Exemple #1
0
 private TCodeToken getNextToken()
 {
     if (_IsEndOfDocument)
     {
         return(null);
     }
     if (currentToken == null)
     {
         currentToken = getToken(0);
         return(currentToken);
     }
     else
     {
         if (currentToken.nextToken == null)
         {
             currentToken     = null;
             _IsEndOfDocument = true;
             return(null);
         }
         else
         {
             currentToken = currentToken.nextToken;
             return(currentToken);
         }
     }
 }
Exemple #2
0
 private TCodeToken getLastToken()
 {
     if (currentToken == null)
     {
         return(null);
     }
     currentToken     = currentToken.lastToken;
     _IsEndOfDocument = false;
     return(currentToken);
 }
Exemple #3
0
 public bool getLastToken(ref TCodeToken refToken)
 {
     if (_LastToken == null)
     {
         return(false);
     }
     else
     {
         refToken = _LastToken;
         return(true);
     }
 }
Exemple #4
0
 public bool getNextToken(ref TCodeToken RefToken)
 {
     if (_NextToken == null)
     {
         return(false);
     }
     else
     {
         RefToken = _NextToken;
         return(true);
     }
 }
Exemple #5
0
        private void ReadTokens()
        {
            Tokens = new ArrayList();

            TCodeToken tok = null;

            while (true)
            {
                tok = ReadNextToken();
                if (tok == null)
                {
                    break;
                }
            }
            //Script._Tokens = CType(Tokens.ToArray(GetType(TCodeToken)), TCodeToken())
        }
Exemple #6
0
        private void ConnectTokens(ArrayList TokenList)
        {
            foreach (TCodeToken tok in TokenList)
            {
                tok.lastToken = null;
                tok.nextToken = null;
            }

            for (int i = 1; i < TokenList.Count; i++)
            {
                TCodeToken tok       = (TCodeToken)(TokenList[i]);
                TCodeToken LastToken = (TCodeToken)(TokenList[i - 1]);
                LastToken.nextToken = tok;
                tok.lastToken       = LastToken;
            }
        }
Exemple #7
0
 private void Include()
 {
     if (IncludeDelegate != null)
     {
         for (int i = Tokens.Count - 1; i >= 0; i--)
         {
             TCodeToken tok = (TCodeToken)(Tokens[i]);
             if (tok.token == ECodeToken.syRoute && i != Tokens.Count - 1)
             {
                 TCodeToken LabelToken = (TCodeToken)(Tokens[i + 1]);
                 if (LabelToken.token == ECodeToken.ltString && LabelToken.value == "Include")
                 {
                     for (int i2 = i + 2; i2 < Tokens.Count; i2++)
                     {
                         TCodeToken NameToken = (TCodeToken)(Tokens[i2]);
                         if (NameToken.token == ECodeToken.syEndOfCommand)
                         {
                             //Dim Name As String = NameToken.Value
                             string Name = "";
                             for (int i3 = i + 2; i3 < i2; i3++)
                             {
                                 Name += ((TCodeToken)(Tokens[i3])).value;
                             }
                             TCodeToken[] SubTokens = null;
                             SubTokens = IncludeDelegate(Name, TokenFile);
                             if (SubTokens != null)
                             {
                                 Tokens.InsertRange(i, SubTokens);
                             }
                             break;
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #8
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;
        }
Exemple #9
0
 public bool getLastToken(ref TCodeToken refToken)
 {
     if (_LastToken == null)
     {
         return false;
     }
     else
     {
         refToken = _LastToken;
         return true;
     }
 }
Exemple #10
0
 public bool getNextToken(ref TCodeToken RefToken)
 {
     if (_NextToken == null)
     {
         return false;
     }
     else
     {
         RefToken = _NextToken;
         return true;
     }
 }
Exemple #11
0
        internal void setTokens(TCodeToken[] TokenList)
        {
            foreach (TCodeToken tok in TokenList)
            {
                if (tok.token != ECodeToken.syWhiteSpace && tok.token != ECodeToken.SyEndOfLine)
                {
                    tokens.Add(tok);
                }
            }

            ConnectTokens(tokens);
        }
Exemple #12
0
 private TCodeToken getLastToken()
 {
     if (currentToken == null)
     {
         return null;
     }
     currentToken = currentToken.lastToken;
     _IsEndOfDocument = false;
     return currentToken;
 }
Exemple #13
0
 public void resetTokenPosition()
 {
     _IsEndOfDocument = false;
     currentToken = null;
 }
Exemple #14
0
 private TCodeToken getNextToken()
 {
     if (_IsEndOfDocument)
     {
         return null;
     }
     if (currentToken == null)
     {
         currentToken = getToken(0);
         return currentToken;
     }
     else
     {
         if (currentToken.nextToken == null)
         {
             currentToken = null;
             _IsEndOfDocument = true;
             return null;
         }
         else
         {
             currentToken = currentToken.nextToken;
             return currentToken;
         }
     }
 }
Exemple #15
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);
        }
Exemple #16
0
 public void resetTokenPosition()
 {
     _IsEndOfDocument = false;
     currentToken     = null;
 }