ANTLR - parameters
I started learning ANTLR and I was looking at sample grammars. I found the CSV grammar quite interesting:
grammar CSV; file: hdr row+ ; hdr : row ; row : field (',' field)* '\r'? '\n' ; field : TEXT | STRING | ; TEXT : ~[,\n\r"]+ ; STRING : '"' ('""'|~'"')* '"' ;
Is it possible to tell antlr that each line should be the same length as hdr?
In my application, I need such a mechanism. To put it simply, Id like to read in an INT variable contacting the length N of the array and after it the values of N. Something like this:
// example-Input I want to parse A = 3 a_0 = 2 a_1 = 5 //there have to be exactly A = 3 a_ entries a_2 = 3
Is this possible with antlr? And if not directly in grammar, could it be dione after something?
source to share
No one has answered this question yet
Check out similar questions: