首页 > > 详细

Design of A Lexical Parser

 Design of A Lexical Parser 

. Task
Some examples of the symbols subset from C language described by the regular grammar 
are shown below. Add vocabulary symbols as supplement if necessary:
+=, -=,*=,/=,&&, ǁ……
Given some symbols describing C language grammar rules, design and implement lexical 
analysis parser. If necessary, add some symbols which is needed to describe the grammar rules.
→ letter |letter | digit
→ digit |
→ * ︱;︱, ︱ (︱) ︱ {︱}
→ >= ︱<= ︱ ! =︱=︱+ ︱-︱*︱/
→ <
→ = 
→ +
→ -
< logic NOT> → !
Preserved words:void、int、float、double、if、else、for、do、while etc…(it can be added).
[explanation]
(1) The upper and lower character are treated the same, the length of the user defined 
identifier is at most 32Byte
(2) Characters is a-z and A-Z, digital is 0-9
(3) Grammar above can be extended and modified
(4) “/*……*/ and “//” are comments of the program
[design requirements]
(1) Assign the type code of each character symbols (i.e. let identifier equal to 1)
(2) The parser should have the function of finding the input string errors
(3) Design two test examples to test the program and output the analysis result
(4) The output should display the type and value of each input symbols and the error 
information
[main function] 
Through the parser program, the parser analyzer should have the function of identifying the 
symbols of the input files according to the related regular grammar. It should identify: key 
words (preserved words), identifiers and some functional symbols, should report error of 
some symbols which is not identified, as well as the comments.
.Report and requirements
1. The final report should include: the design idea, flow chart if necessary, data structure, 
functions etc 
2. The source code and the test examples should be uploaded as parts of appendix
3. Some test results should be pasted as the result part in the report.
.Upload the file
The final uploaded file should be a zip file includes: final report, source code, test examples 
file, a cover sheet should be added to the file which is your name and ID.
The file you upload to the moodle is also named by your name+ ID
.Plagiarism
It should be your concerns all the time about this problem which is mentioned in every
assignment. If the program is considered a plagiarism, the penalty will be at least one degree 
down or the cancellation of the final exam qualification. 
联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!