Skip to content

Commit df8d7d8

Browse files
authored
[build] Fix for build regression -- #4243 (#4253)
* Fix for build regression * Update Antlr4 version for JavaScript testing as python/python3_12 requires it.
1 parent 21efc8c commit df8d7d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1186
-550
lines changed

.config/dotnet-tools.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,73 @@
33
"isRoot": true,
44
"tools": {
55
"trcaret": {
6-
"version": "0.23.3",
6+
"version": "0.23.6",
77
"commands": [
88
"trcaret"
99
]
1010
},
1111
"trcover": {
12-
"version": "0.23.3",
12+
"version": "0.23.6",
1313
"commands": [
1414
"trcover"
1515
]
1616
},
1717
"trgen": {
18-
"version": "0.23.3",
18+
"version": "0.23.6",
1919
"commands": [
2020
"trgen"
2121
]
2222
},
2323
"trglob": {
24-
"version": "0.23.3",
24+
"version": "0.23.6",
2525
"commands": [
2626
"trglob"
2727
]
2828
},
2929
"triconv": {
30-
"version": "0.23.3",
30+
"version": "0.23.6",
3131
"commands": [
3232
"triconv"
3333
]
3434
},
3535
"trparse": {
36-
"version": "0.23.3",
36+
"version": "0.23.6",
3737
"commands": [
3838
"trparse"
3939
]
4040
},
4141
"trquery": {
42-
"version": "0.23.3",
42+
"version": "0.23.6",
4343
"commands": [
4444
"trquery"
4545
]
4646
},
4747
"trtext": {
48-
"version": "0.23.3",
48+
"version": "0.23.6",
4949
"commands": [
5050
"trtext"
5151
]
5252
},
5353
"trwdog": {
54-
"version": "0.23.3",
54+
"version": "0.23.6",
5555
"commands": [
5656
"trwdog"
5757
]
5858
},
5959
"trxgrep": {
60-
"version": "0.23.3",
60+
"version": "0.23.6",
6161
"commands": [
6262
"trxgrep"
6363
]
6464
},
6565
"trxml": {
66-
"version": "0.23.3",
66+
"version": "0.23.6",
6767
"commands": [
6868
"trxml"
6969
]
7070
},
7171
"trxml2": {
72-
"version": "0.23.3",
72+
"version": "0.23.6",
7373
"commands": [
7474
"trxml2"
7575
]

.config/dotnet-tools.json.save

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,73 @@
33
"isRoot": true,
44
"tools": {
55
"trcaret": {
6-
"version": "0.23.3",
6+
"version": "0.23.6",
77
"commands": [
88
"trcaret"
99
]
1010
},
1111
"trcover": {
12-
"version": "0.23.3",
12+
"version": "0.23.6",
1313
"commands": [
1414
"trcover"
1515
]
1616
},
1717
"trgen": {
18-
"version": "0.23.3",
18+
"version": "0.23.6",
1919
"commands": [
2020
"trgen"
2121
]
2222
},
2323
"trglob": {
24-
"version": "0.23.3",
24+
"version": "0.23.6",
2525
"commands": [
2626
"trglob"
2727
]
2828
},
2929
"triconv": {
30-
"version": "0.23.3",
30+
"version": "0.23.6",
3131
"commands": [
3232
"triconv"
3333
]
3434
},
3535
"trparse": {
36-
"version": "0.23.3",
36+
"version": "0.23.6",
3737
"commands": [
3838
"trparse"
3939
]
4040
},
4141
"trquery": {
42-
"version": "0.23.3",
42+
"version": "0.23.6",
4343
"commands": [
4444
"trquery"
4545
]
4646
},
4747
"trtext": {
48-
"version": "0.23.3",
48+
"version": "0.23.6",
4949
"commands": [
5050
"trtext"
5151
]
5252
},
5353
"trwdog": {
54-
"version": "0.23.3",
54+
"version": "0.23.6",
5555
"commands": [
5656
"trwdog"
5757
]
5858
},
5959
"trxgrep": {
60-
"version": "0.23.3",
60+
"version": "0.23.6",
6161
"commands": [
6262
"trxgrep"
6363
]
6464
},
6565
"trxml": {
66-
"version": "0.23.3",
66+
"version": "0.23.6",
6767
"commands": [
6868
"trxml"
6969
]
7070
},
7171
"trxml2": {
72-
"version": "0.23.3",
72+
"version": "0.23.6",
7373
"commands": [
7474
"trxml2"
7575
]

.github/workflows/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ jobs:
130130
- name: Test JavaScript
131131
run: |
132132
node --version
133+
- name: ts-node typescript tsx
134+
run: |
135+
npm i -g ts-node typescript tsx
136+
ts-node --version
137+
tsc --version
138+
npx -v
139+
npx tsx -v
133140
- name: Update paths
134141
shell: pwsh
135142
run: |

_scripts/templates/Antlr4ng/st.Test.ts

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
// Generated from trgen <version>
22

33
import { ATNSimulator } from 'antlr4ng';
4+
import { BaseErrorListener } from 'antlr4ng';
45
import { CharStream } from 'antlr4ng';
56
import { CommonTokenStream } from 'antlr4ng';
67
import { ConsoleErrorListener } from 'antlr4ng';
7-
import { BaseErrorListener } from 'antlr4ng';
8+
import { ErrorNode } from 'antlr4ng';
89
//import { InputStream } from 'antlr4ng';
10+
import { Parser } from 'antlr4ng';
11+
import { ParserRuleContext } from 'antlr4ng';
12+
import { ParseTree } from 'antlr4ng';
913
import { Recognizer } from 'antlr4ng';
1014
import { RecognitionException } from 'antlr4ng';
15+
import { TerminalNode } from 'antlr4ng';
1116
import { Token } from 'antlr4ng';
17+
import { Trees } from 'antlr4ng';
18+
import { escapeWhitespace } from 'antlr4ng';
1219
import { readFileSync } from 'fs';
1320
import { writeFileSync } from 'fs';
1421
import { openSync } from 'fs';
1522
import { readSync } from 'fs';
1623
import { writeSync } from 'fs';
1724
import { closeSync } from 'fs';
1825
import { readFile } from 'fs/promises'
26+
import { isToken } from 'antlr4ng';
1927

2028
<tool_grammar_tuples: {x | import { <x.GrammarAutomName> \} from './<x.GrammarAutomName>.js';
2129
} >
@@ -221,5 +229,55 @@ function DoParse(str: CharStream, input_name: string, row_number: number) {
221229
}
222230
}
223231

232+
function toStringTree(tree: ParseTree, recog?: Parser | null): string {
233+
var sb = new StringBuilder();
234+
let ruleNames = recog.ruleNames;
235+
toStringTree2(sb, tree, 0, ruleNames);
236+
return sb.toString();
237+
}
238+
239+
function toStringTree2(sb: StringBuilder, tree: ParseTree, indent: number, ruleNames: string[] | null): void {
240+
let s = getNodeText(tree, ruleNames);
241+
s = escapeWhitespace(s!, false);
242+
const c = tree.getChildCount();
243+
if (c === 0) {
244+
for (let i = 0; i \< indent; ++i) sb.Append(" ");
245+
sb.Append(s); sb.AppendLine("");
246+
return;
247+
}
248+
for (let i = 0; i \< indent; ++i) sb.Append(" ");
249+
sb.Append(s); sb.AppendLine("");
250+
for (let i = 0; i \< c; i++) {
251+
toStringTree2(sb, tree.getChild(i)!, indent+1, ruleNames);
252+
}
253+
}
254+
255+
function getNodeText(t: ParseTree, ruleNames: string[] | null, recog?: Parser | null): string | undefined {
256+
if (ruleNames !== null) {
257+
if (t instanceof ParserRuleContext) {
258+
const context = t.ruleContext;
259+
const altNumber = context.getAltNumber();
260+
// use const value of ATN.INVALID_ALT_NUMBER to avoid circular dependency
261+
if (altNumber !== 0) {
262+
return ruleNames[t.ruleIndex] + ":" + altNumber;
263+
}
264+
265+
return ruleNames[t.ruleIndex];
266+
} else if (t instanceof ErrorNode) {
267+
return t.toString();
268+
} else if (t instanceof TerminalNode) {
269+
if (t.symbol !== null) {
270+
return t.symbol.text;
271+
}
272+
}
273+
}
274+
const payload = t.getPayload();
275+
if (isToken(payload)) {
276+
return payload.text;
277+
}
278+
279+
return String(t.getPayload());
280+
}
281+
224282

225283
main()

_scripts/templates/Antlr4ng/st.perf.sh

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
11
# Generated from trgen <version>
22

3-
# People often specify a test file directory, but sometimes no
4-
# tests are provided. Git won't check in an empty directory.
5-
# Test if the test file directory does not exist, or it is just
6-
# an empty directory.
7-
if [ ! -d ../<example_files_unix> ]
8-
then
9-
echo "No test cases provided."
10-
exit 0
11-
elif [ ! "$(ls -A ../<example_files_unix>)" ]
12-
then
13-
echo "No test cases provided."
14-
exit 0
15-
fi
16-
173
SAVEIFS=$IFS
184
IFS=$(echo -en "\n\b")
195

206
# Get a list of test files from the test directory. Do not include any
217
# .errors or .tree files. Pay close attention to remove only file names
228
# that end with the suffix .errors or .tree.
23-
files2=`find ../<example_files_unix> -type f | grep -v '.errors$' | grep -v '.tree$'`
9+
files2=`dotnet trglob -- '../<example_files_unix>' | grep -v '.errors$' | grep -v '.tree$'`
2410
files=()
2511
for f in $files2
2612
do
27-
triconv -f utf-8 $f > /dev/null 2>&1
13+
if [ -d "$f" ]; then continue; fi
14+
dotnet triconv -- -f utf-8 $f > /dev/null 2>&1
2815
if [ "$?" = "0" ]
2916
then
3017
files+=( $f )
3118
fi
3219
done
3320

21+
# People often specify a test file directory, but sometimes no
22+
# tests are provided. Git won't check in an empty directory.
23+
# Test if there are no test files.
24+
if [ ${#files[@]} -eq 0 ]
25+
then
26+
echo "No test cases provided."
27+
exit 0
28+
fi
29+
3430
# Parse all input files.
3531
# Individual parsing.
3632
rm -f parse.txt
Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
# Generated from trgen <version>
22
set -e
3-
# set -x
3+
set -x
44

5-
# ts-node is a bash script, so duplicate that code and call node via trwdog.
6-
tsnode=`which ts-node`
5+
exec npx tsx Test.js "$@"
76

8-
basedir=$(dirname "$(echo "$tsnode" | sed -e 's,\\\\,/,g')")
9-
10-
case `uname` in
11-
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
12-
esac
13-
14-
if [ -x "$basedir/node" ]; then
15-
exec "$basedir/node" "$basedir/node_modules/ts-node/dist/bin.js" Test.js "$@"
16-
else
17-
exec node "$basedir/node_modules/ts-node/dist/bin.js" Test.js "$@"
18-
fi
197
exit $?

_scripts/templates/Antlr4ng/st.test.ps1

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ if (-not(Test-Path -Path "tests.txt" -PathType Leaf)) {
4040
# Parse all input files.
4141
<if(individual_parsing)>
4242
# Individual parsing.
43-
Get-Content "tests.txt" | ForEach-Object { dotnet trwdog -- pwsh -command "ts-node Test.js -q -tee -tree $_" *>> parse.txt }
43+
Get-Content "tests.txt" | ForEach-Object { dotnet trwdog -- pwsh -command "npx tsx Test.js -q -tee -tree $_" *>> parse.txt }
4444
<else>
4545
# Group parsing.
46-
get-content "tests.txt" | dotnet trwdog -- pwsh -command "ts-node Test.js -q -x -tee -tree" *> parse.txt
46+
get-content "tests.txt" | dotnet trwdog -- pwsh -command "npx tsx Test.js -q -x -tee -tree" *> parse.txt
4747
$status=$LASTEXITCODE
4848
<endif>
4949

@@ -66,8 +66,26 @@ if ( $size -eq 0 ) {
6666
exit 1
6767
}
6868

69+
function func {
70+
param (
71+
[string]$p
72+
)
73+
74+
# Find the index of the first asterisk (*)
75+
$index = $p.IndexOf('*')
76+
77+
if ($index -eq -1) {
78+
# No asterisk found, return the entire path
79+
return $p
80+
} else {
81+
# Asterisk found, return the path up to but not including the asterisk
82+
$path = $p.Substring(0, $index)
83+
return $path
84+
}
85+
}
86+
6987
$old = Get-Location
70-
Set-Location ..
88+
Set-Location "<if(os_win)>../<example_dir_win><else>../<example_dir_unix><endif>"
7189

7290
# Check if any .errors/.tree files have changed. That's not good.
7391
git config --global pager.diff false
@@ -88,6 +106,7 @@ foreach ($item in Get-ChildItem . -Recurse) {
88106
$file = $item.fullname
89107
$ext = $item.Extension
90108
if ($ext -eq ".tree") {
109+
[IO.File]::WriteAllText($file, $([IO.File]::ReadAllText($file) -replace "`r`n", "`n"))
91110
git diff --exit-code $file *>> $old/updated.txt
92111
$st = $LASTEXITCODE
93112
if ($st -ne 0) {

0 commit comments

Comments
 (0)