Exemple #1
0
 ParserException BuildException(Error errorCode, Context token)
 {
     return new ParserException(errorCode, token.startPos);
 }
Exemple #2
0
        public Token NextToken()
        {
            SkipBlanks();

            _context = new Context();
            _context.startPos = this._curPos;
            Token token = ScanToken();
            _context.token = token;
            _context.endPos = this._curPos;

            switch (token)
            {
                case Token.StringMarker:
                    _context.value = ScanString();
                    token = Token.Const;
                    _context.token = token;
                    _context.endPos = this._curPos;
                    break;
                case Token.LeftCurly:
                    string identifier = ScanIdentifier();
                    token = Keywords.GetToken(identifier);
                    if (token == Token.None)
                    {
                        token = Token.Identifier;
                        _context.value = identifier;
                    }
                    else
                    {
                        switch (token)
                        {
                            case Token.True:
                                _context.value = true;
                                break;
                            case Token.False:
                                _context.value = false;
                                break;
                            case Token.Null:
                                break;
                        }
                    }
                    _context.token = token;
                    _context.endPos = this._curPos;
                    if (ScanToken() != Token.RightCurly)
                      throw new ScannerException(Error.ParameterAccessNotEnded);
                    break;
                case Token.CharMarker:
                    _context.value = ScanChar();
                    token = Token.Const;
                    _context.token = token;
                    _context.endPos = this._curPos;
                    break;
                case Token.HexStart:
                    _context.value = this.ScanHexNumber();
                    token = Token.Const;
                    _context.token = token;
                    _context.endPos = this._curPos;
                    break;
                case Token.DateMarker:
                    _context.value = this.ScanDate();
                    token = Token.Const;
                    _context.token = token;
                    _context.endPos = this._curPos;
                    break;
                case Token.None:
                    {
                        char ch = this.GetChar(_curPos);
                        if (Scanner.IsDigit(ch))
                        {
                            token = Token.Const;
                            _context.token = token;
                            _context.value = this.ScanNumber();
                            _context.endPos = this._curPos;
                        }
                        else if (ch == '\0')
                        {
                            token = Token.EndOfFile;
                            _context.token = token;
                        }
                        else
                        {
                            throw new ScannerException(Error.UnrecogniseChar);
                        }
                    }
                    break;
            }
            return token;
        }
Exemple #3
0
 internal Token NextToken()
 {
     Token token = _scanner.NextToken();
     _current = _scanner._context;
     return token;
 }