diff --git a/thun/thun.pl b/thun/thun.pl index 9c2503d..11d4316 100644 --- a/thun/thun.pl +++ b/thun/thun.pl @@ -41,13 +41,20 @@ joy_parse([]) --> []. joy_term(N) --> number(N), !. joy_term(J) --> "[", !, joy_parse(J), "]". -joy_term(C) --> chars(Chars), !, {atom_string(C, Chars)}. +joy_term(C) --> symbol(C). + +symbol(C) --> chars(Chars), !, {Chars \= [61, 61], atom_string(C, Chars)}. chars([Ch|Rest]) --> char(Ch), chars(Rest). chars([Ch]) --> char(Ch). char(Ch) --> [Ch], {Ch \== 91, Ch \== 93, code_type(Ch, graph)}. +joy_def(Def ≡ Body) --> symbol(Def), blanks, "==", joy_parse(Body). + +joy_defs([Def|Defs]) --> blanks, joy_def(Def), blanks, joy_defs(Defs). +joy_defs([]) --> []. + /* Interpreter thun(Expression, InputStack, OutputStack)