Some simple projects for practicing compiler design
A scanner for P language.
The scanner can analyze tokens in a P language program.
If there is an unrecognized character in it, the scanner will output the error message, including the number of line and the bad character.
The pseudocomment can control whether tokens should be listed and whether each line should be displayed.
Linux
First, use “makefile” to build the scanner.
% make
And then execute the scanner with the input file name.
% ./scanner [input file name]
Use LEX
to generate a scanner.
Write regular expressions for P language.