Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81281 / c2html / controlStructures.pl
diff options
context:
space:
mode:
Commitaeb0d4f887a0c18c36b59acc7b5df08e62020c50 (patch)
Author
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2020-10-11 21:32:48 +0300
Committer
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2020-10-11 21:33:38 +0300
Filesb6abdc6e1810326b587f2a160f39570f1f568f27 /homework/81281/c2html/controlStructures.pl
IPL-aeb0d4f887a0c18c36b59acc7b5df08e62020c50.tar
IPL-aeb0d4f887a0c18c36b59acc7b5df08e62020c50.tar.gz
IPL-aeb0d4f887a0c18c36b59acc7b5df08e62020c50.zip
Parent154b7cd30f21af1554ca26986ff1643e28857727 (diff)
Removed old homeworks
1 files changed, 0 insertions, 56 deletions
-rw-r--r--homework/81281/c2html/controlStructures.pl56
diff --git a/homework/81281/c2html/controlStructures.pl b/homework/81281/c2html/controlStructures.pl
deleted file mode 100644
index 026c216..0000000
--- a/homework/81281/c2html/controlStructures.pl
+++ /dev/null
@@ -1,56 +0,0 @@
-:- [essentials, tokens].
-identifyControlStructures([], []):- !.
-identifyControlStructures([H|T], [NewH|R]):-
- \+ append(_, [[ttypedef|_]|_], H),
- append(_, [[Token|_]|_], H),
- member(Token, [tdo, tfor, twhile, tif, telse, tswitch, tfunction, tstruct]),
- T = [T1|T2],
- append(T11, [[tleftBrace, "{"], [execNL, "\n"]], T1),
- \+ ((member(M, T11), M \= [execTAB, "\s\s\s\s"])),
- gatherBody(T2, [], PackedStructBody, Rest, 1),
- identifyControlStructures(PackedStructBody, Result),
- append([H, T1], Result, NewH), !,
- identifyControlStructures(Rest, R).
-identifyControlStructures([H|T], [NewH|R]):-
- \+ append(_, [[ttypedef|_]|_], H),
- append(_, [[Token|_]|_], H),
- member(Token, [tfor, twhile, tif, telse]),
- T = [T1|_],
- \+ append(_, [[tleftBrace, "{"], [execNL, "\n"]], T1),
- getPrefixTabsLength(H, N),
- getPrefixTabsLength(T1, M),
- N + 1 =:= M,
- gatherOneLineBody(T, [], PackedOneLineBody, Rest, N),
- identifyControlStructures(PackedOneLineBody, Result),
- append([H], Result, NewH), !,
- identifyControlStructures(Rest, R).
-identifyControlStructures([H|T], [H|R]):- !,
- identifyControlStructures(T, R).
-
-
-gatherOneLineBody([], Res, Res, [], _):- !.
-gatherOneLineBody([H|T], Res, Res, [H|T], N):-
- getPrefixTabsLength(H, M),
- N + 1 =\= M, !.
-gatherOneLineBody([H|T], Buff, Res, Rest, N):-
- getPrefixTabsLength(H, M),
- N + 1 =:= M,
- append(Buff, [H], NewBuff), !,
- gatherOneLineBody(T, NewBuff, Res, Rest, M).
-
-
-gatherBody(Rest, Res, Res, Rest, 0):- !.
-gatherBody([H|T], Buff, Res, Rest, N):-
- N =\= 0, append(H1, [[tleftBrace, "{"]|_], H),
- \+ ((member(M, H1), M \= [execTAB, "\s\s\s\s"])),
- append(Buff, [H], NewBuff), N1 is N + 1, !,
- gatherBody(T, NewBuff, Res, Rest, N1).
-gatherBody([H|T], Buff, Res, Rest, N):-
- N =\= 0, append(H1, [[trightBrace, "}"]|_], H),
- \+ ((member(M, H1), M \= [execTAB, "\s\s\s\s"])),
- append(Buff, [H], NewBuff), N1 is N - 1, !,
- gatherBody(T, NewBuff, Res, Rest, N1).
-gatherBody([H|T], Buff, Res, Rest, N):-
- N =\= 0,
- append(Buff, [H], NewBuff), !,
- gatherBody(T, NewBuff, Res, Rest, N).