Soal Token
Soal 1 :
Var
a,b : integer;
c : boolean;
d : boolean;
e : real;
begin
a := 34;
b := 10;
If d
e := 23.56;
end
Terjemahan dalam Token :
1. identifier
→ Var
2. identifier
→ a
3. delimiter
→ ,
4. identifier
→ b
5. delimiter
→ :
6. identifier
→ integer
7. delimiter
→ ;
8. identifier
→
c
9. delimiter
→
:
10. identifier →
boolean
11. delimiter →
;
12. identifier → d
13. delimiter → :
14. identifier → boolean
15. delimiter → ;
16. identifier → e
17. delimiter → :
18. identifier →
real
19. delimiter →
;
20. identifier →
begin
21. identifier →
a
22. operator →
:=
23. konstanta
riil → 34
24. delimiter →
;
25. identifier →
b
26. operator → :=
27. konstanta
riil →
10
28. delimiter →
;
29. identifier →
If
30. identifier →
d
31. identifier →
e
32. operator →
:=
33. konstanta
riil → 23.56
34. delimiter →
;
35. identifier → end
Tabel lokasi Token
Lokasi
|
Token
|
0
|
Var
|
1
|
a
|
0
|
,
|
2
|
b
|
0
|
:
|
0
|
integer
|
0
|
;
|
3
|
c
|
0
|
:
|
0
|
boolean
|
0
|
;
|
4
|
d
|
0
|
:
|
0
|
boolean
|
0
|
;
|
5
|
e
|
0
|
:
|
0
|
real
|
0
|
;
|
0
|
begin
|
1
|
a
|
0
|
:=
|
6
|
34
|
0
|
;
|
2
|
b
|
0
|
:=
|
7
|
10
|
0
|
;
|
0
|
If
|
4
|
d
|
5
|
e
|
0
|
:=
|
8
|
23,56
|
0
|
;
|
0
|
end
|
Soal 2 :
Var
a : boolean;
begin
a := true;
If a
Then a:= false;
end
Terjemahan dalam Token :
1. identifier
→ Var
2. identifier
→ a
3. delimiter
→ :
4. identifier
→ boolean
5. delimiter
→ ;
6. identifier
→ begin
7. identifier
→ a
8. operator
→ :=
9. konstanta
→ true
10. delimiter → ;
11. identifier → If
12. identifier → a
13. identifier → Then
14. identifier → a
15. operator → :=
16. konstanta → false
17. delimiter → ;
18. identifier → end
Tabel lokasi Token :
Lokasi
|
Token
|
0
|
Var
|
1
|
a
|
0
|
:
|
0
|
boolean
|
0
|
;
|
0
|
begin
|
1
|
a
|
0
|
:=
|
2
|
true
|
0
|
;
|
0
|
If
|
1
|
a
|
0
|
Then
|
1
|
a
|
0
|
:=
|
3
|
false
|
0
|
;
|
0
|
end
|
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment