A simple recursive descent parser for accepting all nested-if commands implemented in C.
The input for the program is given in the format:
if ( c ) { if ( c ) {...if ( c ) { stmt ; } else { stmt ; }...} else { stmt ; } } else { stmt; }
The grammar for nested-if used is given below. The code is implemented using the following grammar:
S' --> S | SS'
S --> B | B else { S } | A
B --> if ( c ) { S }
A --> stmt;
The code is written in C and can be run in terminal using the following commands:
>gcc rdpnestedif.c -o rdp
>./rdp