Description
Accompanying PDF file describes the home-brewed, full flavored language G++. (Gppsyntax.pdf). We are
asking you to develop a lexer that will accept any set of valid g++ expressions and reject incorrect
expressions. Your lexer will tokenize the valid statements of the g++ language and identify incorrect
statements and produce an error message regarding the incorrect statement.
You are asked to implement the lexer in two different ways:
• There are tools to implement lexers given the rules in a meta-grammar such as CFGs. One such
tool is “Flex” that lets you generate C code to do the lexical analysis. In the first part of the
assignment you will use Flex to generate a valid lexer for G++.
• In the second part, you will be implementing a lexer for G++ in Lisp. For this part you are not
expected to use a meta-grammar to define the lexical syntax of your language.
CSE341 – Fall 2020 Assignment # 1
Page 2 of 2
Both lexers should start the interpreter. It will read one line at a time from the user and check if the input
lexically correct while generating the tokens for later processing.
Part 1. G++ Language Lexer using Flex: Implement your lexer using Flex. Hand in your “gpp_lexer.l” file
for this part of the assignment . You are also expected to submit the corresponding C file generated
by flex in “gpp_lexer.c” along with any other .h or .c file that is needed to compile “gpp_lexer.c” using
GCC on Ubuntu (16 or later).
Part 2. G++ Language Lexer in Lisp. Implement your lexer in Common Lisp. Hand in your “gpp_lexer.lisp”
file for this part of the homework. This file should have a function called “gppinterpreter” that will
start your interpreter. “gppinterpreter” can have zero or one input. The input can be a file name
which will be loaded by the interpreter and interpreted right away.
Important note!
Full score for each part requires the lexer code to implement the proper regular expression or DFA
for keywords, identifiers as well as integer values. You may not use available Common Lisp code for
regular expression finding. A penalty will be applied for those not implementing a proper DFA or
regular expression reader.