Esempio n. 1
0
        private Token NextSymbol()
        {
            Token token = new Token();
            token.Type = TokenType.Symbol;

            token.Value = this.NextNameAsString();

            return token;
        }
Esempio n. 2
0
        private Token NextReal(string value)
        {
            int ch;

            ch = this.NextChar();

            while (ch >= 0 && char.IsDigit((char)ch))
            {
                value += (char)ch;
                ch = this.NextChar();
            }

            this.PushChar(ch);

            Token token = new Token();
            token.Type = TokenType.Real;
            token.Value = value;

            return token;
        }
Esempio n. 3
0
        private Token NextString()
        {
            string value = string.Empty;

            int ch;

            while (true)
            {
                ch = this.NextChar();

                while (ch >= 0 && ch != StringDelimiter)
                {
                    value += (char)ch;
                    ch = this.NextChar();
                }

                if (ch < 0)
                    break;

                int ch2 = this.PeekChar();

                if (ch2 < 0)
                    break;

                if (ch2 != StringDelimiter)
                    break;

                this.NextChar();

                value += (char)ch;
            }

            if (ch < 0)
                throw new LexerException("Unclosed string");

            Token token = new Token();

            token.Type = TokenType.String;
            token.Value = value;

            return token;
        }
Esempio n. 4
0
        private Token NextParameter()
        {
            Token token = new Token();
            token.Type = TokenType.Parameter;
            token.Value = this.NextNameAsString();

            return token;
        }
Esempio n. 5
0
        private Token NextPunctuation(char ch)
        {
            Token token = new Token();
            token.Value = new string(ch, 1);
            token.Type = TokenType.Punctuation;

            return token;
        }
Esempio n. 6
0
        private Token NextName(char firstchar)
        {
            StringBuilder sb = new StringBuilder(10);
            sb.Append(firstchar);

            int ch;

            ch = this.NextChar();

            while (ch >= 0 && char.IsLetterOrDigit((char)ch))
            {
                sb.Append((char)ch);
                ch = this.NextChar();
            }

            if (ch >= 0 && ch == '.' && char.IsUpper(firstchar))
            {
                var peek = this.PeekChar();

                if (peek >= 0 && char.IsLetter((char)peek) && char.IsUpper((char)peek))
                {
                    sb.Append((char)ch);
                    return this.NextDottedName(sb.ToString());
                }

                this.PushChar(ch);
            }
            else if (ch >= 0 && ch == ':')
            {
                sb.Append((char)ch);
            }
            else
            {
                this.PushChar(ch);
            }

            Token token = new Token();
            token.Type = TokenType.Name;
            token.Value = sb.ToString();

            return token;
        }
Esempio n. 7
0
        private Token NextOperator(char firstchar)
        {
            string value = new string(firstchar, 1);

            if (firstchar != '^')
            {
                int ch;

                ch = this.NextChar();

                while (ch >= 0 && Operators.IndexOf((char)ch) >= 0)
                {
                    value += (char)ch;
                    ch = this.NextChar();
                }

                this.PushChar(ch);
            }

            Token token = new Token();
            token.Type = TokenType.Operator;
            token.Value = value;

            return token;
        }
Esempio n. 8
0
        private Token NextInteger(char firstdigit)
        {
            string value = new string(firstdigit, 1);

            int ch;

            ch = this.NextChar();

            while (ch >= 0 && char.IsDigit((char)ch))
            {
                value += (char)ch;
                ch = this.NextChar();
            }

            if (ch == '.')
            {
                int ch2 = this.PeekChar();

                if (ch2 >= 0 && char.IsDigit((char)ch2))
                    return this.NextReal(value + ".");
            }

            if (ch >= 0 && ch == 'r')
            {
                value += (char)ch;

                for (ch = this.NextChar(); ch >= 0 && char.IsLetterOrDigit((char)ch); ch = this.NextChar())
                    value += (char)ch;
            }

            this.PushChar(ch);

            Token token = new Token();
            token.Type = TokenType.Integer;
            token.Value = value;

            return token;
        }
Esempio n. 9
0
        private Token NextEnclosedSymbol()
        {
            StringBuilder sb = new StringBuilder(10);

            int ch;

            ch = this.NextChar();

            while (ch >= 0 && ch != '}')
            {
                sb.Append((char)ch);
                ch = this.NextChar();
            }

            if (ch != '}')
                new LexerException("Expected '}'");

            Token token = new Token();
            token.Type = TokenType.Symbol;
            token.Value = sb.ToString();

            return token;
        }
Esempio n. 10
0
        private Token NextDotNetTypeName()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(SpecialDotNetTypeMark);

            int ch;

            ch = this.NextChar();

            while (ch >= 0 && (char.IsLetterOrDigit((char)ch) || ch == '.'))
            {
                sb.Append((char)ch);
                ch = this.NextChar();
            }

            this.PushChar(ch);

            Token token = new Token();
            token.Type = TokenType.Name;
            token.Value = sb.ToString();

            return token;
        }
Esempio n. 11
0
 public void PushToken(Token token)
 {
     this.tokenstack.Push(token);
 }
Esempio n. 12
0
 private void PushToken(Token token)
 {
     this.tokenizer.PushToken(token);
 }