Skip to content

Commit

Permalink
Updates to fix (partial) antlr/grammars-v4#4243
Browse files Browse the repository at this point in the history
  • Loading branch information
kaby76 committed Sep 16, 2024
1 parent 36efbbb commit 26565bb
Show file tree
Hide file tree
Showing 94 changed files with 146 additions and 103 deletions.
2 changes: 1 addition & 1 deletion _scripts/set-version.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/bash
version="0.23.5"
version="0.23.6"
cd src
directories=`find . -maxdepth 1 -type d -name "tr*"`
cwd=`pwd`
Expand Down
15 changes: 15 additions & 0 deletions _tests/trgen-targets/Expression.g4
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
grammar Expression;

start: (multiply | divide | add | subtract) EOF;

expression: '(' expression ')' | number;

multiply: expression '*' expression;
divide: expression '/' expression;
add: expression '+' expression;
subtract: expression '-' expression;

number: NUMBER;

NUMBER: [0-9]+;
WS: [ \t\r\n]+ -> skip;
25 changes: 25 additions & 0 deletions _tests/trgen-targets/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
trap 'LAST_COMMAND=$CURRENT_COMMAND; CURRENT_COMMAND=$BASH_COMMAND' DEBUG
trap 'ERROR_CODE=$?; FAILED_COMMAND=$LAST_COMMAND; tput setaf 1; echo "ERROR: command \"$FAILED_COMMAND\" failed with exit code $ERROR_CODE"; put sgr0;' ERR INT TERM
export MSYS2_ARG_CONV_EXCL="*"
where=`dirname -- "$0"`
cd "$where"
where=`pwd`
cd "$where"
echo "$where"

for target in Antlr4ng CSharp Cpp Dart Java JavaScript Python3 TypeScript Go
do
trgen -t $target
pushd Generated-$target
make
bash run.sh -input '1+2'
if [ "$?" != "0" ]
then
echo Test failed.
exit 1
fi
popd
done
echo Test succeeded.
exit 0
2 changes: 1 addition & 1 deletion src/tragl/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This tool is part of Trash, Transformations for Antlr Shell.

## Current version

0.23.5 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.
0.23.6 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.

## License

Expand Down
2 changes: 1 addition & 1 deletion src/tragl/tragl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This program is part of the Trash toolkit.]]>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<Version>0.23.5</Version>
<Version>0.23.6</Version>
<RepositoryUrl>https://github.com/kaby76/Trash/tree/main/src/tragl</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/tranalyze/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ _Output_

## Current version

0.23.5 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.
0.23.6 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.

## License

Expand Down
2 changes: 1 addition & 1 deletion src/tranalyze/tranalyze.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<Version>0.23.5</Version>
<Version>0.23.6</Version>
<RepositoryUrl>https://github.com/kaby76/Trash/tree/main/src/tranalyze</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/trcaret/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Reads a tree from stdin and prints lines and caret marks.

## Current version

0.23.5 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.
0.23.6 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.

## License

Expand Down
2 changes: 1 addition & 1 deletion src/trcaret/trcaret.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This program is part of the Trash toolkit.
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<Version>0.23.5</Version>
<Version>0.23.6</Version>
<RepositoryUrl>https://github.com/kaby76/Trash/tree/main/src/trcaret</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/trclonereplace/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Clone, rename, and replace symbols in a grammar to optimize full stack fallbacks

## Current version

0.23.5 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.
0.23.6 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.

## License

Expand Down
2 changes: 1 addition & 1 deletion src/trclonereplace/trclonereplace.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<Version>0.23.5</Version>
<Version>0.23.6</Version>
<RepositoryUrl>https://github.com/kaby76/Trash/tree/main/src/trclonereplace</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/trcombine/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ The original grammars are left unchanged.

## Current version

0.23.5 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.
0.23.6 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.

## License

Expand Down
2 changes: 1 addition & 1 deletion src/trcombine/trcombine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<Version>0.23.5</Version>
<Version>0.23.6</Version>
<RepositoryUrl>https://github.com/kaby76/Trash/tree/main/src/trcombine</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/trconvert/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ _Output_

## Current version

0.23.5 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.
0.23.6 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.

## License

Expand Down
2 changes: 1 addition & 1 deletion src/trconvert/trconvert.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ syntax. This program is part of the Trash toolkit.]]>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<Version>0.23.5</Version>
<Version>0.23.6</Version>
<RepositoryUrl>https://github.com/kaby76/Trash/tree/main/src/trconvert</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/trcover/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ a grammar.

## Current version

0.23.5 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.
0.23.6 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.

## License

Expand Down
2 changes: 1 addition & 1 deletion src/trcover/trcover.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ for the entire grammar. This program is part of the Trash toolkit.]]>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<Version>0.23.5</Version>
<Version>0.23.6</Version>
<RepositoryUrl>https://github.com/kaby76/Trash/tree/main/src/trcover</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/trdot/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ The output will be:

## Current version

0.23.5 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.
0.23.6 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.

## License

Expand Down
2 changes: 1 addition & 1 deletion src/trdot/trdot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This program is part of the Trash toolkit.
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<Version>0.23.5</Version>
<Version>0.23.6</Version>
<RepositoryUrl>https://github.com/kaby76/Trash/tree/main/src/trdot</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/trenum/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## Current version

0.23.5 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.
0.23.6 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.

## License

Expand Down
2 changes: 1 addition & 1 deletion src/trenum/trenum.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This program is part of the Trash toolkit.
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<Version>0.23.5</Version>
<Version>0.23.6</Version>
<RepositoryUrl>https://github.com/kaby76/Trash/tree/main/src/trull</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/trfirst/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command.

## Current version

0.23.5 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.
0.23.6 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.

## License

Expand Down
2 changes: 1 addition & 1 deletion src/trfirst/trfirst.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<Version>0.23.5</Version>
<Version>0.23.6</Version>
<RepositoryUrl>https://github.com/kaby76/Trash/tree/main/src/trfirst</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/trfold/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command.

## Current version

0.23.5 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.
0.23.6 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.

## License

Expand Down
2 changes: 1 addition & 1 deletion src/trfold/trfold.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<Version>0.23.5</Version>
<Version>0.23.6</Version>
<RepositoryUrl>https://github.com/kaby76/Trash/tree/main/src/trfold</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/trfoldlit/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command.

## Current version

0.23.5 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.
0.23.6 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.

## License

Expand Down
2 changes: 1 addition & 1 deletion src/trfoldlit/trfoldlit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<Version>0.23.5</Version>
<Version>0.23.6</Version>
<RepositoryUrl>https://github.com/kaby76/Trash/tree/main/src/trfoldlit</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/trformat/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Format of grammar using machine learning.

## Current version

0.23.5 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.
0.23.6 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.

## License

Expand Down
2 changes: 1 addition & 1 deletion src/trformat/trformat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<Version>0.23.5</Version>
<Version>0.23.6</Version>
<RepositoryUrl>https://github.com/kaby76/Trash/tree/main/src/trformat</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
Expand Down
26 changes: 14 additions & 12 deletions src/trgen/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ private void ModifyWithGrammarParse(Config config)
OriginalSourceFileName = sgfn,
ParsingResultSet = parsing_result_set,
StartSymbol = start_symbol,
WhatType = GrammarTuple.Type.Combined,
WhatType = GrammarTuple.Type.Parser,
};
test.tool_grammar_tuples.Add(g);
}
Expand Down Expand Up @@ -412,9 +412,9 @@ private void ModifyWithGrammarParse(Config config)
}
else
{
t.GeneratedFileName = pre1 + t.GrammarName + Suffix(test.target);
t.GeneratedIncludeFileName = pre1 + t.GrammarName + ".h";
t.GrammarAutomName = pre2 + t.GrammarName;
t.GrammarAutomName = pre2 + t.GrammarName + "Parser";
t.GeneratedFileName = pre1 + t.GrammarAutomName + Suffix(test.target);
t.GeneratedIncludeFileName = pre1 + t.GrammarAutomName + ".h";
t.GrammarGoNewName = "";
}
}
Expand All @@ -431,14 +431,15 @@ private void ModifyWithGrammarParse(Config config)
}
else
{
t.GeneratedFileName = pre1 + t.GrammarName + Suffix(test.target);
t.GeneratedIncludeFileName = pre1 + t.GrammarName + ".h";
t.GrammarAutomName = pre2 + t.GrammarName;
t.GrammarAutomName = pre2 + t.GrammarName + "Lexer";
t.GeneratedFileName = pre1 + t.GrammarAutomName + Suffix(test.target);
t.GeneratedIncludeFileName = pre1 + t.GrammarAutomName + ".h";
t.GrammarGoNewName = "";
}
}
else if (t.WhatType == GrammarTuple.Type.Combined)
{
throw new Exception("Should not execute!");
var pre1 = test.package == "" ? "" : test.package + "/";

Check warning on line 443 in src/trgen/Command.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected

Check warning on line 443 in src/trgen/Command.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected

Check warning on line 443 in src/trgen/Command.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected
var pre2 = test.package.Replace("/", ".") == "" ? "" : test.package.Replace("/", ".") + ".";
if (test.target == "Go")
Expand Down Expand Up @@ -466,17 +467,14 @@ private void ModifyWithGrammarParse(Config config)
if (!t.IsTopLevel) continue;
if (t.WhatType == GrammarTuple.Type.Parser)
{
t.GrammarAutomName = t.GrammarName;
t.GrammarGoNewName = "New" + t.GrammarAutomName;
}
else if (t.WhatType == GrammarTuple.Type.Lexer)
{
t.GrammarAutomName = t.GrammarName;
t.GrammarGoNewName = "New" + t.GrammarAutomName;
}
else if (t.WhatType == GrammarTuple.Type.Combined)
{
t.GrammarAutomName = test.grammar_name;
t.GrammarGoNewName = "New" + t.GrammarAutomName;
}
}
Expand Down Expand Up @@ -513,6 +511,7 @@ private void ModifyWithGrammarParse(Config config)
}
else if (t.WhatType == GrammarTuple.Type.Combined)
{
throw new Exception("Should not execute!");
if (test.grammar_name == t.GrammarName)

Check warning on line 515 in src/trgen/Command.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected

Check warning on line 515 in src/trgen/Command.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected

Check warning on line 515 in src/trgen/Command.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected
{
test.fully_qualified_parser_name = t.GrammarAutomName + "Parser";
Expand Down Expand Up @@ -541,7 +540,7 @@ private void ModifyWithGrammarParse(Config config)
}
}

public static string version = "0.23.5";
public static string version = "0.23.6";

// For maven-generated code.
public List<string> failed_modules = new List<string>();
Expand Down Expand Up @@ -1731,7 +1730,10 @@ void ComputeSort(Test test)
{
if (!graph.Edges.Any(e => e.To == n))
{
test.tool_grammar_tuples.Where(t => t.GrammarName == n).First().IsTopLevel = true;
foreach (var z in test.tool_grammar_tuples.Where(t => t.GrammarName == n))
{
z.IsTopLevel = true;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/trgen/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"profiles": {
"dotnet-antlr": {
"commandName": "Project",
"commandLineArgs": "-i save,comp -t CSharp",
"workingDirectory": "C:\\msys64\\home\\Kenne\\fortran"
"commandLineArgs": "-t TypeScript",
"workingDirectory": "C:\\msys64\\home\\Kenne\\temp4"
}
}
}
2 changes: 1 addition & 1 deletion src/trgen/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ simplify and eliminate bugs created when adding new grammars.

## Current version

0.23.5 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.
0.23.6 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates.

## License

Expand Down
Loading

0 comments on commit 26565bb

Please sign in to comment.