diff options
| author | Jack Palevich <jackpal@google.com> | 2009-07-31 14:01:37 -0700 |
|---|---|---|
| committer | Jack Palevich <jackpal@google.com> | 2009-07-31 14:01:37 -0700 |
| commit | 43aaee31b9cedc059213396f1e7aa420ace0c797 (patch) | |
| tree | 9ead26ed3294192dfe5dfd3ad91f1044cef44743 /libacc/acc.cpp | |
| parent | 0c01774816245e59aac7f2109c28523eeb6492ac (diff) | |
| download | system_core-43aaee31b9cedc059213396f1e7aa420ace0c797.tar.gz system_core-43aaee31b9cedc059213396f1e7aa420ace0c797.tar.bz2 system_core-43aaee31b9cedc059213396f1e7aa420ace0c797.zip | |
Support the comma operator.
Diffstat (limited to 'libacc/acc.cpp')
| -rw-r--r-- | libacc/acc.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/libacc/acc.cpp b/libacc/acc.cpp index 823849c7..da703a70 100644 --- a/libacc/acc.cpp +++ b/libacc/acc.cpp @@ -3868,7 +3868,7 @@ class Compiler : public ErrorSink { pGen->forceR0RVal(); pGen->convertR0(pCast); } else { - expr(); + commaExpr(); skip(')'); } } else if (t == '*') { @@ -4076,12 +4076,21 @@ class Compiler : public ErrorSink { } } + void commaExpr() { + for(;;) { + expr(); + if (!accept(',')) { + break; + } + } + } + void expr() { binaryOp(11); } int test_expr() { - expr(); + commaExpr(); pGen->forceR0RVal(); return pGen->gtst(0, 0); } @@ -4117,7 +4126,7 @@ class Compiler : public ErrorSink { a = test_expr(); } else { if (tok != ';') - expr(); + commaExpr(); skip(';'); n = codeBuf.getPC(); a = 0; @@ -4126,7 +4135,7 @@ class Compiler : public ErrorSink { skip(';'); if (tok != ')') { t = pGen->gjmp(0); - expr(); + commaExpr(); pGen->gjmp(n - codeBuf.getPC() - pGen->jumpOffset()); pGen->gsym(t); n = t + 4; @@ -4150,7 +4159,7 @@ class Compiler : public ErrorSink { } else { if (accept(TOK_RETURN)) { if (tok != ';') { - expr(); + commaExpr(); pGen->forceR0RVal(); if (pReturnType->tag == TY_VOID) { error("Must not return a value from a void function"); @@ -4166,7 +4175,7 @@ class Compiler : public ErrorSink { } else if (accept(TOK_BREAK)) { *(int *) l = pGen->gjmp(*(int *) l); } else if (tok != ';') - expr(); + commaExpr(); skip(';'); } } |
