Ejemplo n.º 1
0
 public string ToString()
 {
     //prints Token, if statement for human readability in console
     if (lexeme.Length < 7)
     {
         return("Lexeme: " + lexeme + " \t\t Type: " + tokenType.ToString());
     }
     else
     {
         return("Lexeme: " + lexeme + " \t Type: " + tokenType.ToString());
     }
 }
Ejemplo n.º 2
0
        public Lexeme GetNextLexemeFromBuffer(LexemeType specifiedLexeme = LexemeType.Unspecified)
        {
            if (_bufferReader.EndOfStream)
            {
                return(EofLexeme);
            }

            var lexeme = new List <char>();

            var currentState = _stateContainer[specifiedLexeme.ToString()];

            if (currentState is TerminalState)
            {
                _bufferReader.AdvanceBuffer();
            }

            while (!(currentState is TerminalState))
            {
                currentState = currentState.TransitionToNextState(_bufferReader.Buffer, lexeme);
            }

            var terminalStateLexeme = new Lexeme(((TerminalState)currentState).Type, new string(lexeme.ToArray()));

            return(terminalStateLexeme);
        }