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

Add interp tool like TestRig #3727

Merged
merged 7 commits into from
May 30, 2022
Merged

Add interp tool like TestRig #3727

merged 7 commits into from
May 30, 2022

Conversation

parrt
Copy link
Member

@parrt parrt commented May 29, 2022

An interpreted version of TestRig, which only ran Java-based (and compiled) parser/lexers. This uses java-based interp to process any grammar (ignoring actions of course).

Needed by new tools: https://github.com/antlr/antlr4-tools

$ java org.antlr.v4.gui.Interpreter \
    /Users/parrt/sample/TParser.g4 \
    /Users/parrt/sample/TLexer.g4 \
    expr -profile /tmp/T-profile.csv -tokens /tmp/foo.txt
$ java org.antlr.v4.gui.Interpreter /Users/parrt/sample/JSON.g4 json -profile /tmp/json.csv /tmp/foo.json
Rule,Invocations,Time,Total k,Max k,Ambiguities,DFA cache miss
obj:0,2,0.030417,2,1,0,2
obj:1,1,1.317417,2,2,0,2
arr:2,3,0.034917,3,1,0,2
arr:3,1,0.101917,2,2,0,2
value:4,6,0.341458,6,1,0,3

@kaby76 @KvanTTT @hzeller @mike-lischke @ericvergnaud might be interested. Then I'll hook into python script which installs java/antlr.

$ java org.antlr.v4.gui.Interpreter /Users/parrt/sample/JavaParser.g4 /Users/parrt/sample/JavaLexer.g4 compilationUnit -profile /tmp/a.csv -trace
class T { int i; }
enter   compilationUnit, LT(1)=class
enter   typeDeclaration, LT(1)=class
enter   classDeclaration, LT(1)=class
consume [@0,0:4='class',<9>,1:0] rule classDeclaration
enter   identifier, LT(1)=T
consume [@2,6:6='T',<128>,1:6] rule identifier
exit    identifier, LT(1)={
enter   classBody, LT(1)={
consume [@4,8:8='{',<80>,1:8] rule classBody
enter   classBodyDeclaration, LT(1)=int
...
exit    compilationUnit, LT(1)=<EOF>
$ head /tmp/a.csv
Rule,Invocations,Time (ms),Total k,Max k,Ambiguities,DFA cache miss
compilationUnit:0,1,0.30525,1,1,0,1
compilationUnit:1,1,0.578416,1,1,0,1
compilationUnit:2,2,0.634208,2,1,0,2
compilationUnit:3,1,1.662042,1,1,0,1
packageDeclaration:4,0,0.0,0,0,0,0
importDeclaration:5,0,0.0,0,0,0,0
importDeclaration:6,0,0.0,0,0,0,0
typeDeclaration:7,1,0.0925,1,1,0,1
typeDeclaration:8,1,0.086917,1,1,0,1

parrt added 4 commits May 28, 2022 15:47
Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Terence Parr <parrt@antlr.org>
@parrt parrt added this to the 4.10.2 milestone May 29, 2022
@parrt
Copy link
Member Author

parrt commented May 29, 2022

Signed-off-by: Terence Parr <parrt@antlr.org>
parrt added 2 commits May 30, 2022 12:15
Signed-off-by: Terence Parr <parrt@antlr.org>
Signed-off-by: Terence Parr <parrt@antlr.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant