diff --git a/alib2cli/src/lexer/Lexer.cpp b/alib2cli/src/lexer/Lexer.cpp index f0367e1ff54f6f1329d6c15f7dd4646b7c5d8dc8..c163aa97a83207aca055e40e39e2541ffddb96ac 100644 --- a/alib2cli/src/lexer/Lexer.cpp +++ b/alib2cli/src/lexer/Lexer.cpp @@ -153,7 +153,7 @@ q0: if ( m_source.getCharacter ( ) == EOF ) { res.m_raw += m_source.getCharacter ( ); m_source.advance ( readNextLine ); res.m_type = TokenType::SLASH_SIGN; - return res; + goto qComment; } if ( m_source.getCharacter ( ) == '*' ) { res.m_raw += m_source.getCharacter ( ); @@ -574,6 +574,50 @@ qType: res.m_type = TokenType::TYPE; return res; } + +qComment : + if ( m_source.getCharacter ( ) == EOF ) { + return res; + } + if ( m_source.getCharacter ( ) == '\0' ) { + return res; + } + + if ( m_source.getCharacter ( ) == '/' ) { + res.m_value = ""; + res.m_raw += m_source.getCharacter ( ); + m_source.advance ( readNextLine ); + + while ( m_source.getCharacter ( ) != EOF && m_source.getCharacter ( ) != '\n' && m_source.getCharacter ( ) != '\0' ) { + res.m_raw += m_source.getCharacter ( ); + m_source.advance ( readNextLine ); + } + + res.m_raw += m_source.getCharacter ( ); + m_source.advance ( true ); + } else if ( m_source.getCharacter ( ) == '*' ) { + res.m_value = ""; + res.m_raw += m_source.getCharacter ( ); + m_source.advance ( true ); + + do { + while ( m_source.getCharacter ( ) != EOF && m_source.getCharacter ( ) != '*' && m_source.getCharacter ( ) != '\0' ) { + res.m_raw += m_source.getCharacter ( ); + m_source.advance ( true ); + } + + res.m_raw += m_source.getCharacter ( ); + m_source.advance ( true ); + } while ( m_source.getCharacter ( ) != EOF && m_source.getCharacter ( ) != '/' && m_source.getCharacter ( ) != '\0' ); + + res.m_raw += m_source.getCharacter ( ); + m_source.advance ( true ); + } else { + return res; + } + + goto q0; + } } /* namespace cli */