void Primary(Scope scope, out IExpression expr) { IType type = new UnknownType(); string name = ""; expr = null; IExpression rhs; if (la.kind == 1) { Get(); name = t.val; if (la.kind == 7 || la.kind == 8) { if (la.kind == 7) { Get(); TypeIdentifier(scope, out type); VariableDeclaration vd = new VariableDeclaration(name, type); MultiVariableDeclaration parmDecl = new MultiVariableDeclaration(new List<VariableDeclaration>(new VariableDeclaration[] {vd}), null); FunctionReturnDefinition(scope, out expr, parmDecl); } else { VariableDeclaration vd = new VariableDeclaration(name, type); MultiVariableDeclaration parmDecl = new MultiVariableDeclaration(new List<VariableDeclaration>(new VariableDeclaration[] {vd}), null); FunctionReturnDefinition(scope, out expr, parmDecl); } } if (StartOf(1)) { expr = expr ?? (IExpression)scope.GetDeclarationFor(name); Expression(scope, out rhs); expr = new FunctionCall(expr, rhs); } expr = expr ?? (IExpression)scope.GetDeclarationFor(name); } else if (la.kind == 13) { Get(); VarList vl = new VarList(); if (la.kind == 1 || la.kind == 3 || la.kind == 10) { StillPrimary(scope, out expr, vl); } else if (la.kind == 14) { Get(); } else SynErr(27); } else SynErr(28); }
void StillPrimary(Scope scope, out IExpression expr, VarList vl) { IType type = new UnknownType(); string name = ""; expr = null; IExpression rhs; if (la.kind == 1) { Get(); name = t.val; if (la.kind == 14) { Get(); if (la.kind == 8) { VariableDeclaration newestParam = new VariableDeclaration(name, type); vl.Add(newestParam); MultiVariableDeclaration parmDecl = new MultiVariableDeclaration(vl, null); FunctionReturnDefinition(scope, out expr, parmDecl); } if (StartOf(1)) { expr = expr ?? (IExpression)scope.GetDeclarationFor(name); Expression(scope, out rhs); expr = new FunctionCall(expr, rhs); } expr = expr ?? (IExpression)scope.GetDeclarationFor(name); } else if (la.kind == 7) { Get(); TypeIdentifier(scope, out type); VariableDeclaration newestParam = new VariableDeclaration(name, type); vl.Add(newestParam); MultiVariableDeclaration parmDecl = new MultiVariableDeclaration(vl, null); if (la.kind == 8) { FunctionReturnDefinition(scope, out expr, parmDecl); if (la.kind == 14) { Get(); if (StartOf(1)) { Expression(scope, out rhs); expr = new FunctionCall(expr, rhs); } } else if (StartOf(1)) { Expression(scope, out rhs); expr = new FunctionCall(expr, rhs); if (la.kind == 14) { Get(); } else if (la.kind == 11) { ExpressionList el = new ExpressionList(); expr = expr ?? (IExpression)scope.GetDeclarationFor(name); el.Add(expr); Get(); Secondary(scope, el, out expr); } else SynErr(29); } else if (la.kind == 11) { ExpressionList el = new ExpressionList(); expr = expr ?? (IExpression)scope.GetDeclarationFor(name); el.Add(expr); Get(); Secondary(scope, el, out expr); } else SynErr(30); } else if (la.kind == 14) { Get(); FunctionReturnDefinition(scope, out expr, parmDecl); if (StartOf(1)) { Expression(scope, out rhs); expr = new FunctionCall(expr, rhs); } if (la.kind == 11) { ExpressionList el = new ExpressionList(); expr = expr ?? (IExpression)scope.GetDeclarationFor(name); el.Add(expr); Get(); Secondary(scope, el, out expr); } } else if (la.kind == 11) { VariableDeclaration vd; NextNomination(ref scope, out vd); FunctionReturnDefinition(scope, out expr, parmDecl); if (StartOf(1)) { Expression(scope, out rhs); expr = new FunctionCall(expr, rhs); } } else SynErr(31); } else if (la.kind == 11) { Get(); vl.Add(new VariableDeclaration(name, type)); StillPrimary(scope, out expr, vl); } else if (la.kind == 8) { VariableDeclaration newestParam = new VariableDeclaration(name, type); vl.Add(newestParam); MultiVariableDeclaration parmDecl = new MultiVariableDeclaration(vl, null); FunctionReturnDefinition(scope, out expr, parmDecl); if (la.kind == 14) { Get(); Expression(scope, out rhs); expr = new FunctionCall(expr, rhs); } else if (StartOf(3)) { if (la.kind == 11) { Get(); } ExpressionList el = new ExpressionList(); expr = expr ?? (IExpression)scope.GetDeclarationFor(name); el.Add(expr); Secondary(scope, el, out expr); } else SynErr(32); } else SynErr(33); } else if (la.kind == 3 || la.kind == 10) { if (la.kind == 3) { IntegerLiteral(scope, out expr); } else { ArrayLiteral(scope, out expr); } ExpressionList el = new ExpressionList(); expr = expr ?? (IExpression)scope.GetDeclarationFor(name); el.Add(expr); if (la.kind == 11) { Get(); Secondary(scope, el, out expr); } } else SynErr(34); }
public IExpression Bind(Scope scope) { return (IExpression)scope.GetDeclarationFor(Name); }