Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Fix build regression. #4246

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
24 changes: 12 additions & 12 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,73 @@
"isRoot": true,
"tools": {
"trcaret": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trcaret"
]
},
"trcover": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trcover"
]
},
"trgen": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trgen"
]
},
"trglob": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trglob"
]
},
"triconv": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"triconv"
]
},
"trparse": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trparse"
]
},
"trquery": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trquery"
]
},
"trtext": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trtext"
]
},
"trwdog": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trwdog"
]
},
"trxgrep": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trxgrep"
]
},
"trxml": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trxml"
]
},
"trxml2": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trxml2"
]
Expand Down
24 changes: 12 additions & 12 deletions .config/dotnet-tools.json.save
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,73 @@
"isRoot": true,
"tools": {
"trcaret": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trcaret"
]
},
"trcover": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trcover"
]
},
"trgen": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trgen"
]
},
"trglob": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trglob"
]
},
"triconv": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"triconv"
]
},
"trparse": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trparse"
]
},
"trquery": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trquery"
]
},
"trtext": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trtext"
]
},
"trwdog": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trwdog"
]
},
"trxgrep": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trxgrep"
]
},
"trxml": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trxml"
]
},
"trxml2": {
"version": "0.23.3",
"version": "0.23.6",
"commands": [
"trxml2"
]
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ jobs:
- name: Test JavaScript
run: |
node --version
- name: ts-node typescript tsx
run: |
npm i -g ts-node typescript tsx
ts-node --version
tsc --version
npx -v
npx tsx -v
- name: Update paths
shell: pwsh
run: |
Expand Down
60 changes: 59 additions & 1 deletion _scripts/templates/Antlr4ng/st.Test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
// Generated from trgen <version>

import { ATNSimulator } from 'antlr4ng';
import { BaseErrorListener } from 'antlr4ng';
import { CharStream } from 'antlr4ng';
import { CommonTokenStream } from 'antlr4ng';
import { ConsoleErrorListener } from 'antlr4ng';
import { BaseErrorListener } from 'antlr4ng';
import { ErrorNode } from 'antlr4ng';
//import { InputStream } from 'antlr4ng';
import { Parser } from 'antlr4ng';
import { ParserRuleContext } from 'antlr4ng';
import { ParseTree } from 'antlr4ng';
import { Recognizer } from 'antlr4ng';
import { RecognitionException } from 'antlr4ng';
import { TerminalNode } from 'antlr4ng';
import { Token } from 'antlr4ng';
import { Trees } from 'antlr4ng';
import { escapeWhitespace } from 'antlr4ng';
import { readFileSync } from 'fs';
import { writeFileSync } from 'fs';
import { openSync } from 'fs';
import { readSync } from 'fs';
import { writeSync } from 'fs';
import { closeSync } from 'fs';
import { readFile } from 'fs/promises'
import { isToken } from 'antlr4ng';

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

function toStringTree(tree: ParseTree, recog?: Parser | null): string {
var sb = new StringBuilder();
let ruleNames = recog.ruleNames;
toStringTree2(sb, tree, 0, ruleNames);
return sb.toString();
}

function toStringTree2(sb: StringBuilder, tree: ParseTree, indent: number, ruleNames: string[] | null): void {
let s = getNodeText(tree, ruleNames);
s = escapeWhitespace(s!, false);
const c = tree.getChildCount();
if (c === 0) {
for (let i = 0; i \< indent; ++i) sb.Append(" ");
sb.Append(s); sb.AppendLine("");
return;
}
for (let i = 0; i \< indent; ++i) sb.Append(" ");
sb.Append(s); sb.AppendLine("");
for (let i = 0; i \< c; i++) {
toStringTree2(sb, tree.getChild(i)!, indent+1, ruleNames);
}
}

function getNodeText(t: ParseTree, ruleNames: string[] | null, recog?: Parser | null): string | undefined {
if (ruleNames !== null) {
if (t instanceof ParserRuleContext) {
const context = t.ruleContext;
const altNumber = context.getAltNumber();
// use const value of ATN.INVALID_ALT_NUMBER to avoid circular dependency
if (altNumber !== 0) {
return ruleNames[t.ruleIndex] + ":" + altNumber;
}

return ruleNames[t.ruleIndex];
} else if (t instanceof ErrorNode) {
return t.toString();
} else if (t instanceof TerminalNode) {
if (t.symbol !== null) {
return t.symbol.text;
}
}
}
const payload = t.getPayload();
if (isToken(payload)) {
return payload.text;
}

return String(t.getPayload());
}


main()
28 changes: 12 additions & 16 deletions _scripts/templates/Antlr4ng/st.perf.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
# Generated from trgen <version>

# People often specify a test file directory, but sometimes no
# tests are provided. Git won't check in an empty directory.
# Test if the test file directory does not exist, or it is just
# an empty directory.
if [ ! -d ../<example_files_unix> ]
then
echo "No test cases provided."
exit 0
elif [ ! "$(ls -A ../<example_files_unix>)" ]
then
echo "No test cases provided."
exit 0
fi

SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

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

# People often specify a test file directory, but sometimes no
# tests are provided. Git won't check in an empty directory.
# Test if there are no test files.
if [ ${#files[@]} -eq 0 ]
then
echo "No test cases provided."
exit 0
fi

# Parse all input files.
# Individual parsing.
rm -f parse.txt
Expand Down
16 changes: 2 additions & 14 deletions _scripts/templates/Antlr4ng/st.run.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
# Generated from trgen <version>
set -e
# set -x
set -x

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

basedir=$(dirname "$(echo "$tsnode" | sed -e 's,\\\\,/,g')")

case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/node_modules/ts-node/dist/bin.js" Test.js "$@"
else
exec node "$basedir/node_modules/ts-node/dist/bin.js" Test.js "$@"
fi
exit $?
25 changes: 22 additions & 3 deletions _scripts/templates/Antlr4ng/st.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ if (-not(Test-Path -Path "tests.txt" -PathType Leaf)) {
# Parse all input files.
<if(individual_parsing)>
# Individual parsing.
Get-Content "tests.txt" | ForEach-Object { dotnet trwdog -- pwsh -command "ts-node Test.js -q -tee -tree $_" *>> parse.txt }
Get-Content "tests.txt" | ForEach-Object { dotnet trwdog -- pwsh -command "npx tsx Test.js -q -tee -tree $_" *>> parse.txt }
<else>
# Group parsing.
get-content "tests.txt" | dotnet trwdog -- pwsh -command "ts-node Test.js -q -x -tee -tree" *> parse.txt
get-content "tests.txt" | dotnet trwdog -- pwsh -command "npx tsx Test.js -q -x -tee -tree" *> parse.txt
$status=$LASTEXITCODE
<endif>

Expand All @@ -66,8 +66,26 @@ if ( $size -eq 0 ) {
exit 1
}

function func {
param (
[string]$p
)

# Find the index of the first asterisk (*)
$index = $p.IndexOf('*')

if ($index -eq -1) {
# No asterisk found, return the entire path
return $p
} else {
# Asterisk found, return the path up to but not including the asterisk
$path = $p.Substring(0, $index)
return $path
}
}

$old = Get-Location
Set-Location ..
Set-Location "<if(os_win)>../<example_dir_win><else>../<example_dir_unix><endif>"

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