antlr4 expression separator with '\n' and let parser to ignore '\n' like in Kotlin

34 Views Asked by At

I make grammar with antlr4 and encountered a problem with expression separation I need to be able to separate expressions with the next line like in Kotlin, Swift or JavaScript For example:

a = 5
b = 10
c = a + b

Here, each line is new expression, which is separated from the others by a next line character '\n' But i also wants, that '\n' don't separate not-full expression like that

a =
10 + 15

where a = 10 + 15 is whole expression How can i make it?

i surfed internet, but didn't find even crutch solutions ((( i thought replacing

Int : [0-9]+;
WS: [ \t\n\r\f]+ -> skip;

with something like this

Int : [0-9]+ WS;
WS: [ \t\n\r\f]+;

will helps, but i just got a lot of errors of parsing

0

There are 0 best solutions below