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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
%% Writing to html file the stream of tokens
tohtmlfile(_, []):- !.
tohtmlfile(Stream, [H|T]) :- is_identifier(H), H = [_,Lexem],
write(Stream, '<span class=\"identifier\">'),
write(Stream, Lexem),
write(Stream,'</span>'),
!,
tohtmlfile(Stream, T).
tohtmlfile(Stream, [H|T]) :- is_string(H), H = [_,Lexem],
write(Stream, '<span class=\"string\">'),
write(Stream, Lexem),
write(Stream,'</span>'),
!,
tohtmlfile(Stream, T).
tohtmlfile(Stream, [H|T]) :- is_function(H), H = [_, Lexem],
write(Stream, '<span class=\"function\">'),
write(Stream, Lexem),
write(Stream,'</span>'),
!,
tohtmlfile(Stream, T).
tohtmlfile(Stream, [H|T]) :- is_header(H), H = [_,Lexem],
write(Stream, '<span class=\"string\"><'),
write(Stream, Lexem),
write(Stream,'></span>'),
!,
tohtmlfile(Stream, T).
tohtmlfile(Stream, [H|T]) :- is_keyWord(H), H = [_,Lexem],
write(Stream, '<span class=\"keyword\">'),
write(Stream, Lexem),
write(Stream,'</span>'),
!,
tohtmlfile(Stream, T).
tohtmlfile(Stream, [H|T]) :- is_number(H), H = [_,Lexem],
write(Stream, '<span class=\"number\">'),
write(Stream, Lexem),
write(Stream,'</span>'),
!,
tohtmlfile(Stream, T).
tohtmlfile(Stream, [H|T]) :- is_operator(H), H = [_,Lexem],
write(Stream, '<span class=\"operator\">'),
write(Stream, Lexem),
write(Stream,'</span>'),
!,
tohtmlfile(Stream, T).
tohtmlfile(Stream, [H|T]) :- is_parenth(H), H = [_,Lexem],
write(Stream, '<span class=\"parenthese\">'),
write(Stream, Lexem),
write(Stream,'</span>'),
!,
tohtmlfile(Stream, T).
tohtmlfile(Stream, [H|T]) :- is_quotation(H), H = [_,Lexem],
write(Stream, '<span class=\"quotation\">'),
write(Stream, Lexem),
write(Stream,'</span>'),
!,
tohtmlfile(Stream, T).
tohtmlfile(Stream, [H|T]) :- is_unknown(H), H = [_,Lexem],
write(Stream, '<span class=\"unknown\">'),
write(Stream, Lexem),
write(Stream,'</span>'),
!,
tohtmlfile(Stream, T).
tohtmlfile(Stream, [H|T]) :- is_comment(H), H = [_,Lexem],
write(Stream, '<span class=\"comment\">'),
write(Stream, Lexem),
write(Stream,'</span>'),
!,
tohtmlfile(Stream, T).
tohtmlfile(Stream, [H|T]) :- is_controlStructureBody(H),
write(Stream, '<button class=\"collapsible\">'),
H = [H1|T1],
tohtmlfile(Stream, H1),
write(Stream, '</span></button>'), nl(Stream),
write(Stream, '<div class=\"content\">'),
helper(Stream, T1),
write(Stream,'</div>'),
!,
tohtmlfile(Stream, T).
tohtmlfile(Stream, [H|T]) :- is_blank(H), H = [_,Lexem],
write(Stream, Lexem),
!,
tohtmlfile(Stream, T).
helper(_, []).
helper(Stream, L):- append(A, [H|B], L), is_controlStructureBody(H),
helper(Stream,A), tohtmlfile(Stream, [H]), helper(Stream,B).
helper(Stream, [H|T]):- tohtmlfile(Stream, H), helper(Stream, T).
|