-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht3.txt
51 lines (43 loc) · 1.41 KB
/
t3.txt
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
**
//lexeme, lno, flag, width, offset, type
Semantic error: Identifier already declared
Semantic error: Identifier already declared
FUNCTION
square 33 0
Variable Symbol Table:
lno: 33, depth: 1, tag= 0
entries
x 34 0 2 0 0
value 35 1 2 0 0
FUNCTION
program 24 0
Variable Symbol Table:
lno: 24, depth: 1, tag= 0
entries
v_1_2_3 26 2 2 0 0
result_ 28 2 2 0 0
**
** This testcase demonstrates correctness of module structure with declaration and simple statements**
<<<driver program>>>
start
declare R1_abc: boolean;
declare r2_ABC: integer;
declare var_1: integer;
get_value(v_1_2_3);
declare result_:boolean;
[result_]:=use module square with parameters v_1_2_3;
print(result);
end
<<module square>>
takes input [x:integer];
returns [value:integer];
start
value:= x*x;
end
**notice that this test case does not declare the module before the driver module, still it is syntactically correct as moduleDeclarations is optional. Testing whether a module is declared before its use is a matter of semantic analysis**
** test the correctness of all lexemes and parse tree created
and print the following message on successful compilation on the console
" Input source code is syntactically correct.........."
**
**make sure to produce only relevant output of your compiler code...
Also remove all unnecessary printf statements and make the code more professional before submitting**