summaryrefslogtreecommitdiff
path: root/sys/src/cmd/cpp/eval.c
AgeCommit message (Collapse)Author
2020-04-19Make priority array max size explicit.Ori Bernstein
we were implicitly depending on UMINUS being the last entry in the operator table -- that's fragile.
2020-04-19fix cpp operator associativityOri Bernstein
We used to treat all operators as right associative, which means that we would evaluate them incorrecty. For example, '2 - 1 + 1' would evaluate as '2 - (1 + 2)', instead of '(2 - 1) + 1'. This adds an assoc parameter to struct pri, and then uses it to decide how to evaluate operators.
2020-04-19dont overflow the stackOri Bernstein
when pushing expressions in cpp, particularly complex ones could overflow the stack and silently corrupt our data structures. add checks when we push, and bump the stack size up.
2020-03-23evaluate #if expressions using vlongOri Bernstein
#if expressions are expected to be evaluated using intmax_t, according to the C99 spec, 6.10.1 p3. On plan9, intmax_t maps to vlong.
2020-03-17Improve the posix preprocessor.Ori Bernstein
This fixes token pasting, making it expand when it should expand, and paste before expansion when it should paste before expanding. #define CAT(a, b) a ## b #define BAR 3 #define FOO CAT(BAR, 3) FOO now produces 33, while #define CAT(a, b) a ## b #define EOF (-1) #define NOP(x) x NOP(CAT(foo, EOF)) CAT(,EOF) CAT(,) produces fooEOF (-1) <empty> respectively.
2011-03-30Import sources from 2011-03-30 iso image - libTaru Karttunen
2011-03-30Import sources from 2011-03-30 iso imageTaru Karttunen