This is a simple parser which can parse expressions in a strange way. The syntax for this language is very similar to if-else
of C++. Inside curly braces or round braces, you can enter numbers or similar expressions and it will evaluate the final result.
digit [0-9]+
if "if"
else "else"
cleft "{"
cright "}"
rleft "("
rright ")"
- rL = round left =
(
- cL = curly left =
{
prog:
prog atom
| prog SEMICOLON
|
atom:
IF rL atom rR cL atom cR ELSE cL atom cR
| IF rL atom rR cL atom cR
| DIGIT
if(1){33}
else{55};
if(1){
if(1){33}
else{55}
}
else{
if(1){33}
else{55}
};
make
- Enter inputs as mentioned above.