Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,7 @@ runtime/Cpp/runtime/cmake_install.cmake
runtime/Cpp/runtime/libantlr4-runtime.4.10.1.dylib
runtime/Cpp/runtime/libantlr4-runtime.a
runtime/Cpp/runtime/libantlr4-runtime.dylib
/runtime/Cpp/runtime/libantlr4-runtime.4.12.0.dylib

# Go test and performance trace files
**/*.pprof
3 changes: 3 additions & 0 deletions runtime/Go/antlr/internal/testrig/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Test rig for go

This test rig will build and run the grammar file test.g4 with the `input` file and turn on all tracing options.
3 changes: 3 additions & 0 deletions runtime/Go/antlr/internal/testrig/antlr/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package antlr

//go:generate ./generate.sh
5 changes: 5 additions & 0 deletions runtime/Go/antlr/internal/testrig/antlr/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/zsh

alias antlr4='java -Xmx500M -cp "./antlr4-4.12.1-SNAPSHOT-complete.jar:$CLASSPATH" org.antlr.v4.Tool'

antlr4 -Dlanguage=Go -visitor -listener -package test -o ../test *.g4
14 changes: 14 additions & 0 deletions runtime/Go/antlr/internal/testrig/antlr/test.g4
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
grammar test;

stat: expression
| IDENTIFIER ';'
;

expression
: expression (AND expression)+
| IDENTIFIER
;

AND : 'and' ;
IDENTIFIER : [a-zA-Z_]+ ;
WS : [ \t\r\n]+ -> skip ;
15 changes: 15 additions & 0 deletions runtime/Go/antlr/internal/testrig/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module testrig

go 1.20

replace github.com/antlr/antlr4/runtime/Go/antlr/v4 => ../../v4

require (
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df
github.com/pyroscope-io/client v0.6.0
)

require (
github.com/pyroscope-io/godeltaprof v0.1.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
)
6 changes: 6 additions & 0 deletions runtime/Go/antlr/internal/testrig/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
github.com/pyroscope-io/client v0.6.0 h1:rcUFgcnfmuyVYDYT+4d0zfqc8YedOyruHSsUb9ImaBw=
github.com/pyroscope-io/client v0.6.0/go.mod h1:4h21iOU4pUOq0prKyDlvYRL+SCKsBc5wKiEtV+rJGqU=
github.com/pyroscope-io/godeltaprof v0.1.0 h1:UBqtjt0yZi4jTxqZmLAs34XG6ycS3vUTlhEUSq4NHLE=
github.com/pyroscope-io/godeltaprof v0.1.0/go.mod h1:psMITXp90+8pFenXkKIpNhrfmI9saQnPbba27VIaiQE=
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
1 change: 1 addition & 0 deletions runtime/Go/antlr/internal/testrig/input
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a and b
23 changes: 23 additions & 0 deletions runtime/Go/antlr/internal/testrig/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"github.com/antlr/antlr4/runtime/Go/antlr/v4"
"testrig/test"
)

func main() {
testRun("input")
}

func testRun(inf string) {

// Pre-initialize so that we can distinguish this initialization from the lexing nad parsing rules
test.TestLexerInit()
test.TestParserInit()

input, _ := antlr.NewFileStream(inf)
lexer := test.NewtestLexer(input)
stream := antlr.NewCommonTokenStream(lexer, 0)
p := test.NewtestParser(stream)
p.Stat()
}
21 changes: 21 additions & 0 deletions runtime/Go/antlr/internal/testrig/test/test.interp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
token literal names:
null
';'
'and'
null
null

token symbolic names:
null
null
AND
IDENTIFIER
WS

rule names:
stat
expression


atn:
[4, 1, 4, 25, 2, 0, 7, 0, 2, 1, 7, 1, 1, 0, 1, 0, 1, 0, 3, 0, 8, 8, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 16, 8, 1, 11, 1, 12, 1, 17, 5, 1, 20, 8, 1, 10, 1, 12, 1, 23, 9, 1, 1, 1, 0, 1, 2, 2, 0, 2, 0, 0, 25, 0, 7, 1, 0, 0, 0, 2, 9, 1, 0, 0, 0, 4, 8, 3, 2, 1, 0, 5, 6, 5, 3, 0, 0, 6, 8, 5, 1, 0, 0, 7, 4, 1, 0, 0, 0, 7, 5, 1, 0, 0, 0, 8, 1, 1, 0, 0, 0, 9, 10, 6, 1, -1, 0, 10, 11, 5, 3, 0, 0, 11, 21, 1, 0, 0, 0, 12, 15, 10, 2, 0, 0, 13, 14, 5, 2, 0, 0, 14, 16, 3, 2, 1, 0, 15, 13, 1, 0, 0, 0, 16, 17, 1, 0, 0, 0, 17, 15, 1, 0, 0, 0, 17, 18, 1, 0, 0, 0, 18, 20, 1, 0, 0, 0, 19, 12, 1, 0, 0, 0, 20, 23, 1, 0, 0, 0, 21, 19, 1, 0, 0, 0, 21, 22, 1, 0, 0, 0, 22, 3, 1, 0, 0, 0, 23, 21, 1, 0, 0, 0, 3, 7, 17, 21]
6 changes: 6 additions & 0 deletions runtime/Go/antlr/internal/testrig/test/test.tokens
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
T__0=1
AND=2
IDENTIFIER=3
WS=4
';'=1
'and'=2
29 changes: 29 additions & 0 deletions runtime/Go/antlr/internal/testrig/test/testLexer.interp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
token literal names:
null
';'
'and'
null
null

token symbolic names:
null
null
AND
IDENTIFIER
WS

rule names:
T__0
AND
IDENTIFIER
WS

channel names:
DEFAULT_TOKEN_CHANNEL
HIDDEN

mode names:
DEFAULT_MODE

atn:
[4, 0, 4, 27, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 2, 17, 8, 2, 11, 2, 12, 2, 18, 1, 3, 4, 3, 22, 8, 3, 11, 3, 12, 3, 23, 1, 3, 1, 3, 0, 0, 4, 1, 1, 3, 2, 5, 3, 7, 4, 1, 0, 2, 3, 0, 65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 28, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 1, 9, 1, 0, 0, 0, 3, 11, 1, 0, 0, 0, 5, 16, 1, 0, 0, 0, 7, 21, 1, 0, 0, 0, 9, 10, 5, 59, 0, 0, 10, 2, 1, 0, 0, 0, 11, 12, 5, 97, 0, 0, 12, 13, 5, 110, 0, 0, 13, 14, 5, 100, 0, 0, 14, 4, 1, 0, 0, 0, 15, 17, 7, 0, 0, 0, 16, 15, 1, 0, 0, 0, 17, 18, 1, 0, 0, 0, 18, 16, 1, 0, 0, 0, 18, 19, 1, 0, 0, 0, 19, 6, 1, 0, 0, 0, 20, 22, 7, 1, 0, 0, 21, 20, 1, 0, 0, 0, 22, 23, 1, 0, 0, 0, 23, 21, 1, 0, 0, 0, 23, 24, 1, 0, 0, 0, 24, 25, 1, 0, 0, 0, 25, 26, 6, 3, 0, 0, 26, 8, 1, 0, 0, 0, 3, 0, 18, 23, 1, 6, 0, 0]
6 changes: 6 additions & 0 deletions runtime/Go/antlr/internal/testrig/test/testLexer.tokens
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
T__0=1
AND=2
IDENTIFIER=3
WS=4
';'=1
'and'=2
33 changes: 33 additions & 0 deletions runtime/Go/antlr/internal/testrig/test/test_base_listener.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions runtime/Go/antlr/internal/testrig/test/test_base_visitor.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

114 changes: 114 additions & 0 deletions runtime/Go/antlr/internal/testrig/test/test_lexer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions runtime/Go/antlr/internal/testrig/test/test_listener.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading