首页 > > 详细

辅导program、辅导Java编程设计

LAB 1
Design and implementation of a lexical analyser
Your name and ID
一、Purpose
Design and implement a Lexical analyser using regular grammar.
Create rules which can be used in one language subset.
Symbol needed be designed in your LA. Reserve words includes like:
int, float, double, if, else, for, do, while, etc……
二、Design instructions
1. Please supplement reserve words using in the language.
2. The language is not sensitive to uppercase and lowercase.
3. The identifiers defined are not longer than 32bytes.
4. The characters are “a-z” “A-Z”, numbers are 0-9.
5. The rules showed below as examples can be extended and modified.
6. /*……*/ and // are the comments of the program.
7. The platforms we can use could be c, Java, Lex, yacc, LLVM, GCC.
8. Print the output of Tokens and report the errors.
三、Design requirements
1. Output for each kind of token. is the type
you defined and is the class of the token.
2. LA is designed as one pass, the output is a middle file consists of twotuple sequence.
3. Two test cases are needed to test the program function: one reportsthe
errors found in the program.
四、Functions
Through regular grammar analyzing, the LA program completes the
recognition of the symbols in the input file, including reserved words,
identifiers and some other functional symbols, also the comments. The LA
program is needed to find errorsin the source program and report the line
and type of the errors.
The following rules are some examples of describing C language subset
using Regular Grammar. Supplement symbols is not included in these rules.
The students are asked to rewrite the rules according to their designs.
+=, -=, *=, /=, && (and), ||(or).
→ character ︱character ︱number
→ number ︱number
→ * ︱;︱, ︱( ︱) ︱{ ︱}
= ︱= ︱= ︱= ︱
+ ︱- ︱ /
→ <
→ =
→ >
→ /
→ +
→ -
→ !
[some example categories are shown below]
#define ERROR 0
#define INTT 1
……
#define IF 3
#define ELSE 4
……
#define ID 5
#define LT 6 //<
……
#define SR 132 //>>
#define EQUU 133 // ==
……

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

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