You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# make test2
cc -o parser2 -g expr2.c interp.c main.c scan.c tree.c
(./parser2 input01; \
./parser2 input02; \
./parser2 input03; \
./parser2 input04; \
./parser2 input05)
15
29
syntax error on line 1, token 1
Unrecognised character . on line 3
Unrecognised character a on line 1
Unrecognised character . on line 3 # input04 result
Unrecognised character a on line 1 # input05 result
$ make test2
(./parser2 input01; \
./parser2 input02; \
./parser2 input03; \
./parser2 input04; \
./parser2 input05)
15 # input01 result
29 # input02 result
syntax error on line 1, token 5 # input03 result
Unrecognised character . on line 3 # input04 result
Unrecognised character a on line 1 # input05 result
The parser2's result on input03 is with a wrong token type, it should be 5, not 1. The following is the content of input03
12 34 + -56 * / - - 8 + * 2
Now the parse2 reports error on token + whose enum value equals 1. It should reports on 34 instead, with enum value 5, because the position of which shoude be an operator.
On the preceding code, the operator is checked after parsing the right sub tree. I think the check action should be done first with this code to get a right result.
// Loop working on token at our level of precedence while (1) {
// Check if the middle position is an operatorintprecedence=arithop(tokentype);
// Fetch in the next integer literal scan(&Token);
// Get the right sub-tree at a higher precedence than us right=multiplicative_expr();
// Join the two sub-trees with our low-precedence operator left=mkastnode(precedence, left, right, 0);
The text was updated successfully, but these errors were encountered:
What I got
And what is in Readme
acwj/03_Precedence/Readme.md
Lines 392 to 414 in 14e9397
The parser2's result on input03 is with a wrong token type, it should be 5, not 1. The following is the content of input03
Now the parse2 reports error on token
+
whose enum value equals 1. It should reports on34
instead, with enum value 5, because the position of which shoude be an operator.acwj/03_Precedence/expr2.c
Lines 96 to 105 in eabf90e
On the preceding code, the operator is checked after parsing the right sub tree. I think the check action should be done first with this code to get a right result.
The text was updated successfully, but these errors were encountered: