Add minus

This commit is contained in:
Diogo Cordeiro 2018-12-20 01:10:35 +00:00
parent d9d835b00d
commit 957e484db5

View File

@ -298,10 +298,20 @@ parse_number_explicit(void, void, T, [WN | In], NC) :-
member(P, [f, g, fy]),
!,
parse_number_explicit(P, N, T, In, NC).
parse_number_explicit(fy, NL, T, [WN | In], NC) :-
special_word_number(WN, N, f),
!,
parse_number_explicit(f, op(-, NL, N), T, In, NC).
parse_number_explicit(fy, NL, T, [WN | In], NC) :-
special_word_number(WN, N, f),
!,
parse_number_explicit(f, op(+, NL, N), T, In, NC).
parse_number_explicit(xfy, TL, T, [WN | In], NC) :-
TL \= void,
special_word_number(WN, N, P),
member(P, [f, g, fy]),
!,
parse_number_explicit(P, op(-, TL, N), T, In, NC).
parse_number_explicit(xfy, TL, T, [WN | In], NC) :-
TL \= void,
special_word_number(WN, N, P),
@ -400,6 +410,7 @@ parse_power(TB) -->
parse_polynomial_variable(TB).
parse_operation(-) --> [minus].
parse_operation(+) --> [plus].
parse_operation(*) --> [times].
@ -473,6 +484,11 @@ parse_polynomial_explicit(void-_, T) -->
parse_operation(Op),
!,
parse_polynomial_explicit(op(Op, TL, TRP)-TRP, T).
parse_polynomial_explicit(TLP-TL, T) -->
parse_polynomial_operand(TL),
parse_operation(-),
!,
parse_polynomial_explicit(op(-, TLP, TRP)-TRP, T).
parse_polynomial_explicit(TLP-TL, T) -->
parse_polynomial_operand(TL),
parse_operation(+),
@ -539,6 +555,12 @@ parse_command(multiply(TN, TP)) -->
parse_number(TN),
[by],
parse_polynomial(TP).
parse_command(op(-, TN, TP)) -->
[sub],
parse_polynomial(TN),
[X],
{ member(X, [to, with]) },
parse_polynomial(TP).
parse_command(op(+, TN, TP)) -->
[add],
parse_polynomial(TN),