Ejemplo 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));
        }
Ejemplo n.º 2
0
        public static PapyrusSymbol GetReferencedTypeSymbol(this TypeIdentifierNode node)
        {
            var type = node.GetReferencedType();

            if (type is ArrayType complexType)
            {
                type = node.GetTypeChecker().GetTypeForObjectId(complexType.ElementType);
            }

            return((type as ComplexType)?.Symbol);
        }
        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));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
 public VarDeclarationNode(Token sourceToken, IdentifierNode identifier, TypeIdentifierNode type, ASTNode assignment) : base(sourceToken)
 {
     Identifier = identifier;
     Type       = type;
     Assignment = assignment;
 }
Ejemplo n.º 6
0
 public FunctionParameterNode(Token sourceToken, IdentifierNode identifier, TypeIdentifierNode type) : base(sourceToken)
 {
     Identifier = identifier;
     Type       = type;
 }
Ejemplo n.º 7
0
 public CastNode(Token sourceToken, TypeIdentifierNode toType, ASTNode inner)
     : base(sourceToken)
 {
     ToType = toType;
     Inner  = inner;
 }