Tools for Constructing Lexers
We can use JavaCC file to generate lexers.
Files:
- simple lexer for polynomials: polyTokens.jj
- simple main file: PolyTokenTest.java
- simple test input for lexer: TestPolyInput.poly
Instructions:
javacc polyTokens.jj javac *.java java -cp . PolyTokenTest < TestPolyInput.poly
Note:
- still must e.g. manually convert digit sequence into an integer
- but easier once you know that you have correct token (we know its beginning and end)