CSE 401, Winter 2014
Robert R. Henry
Scanner for Mini Java
Due via dropbox Wednesday January 22th 2014 by the end of the day (midnight). You only need to submit the single source file src/Scanner/minijava.jflex PLEASE make sure there’s a comment at the head of the jflex file that has your group name, and both partners’ names!
In this assignment you will be extending the existing jflex specification for Mini Java to be able to scan the final mini Java language.
- The scanner returns tokens to the parser which, in the parser’s domain, are called terminal (symbols). The definition of these tokens/terminals is in the parser specification file src/Parser/minijava.cup scanner specification file. Just extend the existing terminal definitions; you don’t need to bother (yet) with the cup precedence declarations.
- Extend the scanner specification file src/Scanner/minijava.jflex as necessary to scan Mini Java programs. Most of this will be trivial. Comments and floating point literal constants will be more challenging.
- At some point you will have to convert ASCII decimal radix integer literals to Java longs, and ASCII decimal radix floating point literals to Java doubles; you don’t need to do this for your assignment, but it would be good to get this out of the way.
- There’s no point in doing this yourself; just call the appropriate Java library routine to do this. Libraries rule! Let somebody else do the thinking!
- With some care, you can get away with doing this yourself for integers.
- Under no circumstances should you ever attempt the conversion from ASCII to the internal representation of double/floating point numbers. There are only about 20 people in the whole world who truly understand how to do this correctly!
- Look at the scaffolding/throw-away code in src/TestScanner.java.
- Look at the ant rule test-scanner in build.xml and figure out how to run ant on this rule.
- You should be able to correctly scan every test program you wrote in assignment 2, except for those you may have written to provoke scan errors.