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
The advice given in the textbook (4th ed.) on page 786 is:
Supporting pointers is no more difficult than supporting any other data type. However, you will need to add support for the pointer operators to the expression parser.
Hello. Thanks for answering.
I think that in parser.c you need to add or modify a production rule, taking into account the precedence of the * and & pointer operators
Page 58 C The Complete Reference 4th Edition
Precedence Summary
Table 2-8 lists the precedence of all operators defined by C. Note that all operators, except the unary operators and ?, associate from left to right. The unary operators (*, &, –) and ? associate from right
to left.
Expressions
Operators, constants, functions, and variables are the constituents of expressions. An expression in C is any valid combination of these elements. Because most expressions tend to follow the general
rules of algebra, they are often taken for granted. However, a few aspects of expressions relate specifically to C.
–
<< >>
< <= > >=
== !=
&
^
|
&&
| |
?:
= += –= *= /= etc.
Lowest,
Table 2 -8. Precedence of C Operators
I believe that as seen in the Operator Precedence table, the * operator and the & operator have the same level of precedence as the NOT (!) and unary minus (-) operator.
I have added support to Littlec for NOT(!) , AND(&&), OR(||).
I think support for the *, & pointer operators could be done in the same evalexp() as support for NOT(!) and unary minus (-)
Hello: Do you know how to add pointer support in LittleC?
Thanks in advance,
paco
The text was updated successfully, but these errors were encountered: