private static Parser <SyntaxToken, JassGlobalDeclarationSyntax> GetGlobalDeclarationParser() { return(Keyword(SyntaxTokenType.ConstantKeyword).Then(Map((type, id, value) => (IVariableDeclarator) new JassVariableDeclaratorSyntax(type, id, value), TypeParser, IdentifierNameParser, EqualsValueClauseParser)) .Or(VariableDeclaratorParser) .Before(Newline.AtLeastOnce()) .Select(declarator => new JassGlobalDeclarationSyntax(declarator))); }
private static Parser <SyntaxToken, IDeclaration> GetDeclarationParser() { return(OneOf( TypeDeclarationParser, GlobalDeclarationListParser, NativeFunctionDeclarationParser) .Before(Newline.AtLeastOnce())); }
private static Parser <SyntaxToken, IDeclaration> GetGlobalDeclarationListParser() { return(Keyword(SyntaxTokenType.GlobalsKeyword).Then(Newline.AtLeastOnce()).Then(GlobalDeclarationParser.Many()).Before(Keyword(SyntaxTokenType.EndglobalsKeyword)) .Select <IDeclaration>(globals => new JassGlobalDeclarationListSyntax(globals.ToImmutableArray()))); }