コード例 #1
0
ファイル: VBScriptLexer.cs プロジェクト: kmvi/vbscript-parser
        private Token NextDateLiteral()
        {
            int start = Index++;
            var str   = GetStringBuilder();

            while (!IsEof())
            {
                char c = Code.GetChar(Index);
                if (c == '#' || CharUtils.IsNewLine(c))
                {
                    break;
                }
                else
                {
                    str.Append(c);
                    ++Index;
                }
            }

            if (Code.GetChar(Index) != '#' || str.Length == 0)
            {
                throw VBSyntaxError(VBSyntaxErrorCode.SyntaxError);
            }

            var date = LexerUtils.GetDate(str.ToString());

            return(new DateLiteralToken
            {
                Start = start,
                End = ++Index,
                LineNumber = CurrentLine,
                LineStart = CurrentLineStart,
                Value = date,
            });
        }
コード例 #2
0
ファイル: VBScriptLexer.cs プロジェクト: kmvi/vbscript-parser
        private Token NextIdentifier()
        {
            int    start = Index;
            string id    = GetIdentifierName();

            Token result;

            if (id.CIEquals("true"))
            {
                result = new TrueLiteralToken();
            }
            else if (id.CIEquals("null"))
            {
                result = new NullLiteralToken();
            }
            else if (id.CIEquals("false"))
            {
                result = new FalseLiteralToken();
            }
            else if (id.CIEquals("empty"))
            {
                result = new EmptyLiteralToken();
            }
            else if (id.CIEquals("nothing"))
            {
                result = new NothingLiteralToken();
            }
            else if (LexerUtils.IsKeyword(id))
            {
                result = new KeywordToken {
                    Keyword = LexerUtils.GetKeyword(id),
                    Name    = id,
                }
            }
            ;
            else if (LexerUtils.IsKeywordAsIdentifier(id))
            {
                result = new KeywordOrIdentifierToken
                {
                    Keyword = LexerUtils.GetKeywordAsIdentifier(id),
                    Name    = id,
                }
            }
            ;
            else
            {
                result = new IdentifierToken {
                    Name = id
                }
            };

            result.Start      = start;
            result.End        = Index;
            result.LineNumber = CurrentLine;
            result.LineStart  = CurrentLineStart;

            return(result);
        }