(+ 1 2 3 45) (* 1 2 3 4 (\\ 1 3 4 (* 12 34 54) 32 (+ 34 56))) I want to develop
ID: 644761 • Letter: #
Question
(+ 1 2 3 45)
(* 1 2 3 4 ( 1 3 4 (* 12 34 54) 32 (+ 34 56)))
I want to develop the grammar for the above language in ANTLR. This is my ANTLR code but it has error in it.
stat : '(' expr ')'
;
expr : ((PLUS | MINUS|MULT|DIV) atom atom+)?('('expr')'*|('('expr))
;
atom : INT;
INT : '0'..'9'+;
PLUS : '+'
;
MINUS : '-'
;
MULT : '*'
;
DIV : '/' ;
NEWLINE : ' '?' '
;
WS : (' '|' '|' '|' ')+ {skip();};
Explanation / Answer
may be due to missing quotes in your expression
((PLUS | MINUS|MULT|DIV) atom atom+)?('('expr')'*|('('expr')');
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.