IronLua.Compiler.Parser.Input.Advance C# (CSharp) Method

Advance() public method

public Advance ( ) : void
return void
        public void Advance()
        {
            index += 1;
            Column = Column + 1;
        }

Usage Example

Example #1
0
        private Token NextToken()
        {
            while (input.CanContinue)
            {
                switch (input.Current)
                {
                // Whitespace
                case ' ':
                case '\t':
                    input.Advance();
                    break;

                // Newlines
                case '\r':
                case '\n':
                    NextLine();
                    break;

                // String
                case '\'':
                case '"':
                    return(StringLiteral(input.Current));

                // Comment or minus
                case '-':
                    input.StorePosition();
                    input.Advance();

                    if (input.Current != '-')
                    {
                        return(input.Output(Symbol.Minus));
                    }

                    if (input.CanPeek && input.Peek == '[')
                    {
                        LongComment();
                    }
                    else
                    {
                        ShortComment();
                    }

                    break;

                default:
                    // Long string
                    if (input.Current == '[' && input.CanPeek &&
                        (input.Peek == '[' || input.Peek == '='))
                    {
                        return(LongStringLiteral());
                    }

                    // Hex numeric
                    if (input.Current == '0' && input.CanPeek &&
                        (input.Peek == 'X' || input.Peek == 'x'))
                    {
                        return(NumericHexLiteral());
                    }

                    // Numeric
                    if (input.Current.IsDecimal() ||
                        (input.Current == '.' && input.CanPeek && input.Peek.IsDecimal()))
                    {
                        return(NumericLiteral());
                    }

                    // Identifier or keyword
                    if (input.Current.IsIdentifierStart())
                    {
                        return(IdentifierOrKeyword());
                    }

                    // Punctuation
                    if (input.Current.IsPunctuation())
                    {
                        return(Punctuation());
                    }

                    throw new LuaSyntaxException(input, ExceptionMessage.UNEXPECTED_CHAR, input.Current);
                }
            }
            return(input.Output(Symbol.Eof));
        }