Exemplo n.º 1
0
        internal static BinaryOp CreateBinaryOp03()
        {
            Token    type     = Token.DateMarker;
            BinaryOp binaryOp = BinaryOp.CreateOp(type);

            return(binaryOp);
        }
Exemplo n.º 2
0
        internal static BinaryOp CreateBinaryOp01()
        {
            Token    type     = Token.BitwiseShiftLeft;
            BinaryOp binaryOp = BinaryOp.CreateOp(type);

            return(binaryOp);
        }
Exemplo n.º 3
0
        internal static Expression CreateExpression01()
        {
            Token      type       = Token.LessThan;
            Expression expression = BinaryOp.CreateOp(type);

            return(expression);
        }
Exemplo n.º 4
0
        void ParseBinaryOp( )
        {
            Token token = this.PeekToken();

            this.CheckStartableToken(token);
            BinaryOp bo = BinaryOp.CreateOp(_current.token);

            _tree.AddOperator(bo);
        }
Exemplo n.º 5
0
        public void TestCreateOp01()
        {
            Token    type     = Token.Add;
            BinaryOp binaryOp = BinaryOp.CreateOp(type);

            #region Record State
            ValueRecorder recorder = new ValueRecorder();
            recorder.FinishRecording();
            #endregion
        }
Exemplo n.º 6
0
        public void TestCreateOp03()
        {
            Token    type     = Token.Equality;
            BinaryOp binaryOp = BinaryOp.CreateOp(type);

            type = Token.LessThanOrEqual;
            BinaryOp B1 = BinaryOp.CreateOp(type);

            type = Token.GreaterThanOrEqual;
            B1   = BinaryOp.CreateOp(type);

            type = Token.BitwiseOr;
            B1   = BinaryOp.CreateOp(type);
        }
Exemplo n.º 7
0
 public void TestCreateOp02()
 {
     Token    type     = Token.Inequality;
     BinaryOp binaryOp = BinaryOp.CreateOp(type);
 }
Exemplo n.º 8
0
        public Tree Parse(string text)
        {
            _scanner = new Scanner(text);
            _tree    = new Tree();

            Token token = this.NextToken();

            if (token == Token.EndOfFile)
            {
                return(_tree);
            }
            this.CheckStartableToken(token);

            while (token != Token.EndOfFile)
            {
                if (Parser.IsConstTocken(token))
                {
                    ParseConst();
                }
                else if (_tree._isStart &&
                         ((token == Token.Subtract) || (token == Token.Add)))
                {
                    Constant constant = new Constant((int)0);
                    _tree.AddOperand(constant);
                    BinaryOp bo = BinaryOp.CreateOp(token);
                    _tree.AddOperator(bo);
                }
                else if (Parser.IsBinaryOp(token))
                {
                    ParseBinaryOp();
                }
                else if (Parser.IsUnaryOp(token))
                {
                    ParseUnaryOp();
                }
                else
                {
                    switch (token)
                    {
                    case Token.Identifier:
                        ParseIdentifier();
                        break;

                    case Token.LeftIndexer:
                        this.ParseIndexer();
                        break;

                    case Token.RightIndexer:
                        _tree.Pop('[');
                        break;

                    case Token.ConditionalIf:
                        ParseConditional();
                        break;

                    case Token.ConditionalSemicolon:
                        ParseConditionalSemicolon();
                        break;

                    case Token.Member:
                        ParseMember();
                        break;

                    case Token.LeftParen:
                        if (_tree._top.Expression is MemberOp)
                        {
                            MemberOp memberOp = (MemberOp)_tree._top.Expression;
                            if (memberOp.IsFunction)
                            {
                                throw new ParserException("()() not allowed");
                            }
                            memberOp.IsFunction = true;
                        }
                        this._tree.Push('(');
                        break;

                    case Token.RightParen:
                        _tree.Pop('(');
                        break;

                    case Token.Comma:
                        this._tree.Pop(',');
                        this._tree.Push(',');
                        break;

                    default:
                        throw BuildException(Error.InternalError);
                    }
                }
                token = this.NextToken();
            }

            _tree.Complete();
            return(_tree);
        }