Beispiel #1
0
 internal static void checkDeclComment(Symbol s)
 {
     /*if( comments != null ) {
      *      int last_offset = ((DocCommentNode)comments.nodes[comments.nodes.Count-1]).end.offset;
      *      if( this.text.Substring( last_offset, s.pos.offset - last_offset ).Trim().Length != 0 )
      *              comments = null;
      * }*/
 }
Beispiel #2
0
        internal static ExprNode Expr(Kind k, Symbol s)
        {
            ExprNode res = new ExprNode();

            res.kind  = k;
            res.start = s.pos;
            res.end   = s.endpos;
            return(res);
        }
Beispiel #3
0
        internal static PointerType PointerType(TypeNode parent, Symbol s)
        {
            PointerType res = new PointerType();

            res.kind   = Kind.PointerType;
            res.start  = s.pos;
            res.end    = s.endpos;
            res.parent = parent;
            return(res);
        }
Beispiel #4
0
        internal static TypeName TypeName(IdentNode typename, Symbol s)
        {
            TypeName res = new TypeName();

            res.kind     = Kind.TypeName;
            res.start    = s.pos;
            res.end      = s.endpos;
            res.typename = typename;
            return(res);
        }
Beispiel #5
0
        internal static BaseType BaseType(BaseTypes typeid, Symbol s)
        {
            BaseType res = new BaseType();

            res.kind   = Kind.BaseType;
            res.start  = s.pos;
            res.end    = s.endpos;
            res.typeid = typeid;
            return(res);
        }
Beispiel #6
0
        internal static DimSpecNode DimSpec(int count, Symbol s)
        {
            DimSpecNode res = new DimSpecNode();

            res.kind  = Kind.DimSpecifier;
            res.start = s.pos;
            res.end   = s.endpos;
            res.count = count;
            return(res);
        }
Beispiel #7
0
        internal static IdentNode Ident(string identifier, Symbol s)
        {
            IdentNode res = new IdentNode();

            res.kind       = Kind.Identifier;
            res.start      = s.pos;
            res.end        = s.endpos;
            res.identifier = identifier;
            return(res);
        }
Beispiel #8
0
        internal static void Pos(ref Symbol s)
        {
            Node n = s.sym as Node;

            if (n != null)
            {
                n.start = s.pos;
                n.end   = s.endpos;
            }
        }
Beispiel #9
0
        internal static UnaryNode Unary(Kind k, ExprNode expr, Symbol s)
        {
            UnaryNode res = new UnaryNode();

            res.kind  = k;
            res.start = s.pos;
            res.end   = s.endpos;
            res.expr  = expr;
            return(res);
        }
Beispiel #10
0
        internal static ArrayType ListArrayType(TypeNode parent, ListNode dims, Symbol s)
        {
            TypeNode current = parent;

            foreach (DimSpecNode n in dims.nodes)
            {
                current = OneArrayType(current, n, s);
            }
            return((ArrayType)current);
        }
Beispiel #11
0
        internal static ConstantNode Constant(IdentNode name, ExprNode constant, Symbol s)
        {
            ConstantNode res = new ConstantNode();

            res.kind     = Kind.Constant;
            res.start    = s.pos;
            res.end      = s.endpos;
            res.name     = name;
            res.constant = constant;
            return(res);
        }
Beispiel #12
0
        internal static VariableNode Variable(IdentNode name, InitializerNode init, Symbol s)
        {
            VariableNode res = new VariableNode();

            res.kind  = Kind.Variable;
            res.start = s.pos;
            res.end   = s.endpos;
            res.name  = name;
            res.init  = init;
            return(res);
        }
Beispiel #13
0
        // {{Methods}}

        internal static ListNode List(Node first, Symbol s)
        {
            ListNode res = new ListNode();

            res.kind  = Kind.List;
            res.start = s.pos;
            res.end   = s.endpos;
            res.nodes = new ArrayList();
            res.nodes.Add(first);
            return(res);
        }
Beispiel #14
0
        internal static TypeExprNode TypeExpr(ExprNode expr, DimSpecNode spec, Symbol s)
        {
            TypeExprNode res = new TypeExprNode();

            res.kind  = Kind.DimmedExpr;
            res.start = s.pos;
            res.end   = s.endpos;
            res.expr  = expr;
            res.spec  = spec;
            return(res);
        }
Beispiel #15
0
        internal static AssignNode Assign(Kind k, ExprNode dest, ExprNode source, Symbol s)
        {
            AssignNode res = new AssignNode();

            res.kind   = k;
            res.start  = s.pos;
            res.end    = s.endpos;
            res.dest   = dest;
            res.source = source;
            return(res);
        }
Beispiel #16
0
        internal static LiteralNode Literal(LiteralNode.Type type, object value, Symbol s)
        {
            LiteralNode res = new LiteralNode();

            res.kind  = Kind.Literal;
            res.start = s.pos;
            res.end   = s.endpos;
            res.type  = type;
            res.value = value;
            return(res);
        }
Beispiel #17
0
        internal static ModifiersNode Modifiers(int value, Symbol s)
        {
            ModifiersNode res = new ModifiersNode();

            res.kind  = Kind.Modifiers;
            res.start = s.pos;
            res.end   = s.endpos;
            res.value = value;
            res.start_pos.Add(s.pos.offset);
            return(res);
        }
Beispiel #18
0
        internal static ArrayType ArrayType(TypeNode parent, DimSpecNode dim, Symbol s)
        {
            ArrayType res = new ArrayType();

            res.kind   = Kind.ArrayType;
            res.start  = s.pos;
            res.end    = s.endpos;
            res.parent = parent;
            res.dim    = dim;
            return(res);
        }
Beispiel #19
0
        internal static BinaryNode Binary(Kind k, ExprNode left, ExprNode right, Symbol s)
        {
            BinaryNode res = new BinaryNode();

            res.kind  = k;
            res.start = s.pos;
            res.end   = s.endpos;
            res.left  = left;
            res.right = right;
            return(res);
        }
Beispiel #20
0
        internal static AttributeNode Attribute(IdentNode name, ListNode parms, Symbol s)
        {
            AttributeNode res = new AttributeNode();

            res.kind  = Kind.Attribute;
            res.start = s.pos;
            res.end   = s.endpos;
            res.name  = name;
            res.parms = parms;
            return(res);
        }
Beispiel #21
0
 internal static void Comment(string name, Symbol s)
 {
     /*DocCommentNode com = new DocCommentNode( ref s, text );
      *
      * if( comments != null ) {
      *      int last_offset = ((DocCommentNode)comments.nodes[comments.nodes.Count-1]).end.offset;
      *      if( this.text.Substring( last_offset, s.pos.offset - last_offset ).Trim().Length != 0 )
      *              comments = null;
      * }
      * if( comments == null )
      *      comments = new ListNode( ref s, com );
      * else
      *      comments.Add( ref s, com );*/
 }
Beispiel #22
0
 internal static ArrayType OneArrayType(TypeNode parent, DimSpecNode dim, Symbol s)
 {
     if (parent.kind != Kind.ArrayType)
     {
         return(ArrayType(parent, dim, s));
     }
     else
     {
         ArrayType p = (ArrayType)parent;
         while (p.parent.kind == Kind.ArrayType)
         {
             p = (ArrayType)p.parent;
         }
         p.parent = Make.ArrayType(p.parent, dim, s);
         return((ArrayType)parent);
     }
 }
Beispiel #23
0
        internal static TypeNode type_from_expr(ExprNode expr)
        {
            Symbol s = new Symbol();

            s.pos    = expr.start;
            s.endpos = expr.end;

            switch (expr.kind)
            {
            case Kind.Identifier:
                return(Make.TypeName((IdentNode)expr, s));

            case Kind.Dot:
            case Kind.TypeDot:
                string id = String.Empty;
                while (expr.kind == Kind.Dot)
                {
                    IdentNode idn = ((BinaryNode)expr).right as IdentNode;
                    id   = "." + idn.identifier + id;
                    expr = ((BinaryNode)expr).left;
                }
                if (expr.kind == Kind.TypeDot)
                {
                    // types like: int.A
                    ExprAndTypeNode etn = (ExprAndTypeNode)expr;
                    id = (etn.type as BaseType).typeid.ToString().Substring(1) + "." + (etn.expr as IdentNode).identifier + id;
                    return(Make.TypeName(Make.Ident(id, s), s));
                }
                else if (expr.kind == Kind.Identifier)
                {
                    // types like: a.b.c
                    ((IdentNode)expr).identifier += id;
                    return(Make.TypeName((IdentNode)expr, s));
                }
                return(null);

            case Kind.DimmedExpr:
                TypeExprNode ten = (TypeExprNode)expr;
                return(Make.OneArrayType(type_from_expr(ten.expr), ten.spec, s));
            }
            return(null);
        }
Beispiel #24
0
 internal static ParameterNode Parameter( ListNode attributes, ModifiersNode modifiers, TypeNode type, IdentNode name, Symbol s )
 {
     ParameterNode res = new ParameterNode();
     res.kind = Kind.Param;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.type = type;
     res.name = name;
     return res;
 }
Beispiel #25
0
 internal static void Pos( ref Symbol s )
 {
     Node n = s.sym as Node;
     if( n != null ) {
         n.start = s.pos;
         n.end = s.endpos;
     }
 }
Beispiel #26
0
 internal static NamespaceDecl Namespace( IdentNode name, ListNode usings, ListNode members, Symbol s )
 {
     NamespaceDecl res = new NamespaceDecl();
     res.kind = Kind.Namespace;
     res.start = s.pos;
     res.end = s.endpos;
     res.name = name;
     res.usings = usings;
     res.members = members;
     return res;
 }
Beispiel #27
0
 internal static ArrayType OneArrayType( TypeNode parent, DimSpecNode dim, Symbol s )
 {
     if( parent.kind != Kind.ArrayType )
         return ArrayType( parent, dim, s );
     else {
         ArrayType p = (ArrayType)parent;
         while( p.parent.kind == Kind.ArrayType )
             p = (ArrayType)p.parent;
         p.parent = Make.ArrayType( p.parent, dim, s );
         return (ArrayType)parent;
     }
 }
Beispiel #28
0
 internal static ArrayType ListArrayType( TypeNode parent, ListNode dims, Symbol s )
 {
     TypeNode current = parent;
     foreach( DimSpecNode n in dims.nodes )
         current = OneArrayType( current, n, s );
     return (ArrayType)current;
 }
Beispiel #29
0
 internal static MethodDecl Method( Kind k, ListNode attributes, ModifiersNode modifiers, IdentNode name, TypeNode return_type, ListNode parameters, StatementNode body, ConstructorInitializerNode base_init, Symbol s )
 {
     MethodDecl res = new MethodDecl();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.name = name;
     res.return_type = return_type;
     res.parameters = parameters;
     res.body = body;
     res.base_init = base_init;
     return res;
 }
Beispiel #30
0
        internal static InitializerNode Initializer(Kind k, ExprNode expr, ListNode subinits, Symbol s)
        {
            InitializerNode res = new InitializerNode();

            res.kind     = k;
            res.start    = s.pos;
            res.end      = s.endpos;
            res.expr     = expr;
            res.subinits = subinits;
            return(res);
        }
Beispiel #31
0
        internal static MethodDecl Operator(ModifiersNode mod, TypeNode type, IdentNode name, ParameterNode op1, ParameterNode op2, Symbol s)
        {
            ListNode ln = new ListNode();

            ln.nodes = new ArrayList();
            ln.nodes.Add(op1);
            if (op2 != null)
            {
                ln.nodes.Add(op2);
            }
            ln.start = op1.start;
            ln.end   = op2 != null ? op2.end : op1.end;
            ln.kind  = Kind.List;
            return(Method(name == null ? Kind.ConversionOperator : op2 == null ? Kind.UnaryOperator : Kind.BinaryOperator, null, mod, name, type, ln, null, null, s));
        }
Beispiel #32
0
        internal static ConstructorInitializerNode ConstructorInitializer(Kind k, ListNode args, Symbol s)
        {
            ConstructorInitializerNode res = new ConstructorInitializerNode();

            res.kind  = k;
            res.start = s.pos;
            res.end   = s.endpos;
            res.args  = args;
            return(res);
        }
Beispiel #33
0
 internal static TypeExprNode TypeExpr( ExprNode expr, DimSpecNode spec, Symbol s )
 {
     TypeExprNode res = new TypeExprNode();
     res.kind = Kind.DimmedExpr;
     res.start = s.pos;
     res.end = s.endpos;
     res.expr = expr;
     res.spec = spec;
     return res;
 }
Beispiel #34
0
        internal static AttributeSectionNode AttributeSection(IdentNode target, ListNode attrs, Symbol s)
        {
            AttributeSectionNode res = new AttributeSectionNode();

            res.kind   = Kind.AttributeSection;
            res.start  = s.pos;
            res.end    = s.endpos;
            res.target = target;
            res.attrs  = attrs;
            return(res);
        }
Beispiel #35
0
        // {{End}}

        #endregion

        #region Hand-made modification routines

        internal static void AddList(ListNode list, Node next, Symbol s)
        {
            list.nodes.Add(next);
            list.end = s.endpos;
        }
Beispiel #36
0
 internal static void AddModifier(ModifiersNode mod, int next, int next_offset, Symbol s)
 {
     mod.value |= next;
     mod.start_pos.Add(next_offset);
     mod.end = s.endpos;
 }
Beispiel #37
0
 internal static StatementNode Statement( Kind k, ExprNode expr, IdentNode label, StatementNode stmt1, StatementNode stmt2, ListNode stmts, Symbol s )
 {
     StatementNode res = new StatementNode();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.expr = expr;
     res.label = label;
     res.stmt1 = stmt1;
     res.stmt2 = stmt2;
     res.stmts = stmts;
     return res;
 }
Beispiel #38
0
 internal static EnumDecl Enum( ListNode attributes, ModifiersNode modifiers, IdentNode name, TypeNode basetype, ListNode children, Symbol s )
 {
     EnumDecl res = new EnumDecl();
     res.kind = Kind.Enum;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.name = name;
     res.basetype = basetype;
     res.children = children;
     return res;
 }
Beispiel #39
0
 internal static TypeAndListNode TypeAndList( Kind k, TypeNode type, ListNode list, Symbol s )
 {
     TypeAndListNode res = new TypeAndListNode();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.type = type;
     res.list = list;
     return res;
 }
Beispiel #40
0
 internal static EnumValueNode EnumValue( ListNode attributes, IdentNode name, ExprNode expr, Symbol s )
 {
     EnumValueNode res = new EnumValueNode();
     res.kind = Kind.EnumValue;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.name = name;
     res.expr = expr;
     return res;
 }
Beispiel #41
0
 // {{Methods}}
 internal static ListNode List( Node first, Symbol s )
 {
     ListNode res = new ListNode();
     res.kind = Kind.List;
     res.start = s.pos;
     res.end = s.endpos;
     res.nodes = new ArrayList();
     res.nodes.Add(first);
     return res;
 }
Beispiel #42
0
 internal static EventNode Event( Kind k, ListNode attributes, ModifiersNode modifiers, TypeNode type, IdentNode name, ListNode accessors, ListNode vars, Symbol s )
 {
     EventNode res = new EventNode();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.type = type;
     res.name = name;
     res.accessors = accessors;
     res.vars = vars;
     return res;
 }
Beispiel #43
0
 internal static LiteralNode Literal( LiteralNode.Type type, object value, Symbol s )
 {
     LiteralNode res = new LiteralNode();
     res.kind = Kind.Literal;
     res.start = s.pos;
     res.end = s.endpos;
     res.type = type;
     res.value = value;
     return res;
 }
Beispiel #44
0
 internal static ExprNode Expr( Kind k, Symbol s )
 {
     ExprNode res = new ExprNode();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     return res;
 }
Beispiel #45
0
 internal static ModifiersNode Modifiers( int value, Symbol s )
 {
     ModifiersNode res = new ModifiersNode();
     res.kind = Kind.Modifiers;
     res.start = s.pos;
     res.end = s.endpos;
     res.value = value;
     res.start_pos.Add( s.pos.offset );
     return res;
 }
Beispiel #46
0
 internal static ExprAndListNode ExprAndList( Kind k, ExprNode expr, ListNode list, Symbol s )
 {
     ExprAndListNode res = new ExprAndListNode();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.expr = expr;
     res.list = list;
     return res;
 }
Beispiel #47
0
 internal static NewArrayNode NewArray( TypeNode type, ListNode exprlist, ListNode ranks, Node arrayinit, Symbol s )
 {
     NewArrayNode res = new NewArrayNode();
     res.kind = Kind.NewArray;
     res.start = s.pos;
     res.end = s.endpos;
     res.type = type;
     res.exprlist = exprlist;
     res.ranks = ranks;
     res.arrayinit = arrayinit;
     return res;
 }
Beispiel #48
0
 internal static ExprAndTypeNode ExprAndType( Kind k, ExprNode expr, TypeNode type, Symbol s )
 {
     ExprAndTypeNode res = new ExprAndTypeNode();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.expr = expr;
     res.type = type;
     return res;
 }
Beispiel #49
0
 internal static MethodDecl Operator( ModifiersNode mod, TypeNode type, IdentNode name, ParameterNode op1, ParameterNode op2, Symbol s )
 {
     ListNode ln = new ListNode();
     ln.nodes = new ArrayList();
     ln.nodes.Add( op1 );
     if( op2 != null )
         ln.nodes.Add( op2 );
     ln.start = op1.start;
     ln.end = op2 != null ? op2.end : op1.end;
     ln.kind = Kind.List;
     return Method( name == null ? Kind.ConversionOperator : op2 == null ? Kind.UnaryOperator : Kind.BinaryOperator, null, mod, name, type, ln, null, null, s );
 }
Beispiel #50
0
 internal static FieldsDecl Fields( Kind k, ListNode attributes, ModifiersNode modifiers, TypeNode type, ListNode declarators, Symbol s )
 {
     FieldsDecl res = new FieldsDecl();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.type = type;
     res.declarators = declarators;
     return res;
 }
Beispiel #51
0
 internal static PointerType PointerType( TypeNode parent, Symbol s )
 {
     PointerType res = new PointerType();
     res.kind = Kind.PointerType;
     res.start = s.pos;
     res.end = s.endpos;
     res.parent = parent;
     return res;
 }
Beispiel #52
0
 internal static IdentNode Ident( string identifier, Symbol s )
 {
     IdentNode res = new IdentNode();
     res.kind = Kind.Identifier;
     res.start = s.pos;
     res.end = s.endpos;
     res.identifier = identifier;
     return res;
 }
Beispiel #53
0
 internal static PropertyNode Property( ListNode attributes, ModifiersNode modifiers, TypeNode type, IdentNode name, ListNode accessors, Symbol s )
 {
     PropertyNode res = new PropertyNode();
     res.kind = Kind.Property;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.type = type;
     res.name = name;
     res.accessors = accessors;
     return res;
 }
Beispiel #54
0
 internal static IndexerNode Indexer( ListNode attributes, ModifiersNode modifiers, TypeNode type, IdentNode name, ListNode formal_params, ListNode accessors, Symbol s )
 {
     IndexerNode res = new IndexerNode();
     res.kind = Kind.Indexer;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.type = type;
     res.name = name;
     res.formal_params = formal_params;
     res.accessors = accessors;
     return res;
 }
Beispiel #55
0
 internal static TriplexNode Triplex( ExprNode cond, ExprNode Then, ExprNode Else, Symbol s )
 {
     TriplexNode res = new TriplexNode();
     res.kind = Kind.Triplex;
     res.start = s.pos;
     res.end = s.endpos;
     res.cond = cond;
     res.Then = Then;
     res.Else = Else;
     return res;
 }
Beispiel #56
0
 internal static InitializerNode Initializer( Kind k, ExprNode expr, ListNode subinits, Symbol s )
 {
     InitializerNode res = new InitializerNode();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.expr = expr;
     res.subinits = subinits;
     return res;
 }
Beispiel #57
0
 internal static TypedStatementNode TypedStatement( Kind k, ExprNode expr, IdentNode label, StatementNode stmt1, StatementNode stmt2, ListNode stmts, TypeNode type, Symbol s )
 {
     TypedStatementNode res = new TypedStatementNode();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.expr = expr;
     res.label = label;
     res.stmt1 = stmt1;
     res.stmt2 = stmt2;
     res.stmts = stmts;
     res.type = type;
     return res;
 }
Beispiel #58
0
 internal static void AddIdent(IdentNode id, string postfix, Symbol s)
 {
     id.identifier += postfix;
     id.end         = s.endpos;
 }
Beispiel #59
0
 internal static TypeName TypeName( IdentNode typename, Symbol s )
 {
     TypeName res = new TypeName();
     res.kind = Kind.TypeName;
     res.start = s.pos;
     res.end = s.endpos;
     res.typename = typename;
     return res;
 }
Beispiel #60
0
 internal static DimSpecNode DimSpec( int count, Symbol s )
 {
     DimSpecNode res = new DimSpecNode();
     res.kind = Kind.DimSpecifier;
     res.start = s.pos;
     res.end = s.endpos;
     res.count = count;
     return res;
 }