CS 453 Programming Assignment #2a — MeggyJava Lexer

Introduction

PA2a is the first programming assignment for CS453 where you can work in a team. Your team will implement the lexer for the MeggyJava compiler. The lexer converts the MeggyJava input file into a list of tokens.

The lexer will need to handle all tokens within the MeggyJava language except for Java comments (both one-line and multi-line comments will be a feature added in a later assignment).

See the Meggy Java Tokens description in the Resources section of the website for a description of Tokens and their associated datatype values. Your token datatype in Haskell will have to match those specified:

data Token
      = TokenImportkw
      | TokenBooleankw
      | TokenIntkw
      | TokenBytekw
      | TokenMainkw
...
      | UnknownChar Char
      
      deriving (Show, Eq)

See the LexerTutorial.hs we covered in class for some ideas in how to implement the lexer.

The main difference between what you will submit and the LexerTutorial.hs is that you should have a separate Main.hs and Lexer.hs. The Lexer should be in its own module. That module should be imported and used in Main.hs. Your Main.hs should print the list of tokens returned from the lexer to standard out.

Submitting the Assignment

Grading

Late Policy

Late assignments will be accepted up to 48 hours past the due date for a 10% deduction. The assignment will not be accepted past this period. Late means anything after 11:59pm on the day the assignment is due, including 12 midnight.


mstrout@cs.colostate.edu, 2/12/15