Skip to content
Discussion options

You must be logged in to vote

Check your build environment. The grammar works fine, although the grammar does not recognize whitespace, so spaces and newlines cannot appear at all in the input. Output the tokens recognized when debugging a parser.

$ cat Test.g4
grammar Test;

generic: ID '<' genericElement  '>' ;
genericElement: ID | generic ;

ID: CHAR+ ;
CHAR:  'a'..'z' | 'A'..'Z';

Kenne@DESKTOP-DL44R7B MINGW64 ~/z/Generated-CSharp
$ cat in.txt
A<B<C>>
Kenne@DESKTOP-DL44R7B MINGW64 ~/z/Generated-CSharp
$ ./bin/Debug/net6.0/Test.exe in.txt -tokens
[@0,0:0='A',<3>,1:0]
[@1,1:1='<',<1>,1:1]
[@2,2:2='B',<3>,1:2]
[@3,3:3='<',<1>,1:3]
[@4,4:4='C',<3>,1:4]
[@5,5:5='>',<2>,1:5]
[@6,6:6='>',<2>,1:6]
[@7,7:6='<EOF>',<-1>,1:7…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ReverseJay
Comment options

@ReverseJay
Comment options

Answer selected by ReverseJay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants