private static SyntaxNode Index(RParser.IndexContext index, Func<ParserRuleContext, Scope, SyntaxNode> transform, Scope scope) { var indexExprs = index.sublist().sub(); if (indexExprs.Length != 1) { //td: error return null; } var expr = transform(index.expr(), scope) as ExpressionSyntax; var args = transform(index.sublist(), scope) as ArgumentListSyntax; Debug.Assert(expr != null && args != null); var indexExpr = args.Arguments[0].Expression; Debug.Assert(indexExpr != null); return indexCall.Get(expr, indexExpr); }
private static SyntaxNode FunctionCall(RParser.FunctionCallContext call, Func<ParserRuleContext, Scope, SyntaxNode> transform, Scope scope) { var expr = transform(call.expr(), scope) as ExpressionSyntax; var args = transform(call.sublist(), scope) as ArgumentListSyntax; Debug.Assert(expr != null && args != null); if (expr is IdentifierNameSyntax) return createInvocation(expr.ToString(), args); throw new NotImplementedException(); }