private static Parser <SyntaxToken, IExpressionSyntax> GetArrayReferenceExpressionParser(Parser <SyntaxToken, IExpressionSyntax> expressionParser) { return(Try(IdentifierNameParser .Before(Token(SyntaxTokenType.SquareBracketOpenSymbol))) .Then(expressionParser, (id, indexer) => (IExpressionSyntax) new JassArrayReferenceExpressionSyntax(id, indexer)) .Before(Token(SyntaxTokenType.SquareBracketCloseSymbol)) .Labelled("array reference")); }
private static Parser <char, IExpressionSyntax> GetArrayReferenceExpressionParser(Parser <char, IExpressionSyntax> expressionParser) { return(Try(IdentifierNameParser .Before(Char('[').SkipWhitespaces())) .Then(expressionParser, (id, indexer) => (IExpressionSyntax) new JassArrayReferenceExpressionSyntax(id, indexer)) .Before(Char(']').SkipWhitespaces()) .Labelled("array reference")); }
private static Parser <char, JassFunctionDeclarationSyntax> GetFunctionDeclarationParser() { return(Map( (id, parameterList, returnType) => new JassFunctionDeclarationSyntax(id, parameterList, returnType), IdentifierNameParser.Before(Keyword("takes")), Keyword("nothing").ThenReturn(JassParameterListSyntax.Empty).Or(ParameterListParser), Keyword("returns").Then(Keyword("nothing", JassTypeSyntax.Nothing).Or(TypeParser))) .Labelled("function declaration")); }
private static Parser <SyntaxToken, IExpressionSyntax> GetInvocationExpressionParser(Parser <SyntaxToken, IExpressionSyntax> expressionParser) { return(Try(IdentifierNameParser.Before(Token(SyntaxTokenType.ParenthesisOpenSymbol))) .Then(GetArgumentListParser(expressionParser).Before(Token(SyntaxTokenType.ParenthesisCloseSymbol)), (id, arguments) => (IExpressionSyntax) new JassInvocationExpressionSyntax(id, arguments)) .Labelled("invocation expression")); }
private static Parser <char, IExpressionSyntax> GetInvocationExpressionParser(Parser <char, IExpressionSyntax> expressionParser) { return(Try(IdentifierNameParser.Before(Char('(').SkipWhitespaces())) .Then(GetArgumentListParser(expressionParser).Before(Char(')')), (id, arguments) => (IExpressionSyntax) new JassInvocationExpressionSyntax(id, arguments)) .Labelled("invocation expression")); }