shithub: scc

Download patch

ref: 8b93ef36c624455eff29470aa7c416f8450f7a5a
parent: 7b66933103d3d4930735aec4dd0d739d0efe78e4
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Jul 11 08:23:59 EDT 2014

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.

--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -437,7 +437,28 @@
 	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)
 {
 	register Node *np1, *np2;
@@ -452,7 +473,7 @@
 			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 @@
 			next();
 			np1 = field(np1);
 			break;
-		/* TODO: case '(' */
+		case '(':
+			np1 = arguments(np1);
+			break;
 		default:
 			return np1;
 		}