Skip to content
Snippets Groups Projects
Commit 3ef96230 authored by johti17's avatar johti17
Browse files

Added another file the student can run the diff against

parent ae8be18b
No related branches found
No related tags found
1 merge request!5Feedback 2023
# Code Skeleton for Lab 3 and Lab 4
This folder contains the code skeleton that you will be working on during Lab 3 and Lab 4.
## Lab 3
For Lab 3 two files are of interest, `parser.y` and `scanner.l`.
To start, begin by integrating what you did in lab 1 to the `scanner.l` file.
Here it is important that you are careful, and that you do not simply copy paste.
Look at the structure of `scanner.l` and enter your rules s.t you do not remove any includes present in that file.
### Testing Lab 3.
There is a number of test files in the `test` directory that you may use to check if your parser works as expected.
We also provide traces that you can use to compare the output of your solution to some expected output.
To do this you can exceute the following sequence of commands.
To check if you get about the same result for expressions you can run:
```bash
./compiler ./test/expression_test.prog > my_output.txt
diff -y my_output.txt ../traces/trace_expression_test.txt
```
The same procedure can be done for the more advanced test, that is `traces/trace-lab3.txt`
```
./compiler ./test/test > my_output.txt
diff -y my_output.txt ../traces/trace-lab3.txt
```
## Lab 4
In lab 4 you will work in file `codegen.cc` search for `/* --- Your code here --- */`'
to see where you need to introduce your changes.
### Testing Lab 4
In order to test Lab 4, there exists a test script.
For more details see the README in the test folder.
## Other notes
For more exhaustive documentation see [The Lab Skeleton Documentation](https://www.ida.liu.se/~TDDD55/laboratories/instructions/_static/skeleton.pdf)
FunctionInformation @ 0x564ef0e59ed0
Tag: 0
ID: main
Table: 0
Parent: 0
Returns: 0
Parameters: none
Locals:
0x564ef0e6c9d0 b
0x564ef0e6c8c0 a
Body: 0x564ef0e6e780
StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [<SymbolInformation @ 0x0>]
| +-putline
| +-0
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [integer]
| +-putreal
| +-ExpressionList (expression, preceding)
| +-Identifier (b)
| +-0
+-StatementList (statement, preceding)
+-Assignment (left, right)
| +-Identifier (b)
| +-Power (left, right) [real]
| +-RealConstant (2) [real]
| +-RealConstant (2) [real]
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [<SymbolInformation @ 0x0>]
| +-putline
| +-0
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [integer]
| +-putreal
| +-ExpressionList (expression, preceding)
| +-Identifier (b)
| +-0
+-StatementList (statement, preceding)
+-Assignment (left, right)
| +-Identifier (b)
| +-Divide (left, right) [real]
| +-RealConstant (2) [real]
| +-RealConstant (2) [real]
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [<SymbolInformation @ 0x0>]
| +-putline
| +-0
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [integer]
| +-putreal
| +-ExpressionList (expression, preceding)
| +-Identifier (b)
| +-0
+-StatementList (statement, preceding)
+-Assignment (left, right)
| +-Identifier (b)
| +-Times (left, right) [real]
| +-RealConstant (2) [real]
| +-RealConstant (2) [real]
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [<SymbolInformation @ 0x0>]
| +-putline
| +-0
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [integer]
| +-putreal
| +-ExpressionList (expression, preceding)
| +-Identifier (b)
| +-0
+-StatementList (statement, preceding)
+-Assignment (left, right)
| +-Identifier (b)
| +-Minus (left, right) [real]
| +-RealConstant (2) [real]
| +-RealConstant (2) [real]
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [<SymbolInformation @ 0x0>]
| +-putline
| +-0
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [integer]
| +-putreal
| +-ExpressionList (expression, preceding)
| +-Identifier (b)
| +-0
+-StatementList (statement, preceding)
+-Assignment (left, right)
| +-Identifier (b)
| +-Plus (left, right) [real]
| +-RealConstant (1) [real]
| +-RealConstant (2) [real]
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [<SymbolInformation @ 0x0>]
| +-putline
| +-0
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [integer]
| +-putint
| +-ExpressionList (expression, preceding)
| +-Identifier (a)
| +-0
+-StatementList (statement, preceding)
+-Assignment (left, right)
| +-Identifier (a)
| +-Power (left, right) [integer]
| +-IntegerConstant (2) [integer]
| +-IntegerConstant (2) [integer]
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [<SymbolInformation @ 0x0>]
| +-putline
| +-0
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [integer]
| +-putint
| +-ExpressionList (expression, preceding)
| +-Identifier (a)
| +-0
+-StatementList (statement, preceding)
+-Assignment (left, right)
| +-Identifier (a)
| +-Divide (left, right) [integer]
| +-IntegerConstant (2) [integer]
| +-IntegerConstant (2) [integer]
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [<SymbolInformation @ 0x0>]
| +-putline
| +-0
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [integer]
| +-putint
| +-ExpressionList (expression, preceding)
| +-Identifier (a)
| +-0
+-StatementList (statement, preceding)
+-Assignment (left, right)
| +-Identifier (a)
| +-Times (left, right) [integer]
| +-IntegerConstant (2) [integer]
| +-IntegerConstant (2) [integer]
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [<SymbolInformation @ 0x0>]
| +-putline
| +-0
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [integer]
| +-putint
| +-ExpressionList (expression, preceding)
| +-Identifier (a)
| +-0
+-StatementList (statement, preceding)
+-Assignment (left, right)
| +-Identifier (a)
| +-Minus (left, right) [integer]
| +-IntegerConstant (2) [integer]
| +-IntegerConstant (2) [integer]
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [<SymbolInformation @ 0x0>]
| +-putline
| +-0
+-StatementList (statement, preceding)
+-CallStatement (call)
| +-FunctionCall (function, arguments) [integer]
| +-putint
| +-ExpressionList (expression, preceding)
| +-Identifier (a)
| +-0
+-StatementList (statement, preceding)
+-Assignment (left, right)
| +-Identifier (a)
| +-Plus (left, right) [integer]
| +-IntegerConstant (1) [integer]
| +-IntegerConstant (2) [integer]
+-0
Quads: 0
-------------------------------------------------------------------------------
SymbolTable @ 0x564ef0e59f28
-------------------------------------------------------------------------------
11 0x564ef0e64320 getint() -> integer
65 0x564ef0e6c8c0 a : 0x564ef0e5bf80 integer [8]
66 0x564ef0e6c9d0 b : 0x564ef0e5bff0 real [8] --> 0x564ef0e6c8c0 a
88 0x564ef0e5bf80 0x564ef0e5bf80 integer [8]
92 0x564ef0e5c060 putreal(x) -> integer
481 0x564ef0e5e110 putline() -> no return type
603 0x564ef0e5bff0 0x564ef0e5bff0 real [8]
775 0x564ef0e601c0 putint(x) -> integer
918 0x564ef0e62270 getreal() -> real
-------------------------------------------------------------------------------
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment