Esempio n. 1
0
        public static FunctionParameterNode Parse(ParseContext context)
        {
            // todo: support "ref"

            var id = context.ParseExpression <IdentifierNode>();

            context.Expect(TokenType.Colon);
            var type = TypeIdentifierNode.Parse(context);

            return(new FunctionParameterNode(id.Source, id, type));
        }
        public ASTNode Parse(Token sourceToken, ParseContext context)
        {
            var id = context.ParseExpression <IdentifierNode>();

            context.Expect(TokenType.Colon);
            var type = TypeIdentifierNode.Parse(context);

            context.Expect(TokenType.Equals);
            ASTNode assignment = context.ParseExpression();

            return(new ConstDeclarationNode(sourceToken, id, type, assignment));
        }
Esempio n. 3
0
        public ASTNode Parse(Token sourceToken, ParseContext context)
        {
            context.Expect(TokenType.OpenAngleBracket);
            TypeIdentifierNode toType = TypeIdentifierNode.Parse(context);

            context.Expect(TokenType.CloseAngleBracket);

            context.Expect(TokenType.OpenParenthesis);
            ASTNode castExpr = context.ParseExpression();

            context.Expect(TokenType.CloseParenthesis);

            return(new CastNode(sourceToken, toType, castExpr));
        }