/// <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>
 /// Loads the Lexeme until the regular expression no longer matches.
 /// </summary>
 public void LoadLexeme(Regex lexemeRegex)
 {
     while (lexemeRegex.IsMatch(JavaFile.PeekNextChar().ToString()))
     {
         JavaFile.GetNextChar();
         Lexeme += CurrentChar;
     }
 }
 /// <summary>
 /// Determines type of comment, the comment is then skipped.
 /// </summary>
 public void ProcessComment()
 {
     if (JavaFile.PeekNextChar() == '/')
     {
         SkipComment(oneLineCommentEndRegex);
     }
     else if (JavaFile.PeekNextChar() == '*')
     {
         SkipComment(multiLineCommentEndRegex);
         JavaFile.GetNextChar();
         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();
            }
        }
        /// <summary>
        /// Reads next character into Lexeme, then validates correct
        /// double token.
        /// </summary>
        public void ProcessDoubleToken()
        {
            JavaFile.GetNextChar();
            Lexeme += CurrentChar;

            if (CurrentChar == '=')
            {
                Token = Tokens.RelOpT;
            }
            else if (CurrentChar == '&')
            {
                Token = Tokens.MulOpT;
            }
            else if (CurrentChar == '|')
            {
                Token = Tokens.AddOpT;
            }
            else
            {
                Token = Tokens.UnknownT;
            }
        }
        /// <summary>
        /// Reads the first token char into Lexeme, which is then
        /// used to determine which function to use for processing.
        /// </summary>
        public void ProcessToken()
        {
            JavaFile.GetNextChar();
            Lexeme = CurrentChar.ToString();

            if (commentStartRegex.IsMatch(Lexeme + JavaFile.PeekNextChar()))
            {
                // skip the comment then continue processing the token
                ProcessComment();
                GetNextToken();
            }
            else if (char.IsLetter(Lexeme[0]))
            {
                ProcessWordToken();
            }
            else if (char.IsDigit(Lexeme[0]))
            {
                ProcessNumToken();
            }
            else if (comparisonRegex.IsMatch(Lexeme) && lookAheadCharRegex.IsMatch(JavaFile.PeekNextChar().ToString()))
            {
                ProcessDoubleToken();
            }
            else if (specialCharRegex.IsMatch(Lexeme))
            {
                ProcessSingleToken();
            }
            else if (Lexeme == "\"")
            {
                ProcessLiteral();
            }
            else
            {
                Token = Tokens.UnknownT;
            }
        }