previous                     ToC                 next


4.      Parsing


Now we have to specify the syntactic structure of RLA well-formed programs.

By means of Cup, we’ll then transform the parser specification (grammar, conflict resolution directives, ...) into a Java program implementing an LALR parser.

The parser specification of the RLA language is reported in the rla.cup file, that uses the scanner generated by rla.flex to perform lexical analysis and then generates the interface and the parser

We have slightly modified the previous version of mjava.flex, by introducing the class to retrieve more detailed information about lexical tokens.


You can generate a parser for RLA and run it on an input program such as Sample.rla by means of the Windows batch file rla.bat :

· put the rla.flex, rla.cup,, Sample.rla and rla.bat files in a same directory and “cd”  into it

· run rla.bat

· the files, and will be generated

· you will get something like SampleParsingResult.txt printed to your Java console.



previous                     ToC                 next