Exemplo n.º 1
0
 public bool nextTokenIs(ECodeToken tok)
 {
     if (_NextToken == null)
     {
         return(false);
     }
     else
     {
         return(_NextToken.token == tok);
     }
 }
Exemplo n.º 2
0
 public TCodeToken(string value, ECodeToken Token, int Index, int Line, int Column, int Offset, TCodeTokenFile File)
 {
     _value  = value;
     _token  = Token;
     _line   = Line;
     _column = Column;
     _index  = Index;
     //_Script = Script
     _file   = File;
     _offset = Offset;
 }
Exemplo n.º 3
0
 private static void AddTokenConst(string str, ECodeToken tok)
 {
     TokenConstHash.Add(str.ToUpper(), tok);
 }
Exemplo n.º 4
0
 public bool nextTokenIs(ECodeToken tok)
 {
     if (_NextToken == null)
     {
         return false;
     }
     else
     {
         return _NextToken.token == tok;
     }
 }
Exemplo n.º 5
0
 public TCodeToken(string value, ECodeToken Token, int Index, int Line, int Column, int Offset, TCodeTokenFile File)
 {
     _value = value;
     _token = Token;
     _line = Line;
     _column = Column;
     _index = Index;
     //_Script = Script
     _file = File;
     _offset = Offset;
 }
Exemplo n.º 6
0
 private static void AddTokenConst(string str, ECodeToken tok)
 {
     TokenConstHash.Add(str.ToUpper(), tok);
 }
Exemplo n.º 7
0
        private TCodeToken ReadNextToken()
        {
            if (IsEndOfDocument())
            {
                return(null);
            }
            //MoveToNextNoneWhitespace()

            /*if (IsEndOfDocument())
             * {
             *  return null;
             * }*/

            int        cIndex  = ParsePos;
            int        cLine   = CurrentLine;
            int        cColumn = CurrentColumn;
            string     Value   = "";
            ECodeToken tok     = ECodeToken.Unkown;
            char       c       = CurrentChar;

            Value = c.ToString();

            if (char.IsLetter(c) || c == '_')
            {
                Value = ReadString();
                tok   = GetTokenConst(Value);
                if ((LastCharIs('.') || NextCharIs('.'))) //Schlüsselwörter mit angrenzenden Punkten als Literal behandeln
                {
                    tok = ECodeToken.ltString;
                }
                else
                {
                    if (tok == ECodeToken.Unkown)
                    {
                        tok = ECodeToken.ltString;
                    }
                }
            }
            else if (char.IsDigit(c))
            {
                Value = ReadNumber();
                tok   = ECodeToken.ltNumber;
            }
            else
            {
                if (c == '=')
                {
                    tok = ECodeToken.blEquals;
                }
                else if (c == '<')
                {
                    if (NextCharIs('='))
                    {
                        MoveNextChar();
                        Value = "<=";
                        tok   = ECodeToken.blLessThanOrEquals;
                    }
                    else if (NextCharIs('>'))
                    {
                        MoveNextChar();
                        Value = "<>";
                        tok   = ECodeToken.blUnEquals;
                    }
                    else
                    {
                        tok = ECodeToken.blLessThan;
                    }
                }
                else if (c == '>')
                {
                    if (NextCharIs('='))
                    {
                        MoveNextChar();
                        Value = ">=";
                        tok   = ECodeToken.blGreaterThanOrEquals;
                    }
                    else
                    {
                        tok = ECodeToken.blGreaterThan;
                    }
                }
                else if (c == vbCr)
                {
                    tok = ECodeToken.SyEndOfLine;
                    if (NextCharIs(vbLf))
                    {
                        MoveNextChar();
                        Value  = Environment.NewLine;
                        cLine -= 1;
                    }
                }
                else if (c == '+')
                {
                    if (NextCharIs('+'))
                    {
                        MoveNextChar();
                        Value = "++";
                        tok   = ECodeToken.syAddAdd;
                    }
                    else
                    {
                        tok = ECodeToken.mtAdd;
                    }
                }
                else if (c == '-')
                {
                    if (NextCharIs('-'))
                    {
                        MoveNextChar();
                        Value = "--";
                        tok   = ECodeToken.sySubSub;
                        //ElseIf Char.IsDigit(ParseString.Chars(ParsePos + 1)) Then
                        //	MoveNextChar()
                        //	Value = "-" & ReadNumber()
                        //	tok = ECodeToken.ltNumber
                    }
                    else
                    {
                        tok = ECodeToken.mtSub;
                    }
                }
                else if (c == '\"')
                {
                    Value = ReadQuotedString();
                    tok   = ECodeToken.ltQuotedString;
                }
                else if (c == '\'')
                {
                    Value = ReadQuotedString();
                    tok   = ECodeToken.ltQuotedString;
                }
                else if (c == ' ')
                {
                    Value = ReadWhiteSpace();
                    tok   = ECodeToken.syWhiteSpace;
                }
                else if (c == vbTab)
                {
                    Value = ReadWhiteSpace();
                    tok   = ECodeToken.syWhiteSpace;
                    //Case "#"
                    //	tok = ECodeToken.syRoute
                    //	Value = ReadString()
                }
                else
                {
                    if (c == '/' && NextCharIs('/'))
                    {
                        Value = ReadCommentLine();
                        tok   = ECodeToken.syComment;
                    }
                    else if (c == '/' && NextCharIs('*'))
                    {
                        Value = ReadCommentBlock();
                        tok   = ECodeToken.syComment;
                    }
                    else
                    {
                        tok = GetTokenConst(c.ToString());
                    }
                }
            }

            MoveNextChar();
            TCodeToken ResultToken = new TCodeToken(Value, tok, cIndex, cLine, cColumn, ParsePos - Value.Length, TokenFile);

            if (Tokens.Count > 0)
            {
                TCodeToken LastToken = GetToken(Tokens.Count - 1);
                LastToken.nextToken   = ResultToken;
                ResultToken.lastToken = LastToken;
            }
            Tokens.Add(ResultToken);
            return(ResultToken);
        }