c# - ANTLR4 white space causing problems -


I am using coco for a while and I thought I would look at ANRLR 4. I am using the C # version of ANTLR4 I put together the beginning of a grammar and found that it does not work. After several experiments I found out that the problem is to have a small grammar below to show the problem that came down to a problem with white space:

  grammar AB; / * * Parser rule * / paras: now; Ab: IDENT (',' IDENT) *; / * * Lexter Rule * / IDENT: A_Z_ (A_Z_ | DIGIT) *; Piece A_Z_: [A-Z, A-Z, _]; Piece points: [0- 9]; WS: [\ t \ r \ n] + - & gt; Skip;  

A, b does not give any syntax error.

A, b does not give any syntax error. A, B returns: Line: 1 External Output Except 'B' {, ','}

A gives B: Line: 1 External output 'B' is expected {, ',' '}

I probably miss something in my understanding of dealing with white space but I thought that the WS rule should clear all the spaces so that there is an input equal to A. Apart from the B input which works, if I comment on the WS rule, then it does not matter, it seems that the WS rule is not doing anything.

The problem is that comma does not recognize your identity rule

:

  section A_Z_: [A-Z, A-Z, _];  

But do this instead:

  section A_Z_: [A-Za-z_];  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -