Example #1
0
        public override bool convert( Irony.Parsing.ParseTreeNode node, Compiler c )
        {
            base.convert( node, c );
            if( node.Term.Name == "ArraySliceFull" )
            {
            this.source = c.convertNode( node.ChildNodes[0] );
            this.begin = c.convertNode( node.ChildNodes[2] );
            this.end = c.convertNode( node.ChildNodes[3] );

            return true;
            }
            else if( node.Term.Name == "ArraySliceFromStart" )
            {
            this.source = c.convertNode( node.ChildNodes[0] );
            this.end = c.convertNode( node.ChildNodes[2] );

            return true;
            }
            else if( node.Term.Name == "ArraySliceFromEnd" )
            {
            this.source = c.convertNode( node.ChildNodes[0] );
            this.begin = c.convertNode( node.ChildNodes[2] );

            return true;
            }

            return false;
        }
Example #2
0
        public override bool convert( Irony.Parsing.ParseTreeNode node, Compiler c )
        {
            base.convert( node, c );
            if( node.Term.Name == "ReturnStmt" )
            {
            this.value = c.convertNode( node.ChildNodes[1] );
            return true;
            }

            return false;
        }
Example #3
0
        public override bool convert( ParseTreeNode node, Compiler c )
        {
            base.convert( node, c );
            if( node.Term.Name == "AssignmentStmt" )
            {
            this.lhs = c.convertNode( node.ChildNodes[0] );
            this.rhs = c.convertNode( node.ChildNodes[2] );
            return true;
            }

            return false;
        }
Example #4
0
        public override bool convert( Irony.Parsing.ParseTreeNode node, Compiler c )
        {
            base.convert( node, c );
            if( node.Term.Name == "ArrayAccess" )
            {
            this.source = c.convertNode( node.ChildNodes[0] );
            this.index = c.convertNode( node.ChildNodes[2] );

            return true;
            }

            return false;
        }
Example #5
0
        public override bool convert( Irony.Parsing.ParseTreeNode node, Compiler c )
        {
            base.convert( node, c );
            if( node.Term.Name == "MemberAccess" )
            {
            if( node.ChildNodes[0].Token != null && node.ChildNodes[0].Token.Text == "$" )
                this.rvalue = new AstIdentifier( "$" );
            else
                this.rvalue = c.convertNode( node.ChildNodes[0] );
            this.member = node.ChildNodes[2].Token.Text;
            return true;
            }

            return false;
        }
Example #6
0
        public override bool convert( ParseTreeNode node, Compiler c )
        {
            base.convert( node, c );
            if( node.Term.Name == "BinExpr" )
            {
            this.left = c.convertNode( node.ChildNodes[0] );
            this.right = c.convertNode( node.ChildNodes[2] );
            this.op = node.ChildNodes[1].Term.Name;

            return true;
            }
            if( node.Term.Name == "UnExpr" )
            {
            this.op = node.ChildNodes[0].Term.Name;
            this.right = c.convertNode( node.ChildNodes[1] );
            return true;
            }
            if( node.Term.Name == "NotExpr" )
            {
            this.op = "!";
            this.right = c.convertNode( node.ChildNodes[1] );
            return true;
            }

            return false;
        }
Example #7
0
 internal CodeFragment( AstNode root )
 {
     this.root = root;
     this.errors = null;
 }
Example #8
0
        // Wraps the arguments in AstNodes that can be executed.
        static AstNode[] WrapArgs( object[] args )
        {
            AstNode[] wrapped = new AstNode[args.Length];
            for( int i=0; i<args.Length; ++i )
            wrapped[i] = new WrapperAstObject( Util.CoerceFromDotNet( args[i] ) );

            return wrapped;
        }
Example #9
0
 public IfClause( AstNode condition, AstStatements block )
 {
     this.condition = condition;
     this.block = block;
 }
Example #10
0
        public override bool convert( Irony.Parsing.ParseTreeNode node, Compiler c )
        {
            base.convert( node, c );
            if( node.Term.Name == "WhileStmt" )
            {
            // Get our loop variable.
            this.test = c.convertNode( node.ChildNodes[1] );

            // Convert the inner block.
            this.block = c.convertNode( node.ChildNodes[2] );

            return true;
            }

            // This is really just a special case of a while loop, so we'll handle it here.
            if( node.Term.Name == "ForStmt" )
            {
            this.preLoop = c.convertNode( node.ChildNodes[1] );
            this.test = c.convertNode( node.ChildNodes[3] );
            this.postLoop = c.convertNode( node.ChildNodes[5] );
            this.block = c.convertNode( node.ChildNodes[6] );
            return true;
            }

            return false;
        }
Example #11
0
        public override bool convert( Irony.Parsing.ParseTreeNode node, Compiler c )
        {
            base.convert( node, c );
            if( node.Term.Name == "TryStmt" )
            {
            this.tryBlock = c.convertNode( node.ChildNodes[1] );

            if( node.ChildNodes.Count == 2 )
                throw new InvalidOperationException( "Can't have a try block without except/finally" );

            var except = node.ChildNodes[2];
            if( except.ChildNodes.Count == 2 )
                this.exceptBlock = c.convertNode( except.ChildNodes[1] );
            else
            {
                this.exceptIdentifer = except.ChildNodes[1].Token.Text;
                this.exceptBlock = c.convertNode( except.ChildNodes[2] );
            }

            if( node.ChildNodes.Count > 3 )
            {
                var fin = node.ChildNodes[3];
                this.finallyBlock = c.convertNode( fin.ChildNodes[1] );
            }

            return true;
            }

            return false;
        }
Example #12
0
        public override bool convert( Irony.Parsing.ParseTreeNode node, Compiler c )
        {
            base.convert( node, c );
            if( node.Term.Name == "FunctionCall" )
            {
            this.source = c.convertNode( node.ChildNodes[0] );
            this.parameters = node.ChildNodes[1].ChildNodes.Select( n => c.convertNode( n ) ).ToArray();

            return true;
            }

            return false;
        }
Example #13
0
 public AstCall( AstNode source, AstNode[] parameters, StackTrace.StackFrame frame )
 {
     this.source = source;
     this.parameters = parameters;
     this.frame = frame;
 }
Example #14
0
 public Step( AstNode n, ActionCallback a, string d = null )
 {
     this.node = n;
     this.action = a;
     this.description = d;
 }