Skip to content
Snippets Groups Projects
Commit c0112c85 authored by John Tinnerholm's avatar John Tinnerholm :art: Committed by Adrian Pop
Browse files

Feedback 2023

parent d3703d08
No related branches found
No related tags found
1 merge request!5Feedback 2023
*.o
lab1/scanner
lab1/scanner.cc
lab3-4/scanner.cc
lab3-4/parser.cc
lab3-4/parser.hh
lab3-4/compiler
\ No newline at end of file
......@@ -132,3 +132,34 @@ The file ``main.cc`` contains a sample main program.
You may have to modify it depending on how you choose to report errors from your parser.
If the scanner encounters an error it will throw an object of type :class`ScannerError`.
Your main program should catch this exception (the sample main program does), print an error message (you can print a :class:`ScannerError` object using stream operators) and then perform error recovery.
Testing your solution
---------------------
A test script is available called test.py with an auxilary file called test.txt.
You may test your solution by using the following command::
python3 test.py test.txt
The output of running this test program should be something like this::
=============================================================================
| 0: 1+2*3^-4 | Expected: 1.02469 | Got: 1.02469 | PASS |
| 1: 1+2/3 | Expected: 1.66667 | Got: 1.66667 | PASS |
| 2: (1+2)/3 | Expected: 1 | Got: 1 | PASS |
| 3: 2*3+5 | Expected: 11 | Got: 11 | PASS |
| 4: 2*(3+5) | Expected: 16 | Got: 16 | PASS |
| 5: 2^2^3 | Expected: 256 | Got: 256 | PASS |
| 6: 2*2^2*2 | Expected: 16 | Got: 16 | PASS |
| 7: (2*2)^(2*2) | Expected: 256 | Got: 256 | PASS |
| 8: 2^2*10 | Expected: 40 | Got: 40 | PASS |
| 9: 1--1 | Expected: 2 | Got: 2 | PASS |
| 10: 1*2^2+3/4^-1 | Expected: 16 | Got: 16 | PASS |
| 11: (-4*-4+4^2) | Expected: 32 | Got: 32 | PASS |
| 12: ((-4*-4+4^2)-32+1) | Expected: 1 | Got: 1 | PASS |
| 13: -(-1--(-(-10--100))) | Expected: 91 | Got: 91 | PASS |
| 14: e | Expected: 2.71828 | Got: 2.71828 | PASS |
| 15: pi | Expected: 3.14159 | Got: 3.14159 | PASS |
| 16: e^pi | Expected: 23.1407 | Got: 23.1407 | PASS |
| 17: log10(10) | Expected: 1 | Got: 1 | PASS |
| 18: sin(pi)+cos(pi) | Expected: -1 | Got: -1 | PASS |
| 19: log(e^e) | Expected: 2.71828 | Got: 2.71828 | PASS |
| 20: sin(pi/2)+cos(0)+tan(pi/4) | Expected: 3 | Got: 3 | PASS |
=============================================================================
......@@ -42,3 +42,26 @@ Hand in the following
Demonstrate your solution to your lab assistant during a laboratory session.
Send an e-mail (one e-mail per group) with your modified code to the same assistant, put TDDD55, assignment number and your LiU logins in the e-mail subject line.
Getting Started
---------------
In this lab you will be working with a quite large codebase.
Documentation concerning this codebase is available under skeleton at the left side in the tab tab "The Skeleton".
It is recommended that you start by implementing the different rules for expressions.
A test program is available at `./test/expression_test.prog`.
However, it might be useful to write your own program and test simple expressions on a step by step basis.
To run the compiler on your own program, named for instance myProgram.prog execute::
./compiler ./test/myProgram.prog
If you want to run the program with debugging information you may run::
./compiler -d ./test/myProgram.prog
See the different files in the test folders for examples on how to write programs in this language.
Troubleshooting
---------------
Make sure that you have checked all places in parser.y with the phrase "Your Code Here".
Once you have done so you can execute the following sequence of commands to check your compiler::
./compiler ./test/test.prog > output.txt
diff -y ./output.txt ../traces/trace-lab3.txt
Using this commands you will get a side by side comparision of your own output and a trace.
Take note that the memory addresses might differ for some entries, this is ok.
......@@ -26,3 +26,15 @@ Questions
For example, assigning a constant to a variable causes two quads to be generated, where one would have been enough.
There are a number of other situations where equally bad code is generated.
Suggest at least one way of eliminating most of the bad code that is generated.
Testing your solution
---------------------
To test your solution you may run the code-test.sh script located in the lab3-4 folder.
You can run this script using the following command::
bash ./codegen-test.sh
However, it might be wise to employ a step by step strategy.
Hence, similar to Lab III you may write your own test program and test it as you add new features to the backend.
Assuming you have written your own program you may test this program by invoking the compiler in the following way::
./compiler -c ./test/myProgram.prog > myProgram.c
gcc -g -o myProgram myProgram.c -lm
./myProgram
scanner.o: scanner.cc scanner.h
main.o: main.cc scanner.h
#define FUNCTION 258
#define ID 259
#define DECLARE 260
#define ARRAY 261
#define INTEGER 262
#define OF 263
#define REAL 264
#define XBEGIN 265
#define XEND 266
#define IF 267
#define THEN 268
#define ELSE 269
#define WHILE 270
#define DO 271
#define ASSIGN 272
#define RETURN 273
#define GE 274
#define LE 275
#define EQ 276
#define NE 277
#define TRUE 278
#define FALSE 279
#define PROGRAM 280
#define ELSEIF 281
#define NOT 282
#define AND 283
#define OR 284
#define UMINUS 285
#define FUNCTION 258
#define ID 259
#define DECLARE 260
#define ARRAY 261
#define INTEGER 262
#define OF 263
#define REAL 264
#define XBEGIN 265
#define XEND 266
#define IF 267
#define THEN 268
#define ELSE 269
#define WHILE 270
#define DO 271
#define ASSIGN 272
#define RETURN 273
#define GE 274
#define LE 275
#define EQ 276
#define NE 277
#define TRUE 278
#define FALSE 279
#define PROGRAM 280
#define ELSEIF 281
#define NOT 282
#define AND 283
#define OR 284
#define UMINUS 285
#define true 286
#define false 287
......@@ -52,7 +52,8 @@ not return NOT;
"<>" return NE;
array return ARRAY;
of return OF;
true return TRUE;
false return FALSE;
......
# Instructions on how to run the test script
This folder contains the code for lab 2. A test script exists to test your implementation. To run this test script, you must execute the following command in the terminal on the IDA Lab Computers.
```bash
python3 test.py test.txt --program ./lab2
```
This assumes that you have successfully compiled the project by executing the makefile and *that the program has been configured to read successfully from stdin*.
Furthermore, the test script assumes that the lab has been completed according to the instructions, mistakes might cause the test script to malfunction.
To make the project make sure that you execute:
```
make
````
in the command line interface.
## Notes (Important)
* The test script assumes that you have Python 3 installed and that you run on the IDA Lab Systems. It is has not been tested on other systems such as MacOS or GNU/Linux.
* Initially the program will just enter an infinite loop. Hence, you will need to modify the program and get the basic scaffolding in place before you can run the test script. Thus, it might be a good idea to test of some of the arthimatic expressions in the terminal before proceeding with the test script.
To avoid inifnite loops when using files from stdin the following code snippet could be helpful.
Here we specifiy that if we encounter the end of file token we will throw an `ParserEndOfFile` error.
````c++
double Parser::<your name of the start expression>() {
//Note almost correct C++ but you will need to modify this code in order to make it run corretly. Do not simply just copy paste.
currentToken = scanner.Scan();
if (currentToken.type == kEndMark) {
throw ParserEndOfFile();
}
return <name of your expression method>();
}
````
This will be cought by the main loop which is configured in the following way:
```c++
int main(void)
{
Parser parser;
double val;
while (true)
{
try
{
cout << "Expression: " << flush;
/* Implement the parser.Parse method */
val = parser.Parse();
cout << "Result: " << val << '\n' << flush;
}
catch (ScannerError& e)
{
cerr << e << '\n' << flush;
parser.Recover();
}
catch (ParserError)
{
parser.Recover();
}
catch (ParserEndOfFile)
{
cerr << "End of file\n" << flush;
exit(0);
}
}
}
```
Note that the program will terminate if the end of file token is encountered.
#!/usr/bin/python3
'''
Written by Martin Olivesten in 2023 for TDDD55.
Full permission to use in anyway with no restrictions. :)
Run: `python3 test.py -h` for usage.
'''
from subprocess import Popen, PIPE, STDOUT
from re import search
from argparse import ArgumentParser as ArgParse
from dataclasses import dataclass
from random import randrange
from io import TextIOWrapper
from typing import List, Tuple
GREEN = '\x1b[32m'
YELLOW = '\x1b[33m'
RED = '\x1b[31m'
RESET = '\x1b[39m'
PASS = f'{GREEN}PASS{RESET}'
FAIL = f'{RED}FAIL{RESET}'
MAYBE = f'{YELLOW}MAYBE{RESET}'
REAL_REGEX = r'-?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][+-]?[0-9]+)?'
dump = ''
@dataclass
class Result():
expr: str
expected: str
got: str
outcome: str
def parse_tests(file: TextIOWrapper) -> List[Tuple[str, str]]:
tests = file.readlines()
tests = filter(lambda t: t[0] != '#' and t.strip(), tests)
tests = map(lambda t: t.split('='), tests)
tests = list(tests)
for t in tests:
if len(t) != 2:
print(f'ERR: Invalid test format: `{", ".join(t).strip()}`.')
exit(1)
tests = map(lambda p: list(map(str.strip, p)), tests)
return list(tests)
def run_tests(tests: List[Tuple[str, str]], prog: str) -> (List[Result], int):
global dump
res = []
n_err = 0
for i, test in enumerate(tests):
expr, expected = test
p = Popen([prog], stdin=PIPE, stdout=PIPE, stderr=STDOUT)
p_out = p.communicate(f'{expr}\n'.encode())[0].decode()
m = search(fr'Result:\s*{REAL_REGEX}', p_out)
if m is None:
res.append(Result(expr, expected, 'ERR', FAIL))
n_err += 1
dump += 'ERR: Could not match for result in output.\n'
dump += f'INPUT: {expr}\n'
dump += f'OUTPUT:\n{p_out}\n\n'
continue
got = search(REAL_REGEX, m[0])[0]
outcome = ''
s_ans = got if len(got) <= len(expected) else expected
l_ans = got if len(got) > len(expected) else expected
if got == expected:
outcome = PASS
elif (len(s_ans) > 1
and s_ans.find('.') != -1
and (search(s_ans, l_ans)
or search(s_ans[:-1], l_ans[:-1]))):
outcome = MAYBE
else:
outcome = FAIL
res.append(Result(expr, expected, got, outcome))
return (res, n_err)
def main(file: TextIOWrapper, prog: str) -> None:
global dump
tests = parse_tests(open(file, 'r'))
if len(tests) == 0:
print("ERR: No tests to run")
exit(1)
res, n_err = run_tests(tests, prog)
expr_len = max(map(lambda r: len(r.expr), res))
expect_len = max(map(lambda r: len(r.expected), res))
got_len = max(map(lambda r: len(r.got), res))
nr_len = len(str(len(res)))
bar_len = 35 + expr_len + expect_len + got_len + nr_len
print('='*bar_len)
for i, r in enumerate(res):
print(f'| {i:>{nr_len}}: {r.expr:>{expr_len}} | Expected: {r.expected:>{expect_len}} | Got: {r.got:>{got_len}} | {r.outcome:>{5 + len(RED) + len(RESET)}} |') # noqa: E501
print('='*bar_len)
if n_err:
rand_str = ''.join([str(randrange(0, 10)) for _ in range(8)])
dump_file = f'./test-{rand_str}-dump.txt'
print(f'Writing error outputs to dump file: `{dump_file}`')
with open(dump_file, 'w') as f:
f.write(dump)
if __name__ == '__main__':
ap = ArgParse()
ap.add_argument(
'file',
help='Test file to use.'
)
ap.add_argument(
'-p', '--program',
default='./lab2',
help='Executable to run tests on. Defaults to `./lab2`.'
)
args = ap.parse_args()
main(args.file, args.program)
# Format:
# expression = expected answer
# '#' and empty lines ignored
# Precedence and associativity
1+2*3^-4 = 1.02469
1+2/3 = 1.66667
(1+2)/3 = 1
2*3+5 = 11
2*(3+5) = 16
2^2^3 = 256
2*2^2*2 = 16
(2*2)^(2*2) = 256
2^2*10 = 40
1--1 = 2
1*2^2+3/4^-1 = 16
(-4*-4+4^2) = 32
((-4*-4+4^2)-32+1) = 1
-(-1--(-(-10--100))) = 91
# Symbolic constants
e = 2.71828
pi = 3.14159
e^pi = 23.1407
# Symbolic functions
log10(10) = 1
sin(pi)+cos(pi) = -1
log(e^e) = 2.71828
sin(pi/2)+cos(0)+tan(pi/4) = 3
# 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.
Following this a good starting point for Lab 3 is to start by implementing support for the different expressions:
```C
/* --- Your code here ---
*
* Insert the expression grammar here
* The start symbol of the expression grammar is
* expression. This is important since it's used
* in a number of other places.
*
* Make sure that your code creates itor nodes in the
* AST wherever necessary and that it only created
* trees for expressions with compatible types!
*/
expression :
{
cerr << "Expression here" << endl;
}
;
```
Followed by the different rules for the conditions of the language:
```C
/* --- Your code here ---
*
* Insert the condition grammar here
* The start symbol is condition. It's used
* elsewhere, so make sure you get it right.
* The boolean constants false and true are represented using the BooleanConstant AST-node.
* The other logical relations are subclasses of BinaryRelation.
* See the file ast.hh for the declarations.
*/
condition :
{
cerr << "Condition here" << endl;
}
;
/* --- End your code --- */
```
### 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.
A good place to start is the function `BinaryGenerateCode`
```C++
/*
*
* This function is used to generate code for all kinds of binary
* operators and relations. The arguments to the function are the
* following:
*
* q The QuadsList onto which the generated code is placed.
* realop The quad to generate for the operator if the arguments
* are of type real.
* intop The quad to generate for the operator if the arguments
* are of type integer.
* left The AST for the left-hand side of the operator. The
* value type of this AST must be the same as that of the
* AST for the right-hand side.
* right The AST for the right-hand side of the operator. The
* value type of this AST must be the same as that of the
* AST for the left-hand side.
* node The operator node itself. You probably won't need this
* unless you want to print an error message.
* type If not NULL, this is the type of the result. This is
* used for relations, where the type of the result is
* always integer, even if the operands are real. If this
* parameter is NULL, then the type of the result is the
* same as the type of the operands (the parser needs to
* make sure that the operands have the same type.)
*
* See the GenerateCode methods for the binary operators for
* examples of how this function is used.
*
*/
static VariableInformation *BinaryGenerateCode(QuadsList& q,
tQuadType realop,
tQuadType intop,
ASTNode *left,
ASTNode *right,
ASTNode *node,
TypeInformation *type = NULL)
{
/* --- Your code here --- */
return NULL;
/* --- End your code --- */
}
```
### 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)
......@@ -17,7 +17,7 @@ fi
echo "Frontend OK"
echo "Translating to C-Code..."
gcc expression_test.c -o expression_test -lm
gcc expression_test.c -o expression_test -lm -Wno-int-conversion
if [ $? -eq 0 ]; then
echo "C-Code-Compilation-OK"
......@@ -67,7 +67,7 @@ fi
echo "Frontend OK"
echo "Translating to C-Code..."
gcc factorial_test.c -o factorial_test -lm
gcc factorial_test.c -o factorial_test -lm -Wno-int-conversion
if [ $? -eq 0 ]; then
echo "C-Code-Compilation-OK"
......@@ -117,7 +117,7 @@ fi
echo "Frontend OK"
echo "Translating to C-Code..."
gcc fibonacci_test.c -o fibonacci_test -lm
gcc fibonacci_test.c -o fibonacci_test -lm -Wno-int-conversion
if [ $? -eq 0 ]; then
echo "C-Code-Compilation-OK"
......@@ -167,7 +167,7 @@ fi
echo "Frontend OK"
echo "Translating to C-Code..."
gcc simple_array_test.c -o simple_array_test -lm
gcc simple_array_test.c -o simple_array_test -lm -Wno-int-conversion
if [ $? -eq 0 ]; then
echo "C-Code-Compilation-OK"
......@@ -205,7 +205,6 @@ echo "***********************"
echo "simple_array_test passed!"
echo "***********************"
#= Simple array =#
echo "Testing sort_test"
./compiler -c ./test/sort_test.prog > sort_test.c
......@@ -219,7 +218,7 @@ fi
echo "Frontend OK"
echo "Translating to C-Code..."
gcc sort_test.c -o sort_test -lm
gcc sort_test.c -o sort_test -lm -Wno-int-conversion
if [ $? -eq 0 ]; then
echo "C-Code-Compilation-OK"
......
......@@ -174,15 +174,10 @@ functions : functions function
* Write the function production. Take care to enter and exit
* scope correctly. You'll need to understand how shift-reduce
* parsing works and when actions are run to do this.
*
* Solutions that rely on shift-time actions will not be
* acceptable. You should be able to solve the problem
* using actions at reduce time only.
*
* In lab 4 you also need to generate code for functions after parsing
* them. Just calling GeneratCode in the function should do the trick.
*/
*/
function :
{
cerr << "Function here" << endl;
......@@ -617,8 +612,10 @@ expressionz : expressionz ',' expression
* Insert the condition grammar here
* The start symbol is condition. It's used
* elsewhere, so make sure you get it right.
*/
* The boolean constants false and true are represented using the BooleanConstant AST-node.
* The other logical relations are subclasses of BinaryRelation.
* See the file ast.hh for the declarations.
*/
condition :
{
cerr << "Condition here" << endl;
......
......@@ -55,7 +55,8 @@ not return NOT;
"<>" return NE;
array return ARRAY;
of return OF;
true return TRUE;
false return FALSE;
<<EOF>> yyterminate();
......
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.
Finish editing this message first!
Please register or to comment