Your cart is currently empty!
Problem Write a Lexer for the source language that you have chosen. The output of the lexer must be a “summary” of the tokens in the program. Example For a program in the C language: Input: main ( ) { i n t a = 9 5 9 ;…
Problem
Write a Lexer for the source language that you have chosen. The output of the lexer must be a “summary” of the tokens in the program.
Example
For a program in the C language:
Input:
main ( )
{
i n t a = 9 5 9 ;
f o o ( a ) ;
r e t u r n 0 ;
}
Expected Output:
Token Occurrances Lexemes
OP_ASGN 1 =
’(’ 2 (
’)’ 2 )
IDENTIFIER 3 a
foo
main
BLOCK_BEGIN 1 {
BLOCK_END 1 }
TYPE 1 int
KEYWORD_RET 1 return
INT_CONST 2 959
1
STMT_TERMINATOR 3 ;
Details
– the source of the implementation (in a folder called “src” within “asgn1”;
– a Makefile to build the implementation (it should generate an executable called “lexer” in the folder
“asgn1/bin”;
– a set of at least 5 test cases that you have used to check your implementation (in a folder “asgn1/test”);
– a README file with a brief description for building and running it (within “asgn1”).
Binaries should NOT be part of the submission. Clean the folder of all object and executable files before submission.
– cd asgn1
– make
– bin/lexer test/test1.c (to execute the first test-case file test1.c)