Ejemplo n.º 1
0
 public LookupNode(SourcePosition pos, VariableNode variableNode, Node keyNode)
     : base(pos)
 {
     this.variableNode = variableNode;
     this.keyNode = keyNode;
 }
Ejemplo n.º 2
0
 private Node Variable()
 {
     // VARIABLE_DEF VARIABLE ASSIGN
     Token variable = Match(TokenType.VARIABLE);
     VariableNode varNode = new VariableNode(variable.Position, variable.Text);
     TokenType next = LookAhead(1);
     if (next == TokenType.LBRACKET)
     {
         SourcePosition pos = Match(TokenType.LBRACKET).Position;
         Node key = Expression();
         Match(TokenType.RBRACKET);
         return new LookupNode(pos, varNode, key);
     }
     else if (LookAhead(1) == TokenType.PERIOD)
     {
         Match(TokenType.PERIOD);
         PropertyTreeNode propertyTree = new PropertyTreeNode(varNode.Position, varNode, Property());
         if (LookAhead(1) == TokenType.END_STATEMENT)
         {
             Match(TokenType.END_STATEMENT);
         }
         return propertyTree;
     }
     else if (LookAhead(1) == TokenType.COLON)
     {
         PropertyNode property = new PropertyNode(variable.Position, variable.Text);
         Match(TokenType.COLON);
         Node value = Expression();
         if (LookAhead(1) == TokenType.COMMA)
             Match(TokenType.COMMA);
         return new AssignNode(property.Position, property, value, true);
     }
     else
     {
         return varNode;
     }
 }
Ejemplo n.º 3
0
 private Node Parameter()
 {
     // variable (ASSIGN^ expression)?
     Token t = Match(TokenType.VARIABLE);
     VariableNode variable = new VariableNode(t.Position, t.Text);
     if (LookAhead(1) == TokenType.ASSIGN)
     {
         SourcePosition pos = Match(TokenType.ASSIGN).Position;
         Node e = Expression();
         return new AssignNode(pos, variable, e, true);
     }
     return variable;
 }
Ejemplo n.º 4
0
        private CatchNode Catch()
        {
            SourcePosition pos = Match(TokenType.CATCH).Position;

            VariableNode errorVariable = null;
            if (LookAhead(1) == TokenType.LPAREN)
            {
                Match(TokenType.LPAREN);
                Token variable = Match(TokenType.VARIABLE);
                errorVariable = new VariableNode(variable.Position, variable.Text);
                Match(TokenType.RPAREN);
            }

            BlockNode catchBlock = Block();

            return new CatchNode(pos, errorVariable, catchBlock);
        }
Ejemplo n.º 5
0
 public CatchNode(SourcePosition pos, VariableNode errorVariable, BlockNode catchBlock)
     : base(pos)
 {
     this.errorVariable = errorVariable;
     this.catchBlock    = catchBlock;
 }
Ejemplo n.º 6
0
 public CatchNode(SourcePosition pos, VariableNode errorVariable, BlockNode catchBlock)
     : base(pos)
 {
     this.errorVariable = errorVariable;
     this.catchBlock = catchBlock;
 }