/// <summary> /// Processes tokens until end of stream has been hit. /// </summary> public void GetNextToken() { JavaFile.SkipWhitespace(); if (!JavaFile.EndOfFile()) { ProcessToken(); } else { Token = Tokens.EofT; Lexeme = "End of file"; } }
/// <summary> /// Calls GetNextChar() to skip over comment characters. /// </summary> public void SkipComment(Regex commentEndRegex) { while (!commentEndRegex.IsMatch(CurrentChar.ToString() + JavaFile.PeekNextChar()) && !JavaFile.EndOfFile()) { JavaFile.GetNextChar(); } }
/// <summary> /// Reads a literal string until the ending quote is found. /// Adds 3 tokens: 2 quote tokens, 1 literal token. /// </summary> /// <example> /// "literal" => QuoteT -> LiteralT -> QuoteT /// </example> public void ProcessLiteral() { Token = Tokens.LiteralT; Lexeme = CurrentChar.ToString(); while (JavaFile.PeekNextChar() != '\"' && JavaFile.PeekNextChar() != '\n' && !JavaFile.EndOfFile()) { JavaFile.GetNextChar(); Lexeme += CurrentChar; } if (JavaFile.PeekNextChar() == '\"') { JavaFile.GetNextChar(); Lexeme += CurrentChar.ToString(); } }