-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
89 lines (66 loc) · 3.2 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
README file for Programming Assignment 2 (Java edition)
=======================================================
Your directory should now contain the following files:
Makefile
README
cool.lex
test.cl
AbstractSymbol.java -> [course dir]/src/PA2J/AbstractSymbol.java
BoolConst.java -> [course dir]/src/PA2J/BoolConst.java
Flags.java -> [course dir]/src/PA2J/Flags.java
IdSymbol.java -> [course dir]/src/PA2J/IdSymbol.java
IdTable.java -> [course dir]/src/PA2J/IdTable.java
IntSymbol.java -> [course dir]/src/PA2J/IntSymbol.java
IntTable.java -> [course dir]/src/PA2J/IntTable.java
Lexer.java -> [course dir]/src/PA2J/Lexer.java
AbstractTable.java -> [course dir]/src/PA2J/AbstractTable.java
StringSymbol.java -> [course dir]/src/PA2J/StringSymbol.java
StringTable.java -> [course dir]/src/PA2J/StringTable.java
Utilities.java -> [course dir]/src/PA2J/Utilities.java
TokenConstants.java -> [course dir]/src/PA2J/TokenConstants.java
*.java other generated files
The Makefile contains targets for compiling and running your
program. DO NOT MODIFY.
cool.lex is a skeleton file for the specification of the
lexical analyzer. You should complete it with your regular
expressions, patterns and actions.
test.cl is a COOL program that you can test the lexical
analyzer on. It contains some errors, so it won't compile with
coolc. However, test.cl does not exercise all lexical
constructs of COOL and part of your assignment is to rewrite
test.cl with a complete set of tests for your lexical analyzer.
TokenConstants.java contains constant definitions that are used by
almost all parts of the compiler. DO NOT MODIFY.
*Table.java and *Symbol.java contain string table data
structures. DO NOT MODIFY.
Utilities.java contains various support functions used by the
main lexer driver (Lexer.java). DO NOT MODIFY.
Lexer.java contains the main method which will call your lexer
and print out the tokens that it returns. DO NOT MODIFY.
CoolLexer.java is the scanner generated by jlex from cool.lex.
DO NOT MODIFY IT, as your changes will be overritten the next
time you run jlex.
mycoolc is a shell script that glues together the phases of the
compiler using Unix pipes instead of statically linking code.
While inefficient, this architecture makes it easy to mix and match
the components you write with those of the course compiler.
DO NOT MODIFY.
Instructions
------------
To compile your lextest program type:
% make lexer
Run your lexer by putting your test input in a file 'foo.cl' and
run the lextest program:
% lexer foo.cl
To run your lexer on the file test.cl type:
% make dotest
If you think your lexical analyzer is correct and behaves like
the one we wrote, you can actually try 'mycoolc' and see whether
it runs and produces correct code for any examples.
If your lexical analyzer behaves in an
unexpected manner, you may get errors anywhere, i.e. during
parsing, during semantic analysis, during code generation or
only when you run the produced code on spim. So beware.
Instructions for turning in the assignment will be posted on the
course web page.
GOOD LUCK!