Skip to content

Commit 8a987a5

Browse files
committed
tweaks to text
1 parent 45d4547 commit 8a987a5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

docs/basic_compiler.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
Basic compiler
22
==============
33

4-
For the first time ever, you are provided with a basic compiler that can lex, parse and generate code for only the following program:
4+
You are provided with a basic compiler that can lex, parse, and generate code for only the following program:
55
```
66
int f() {
77
return 5;
88
}
99
```
1010

11-
Having a somewhat functioning compiler should allow you to get started with development of the interesting parts of this coursework while avoiding the common early pitfalls that students have faced in previous years. It should also allow you to better understand the underlying C90 grammar and have an easier time adding new features.
12-
13-
The provided basic compiler is able to traverse the following AST related to the above program. In order to expand its capabilities, you should develop the parser and the corresponding code generation at the same time - do not try to fully implement one before the other.
11+
The compiler is able to traverse the following AST related to the above program. In order to expand its capabilities, you should develop the parser and the corresponding code generation at the same time -- you are advised not to fully implement one before the other.
1412

1513
![int_main_return_tree](./int_main_return_5_tree.png)
1614

@@ -19,9 +17,9 @@ The lexer and parser are loosely based on the "official" grammar covered [here](
1917

2018
Two versions of the grammar have been provided:
2119

22-
- [parser.y](../src/parser.y) contains a stripped down version of the grammar which contains only the elements from the full grammar that are necessary to parse the above program. **This is the grammar used when you run ./scripts/test.py**.
20+
- [parser.y](../src/parser.y) contains a stripped down version of the grammar which contains only the elements from the full grammar that are necessary to parse the program above. **This is the grammar used when you run ./scripts/test.py**.
2321
- [parser_full.y.example](../src/parser_full.y.example) is the same as `parser.y` but also contains the rest of the C90 grammar not used in the above program. Once you understand how the stripped version works, you have two options: you can extend `parser.y` at your own pace and add pieces of the C90 grammar to it as you implement them; alternatively, you may paste the contents of `parser_full.y.example` into `parser.y` allowing you to parse everything but this may make the file much harder to navigate.
2422

2523
Note that you don't have to use any of the provided grammar examples (or even flex and bison) if you are comfortable with doing something else. However, be warned that TAs will likely only be able to provided limited support for such alternatives.
2624

27-
You can follow the patterns introduced for the code generation part of the basic compiler, but you might find adjusting them to your needs be better in the long run. You are recommended to follow the coding style that best suits you while hopefully picking strong design skills throughout the development of your compiler.
25+
You can follow the patterns introduced for the code generation part of the basic compiler, but you might find adjusting them to your needs is better in the long run.

0 commit comments

Comments
 (0)