scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 8b93ef36c624455eff29470aa7c416f8450f7a5a
parent 7b66933103d3d4930735aec4dd0d739d0efe78e4
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 11 Jul 2014 12:23:59 +0200

Add parser for function calls

It is only a parser that accepts any call to function, without
any kind of semantic action and without generating any code. It is
a good point to begin.

Diffstat:
Mcc1/expr.c | 27+++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/cc1/expr.c b/cc1/expr.c @@ -437,6 +437,27 @@ primary(void) return np; } +static Node *assign(void); + +static Node * +arguments(Node *np) +{ + Node *par; + + /* TODO: Check type of np */ + expect('('); + if (accept(')')) + return np; + + do { + if ((par = eval(assign())) == NULL) + unexpected(); + } while (accept(',')); + + expect(')'); + return np; +} + static Node * postfix(void) { @@ -452,7 +473,7 @@ postfix(void) expect(']'); break; case DEC: case INC: - np1 = incdec(np1, (yytoken == INC) ? OINC : ODEC); + np1 = incdec(np1, (yytoken == INC) ? OINC : ODEC); next(); break; case INDIR: @@ -461,7 +482,9 @@ postfix(void) next(); np1 = field(np1); break; - /* TODO: case '(' */ + case '(': + np1 = arguments(np1); + break; default: return np1; }