Practical: Generating Lexical Analyzer With Jlex
Practical: Generating Lexical Analyzer With Jlex
Multimedia University
TCP2451
Programming Language Translation
Lab 8
Practical
1
TCP2451 Programming Language Translation
14. Copy the contents of the “e.lex.java” to replace the entire content in the
“Main.java” of this project.
15. Compile the program.
16. Right-click project -> Properties -> Run and enter the following:
- Main class: SimpleExample.SimpleExample
17. Run the program and view output generated.
Exercise
1. Examine the contents of e.lex and search the Internet for the JLex manual to
understand the contents.
2. Modify e.lex to include tokens for arithmetic and relational operators.
3. Create a Lex file for a different grammar for JLex to generate the lexical analyzer.
Test the lexical analyzer with at least three sample source programs.