forked from lucasspartacus/PUC-Compilers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
125 lines (91 loc) · 4.29 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
README file for Programming Assignment 2 (C++ edition)
=====================================================
Your directory should now contain the following files:
Makefile -> [course dir]/src/PA2/Makefile
README
cool.flex
test.cl
lextest.cc -> [course dir]/src/PA2/lextest.cc
mycoolc -> [course dir]/srcimage.pngPA2/mycoolc
stringtab.cc -> [course dir]/src/PA2/stringtab.cc
utilities.cc -> [course dir]/src/PA2/utilities.cc
handle_flags.cc -> [course dir]/src/PA2/handle_flags.cc
*.d dependency files
*.* other generated files
The include (.h) files for this assignment can be found in
[course dir]/include/PA2
The Makefile contains targets for compiling and running your
program. DO NOT MODIFY.
The README contains this info. Part of the assignment is to fill
the README with the write-up for your project. You should
explain design decisions, explain why your code is correct, and
why your test cases are adequate. It is part of the assignment
to clearly and concisely explain things in text as well as to
comment your code. Just edit this file.
cool.flex is a skeleton file for the specification of the
lexical analyzer. You should complete it with your regular
expressions, patterns and actions. Information on how to do this
is in the flex manual, which is part of your reader.
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.
cool-parse.h contains definitions that are used by almost all parts
of the compiler. DO NOT MODIFY.
stringtab.{cc|h} and stringtab_functions.h contains functions
to manipulate the string tables. DO NOT MODIFY.
utilities.{cc|h} contains functions used by the main() part of
the lextest program. You may want to use the strdup() function
defined in here. Remember that you should not print anything
from inside cool.flex! DO NOT MODIFY.
lextest.cc contains the main function which will call your
lexer and print out the tokens that it returns. DO NOT MODIFY.
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.
cool-lexer.cc is the scanner generated by flex from cool.flex.
DO NOT MODIFY IT, as your changes will be overritten the next
time you run flex.
The *.d files are automatically generated Makefiles that capture
dependencies between source and header files in this directory.
These files are updated automatically by Makefile; see the gmake
documentation for a detailed explanation.
Instructions
------------
To compile your lextest program type:
% gmake 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:
% gmake 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.
To turnin your work type:
% gmake submit-clean
And run the "submit" program following the instructions on the
course web page.
Running "submit" will collect the files cool.flex, test.cl,
README, and test.output. Don't forget to edit the README file to
include your write-up, and to write your own test cases in
test.cl.
You may turn in the assignment as many times as you like.
However, only the last version will be retained for
grading.
If you change architectures you must issue
% gmake clean
when you switch from one type of machine to the other.
If at some point you get weird errors from the linker,
you probably forgot this step.
GOOD LUCK!
---8<------8<------8<------8<---cut here---8<------8<------8<------8<---
Write-up for PA2
----------------