X-Git-Url: https://git.njae.me.uk/?p=lisp-interpreter-in-prolog.git;a=blobdiff_plain;f=lisp-interpreter.pl;h=a036a73bede0836a9d830a1ec52fa059e63e21b5;hp=2be75cd2bf0129771adf7cbae684d0d8f036d5c2;hb=HEAD;hpb=5b949b632cd9db496f8798c67f9a939f41e34d2e diff --git a/lisp-interpreter.pl b/lisp-interpreter.pl index 2be75cd..a036a73 100644 --- a/lisp-interpreter.pl +++ b/lisp-interpreter.pl @@ -22,7 +22,8 @@ *******************************************************************/ -:- style_check. +:- style_check([+singleton, +no_effect, +var_branches, +atom, +discontiguous, + +charset]). :- dynamic bindings/1, @@ -38,14 +39,15 @@ lisp:- write('Welcome to Pro-Lisp!'),nl, write('This is a miniscule Lisp interpreter, written in Prolog'),nl, prompt(Old, '> '), - prompts(Old1, Old2), - prompts('> ', '> '), + % prompts(Old1, Old2), + % prompts('> ', '> '), tidy_database, repeat, read_eval_print(Result), Result = quit, prompt(_, Old), - prompts(Old1, Old2). + % prompts(Old1, Old2). + true. tidy_database:- @@ -212,7 +214,8 @@ read_and_parse(Expression):- % read a line of supposed Lisp code read_words(Words):- - get0(C), + % get0(C), + get_code(C), read_words(C, Words). read_words(C, []):- @@ -232,14 +235,15 @@ read_words(C, [Word|Words]):- !, read_rest_of_word(Chars, LeftOver), name(UCWord, [C|Chars]), - ( atom(UCWord) -> lwrupr(Word, UCWord) + ( atom(UCWord) -> downcase_atom(UCWord, Word) ; Word = UCWord), read_words(LeftOver, Words). read_rest_of_word(Chars, LeftOver):- - get0(C), + % get0(C), + get_code(C), read_rest_of_word(C, Chars, LeftOver). @@ -321,8 +325,10 @@ writeTokenL(['(', ')'|TokenL]):- writeTokenL([Token|TokenL]):- atom(Token), !, - lwrupr(Token, UCToken), - write(UCToken), + % lwrupr(Token, UCToken), + % write(UCToken), + downcase_atom(Token, LCToken), + write(LCToken), write(' '), writeTokenL(TokenL). writeTokenL([Token|TokenL]):-