From 0c103b06f14a356ed5a669181cd3d3ca4f214178 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Sat, 23 Nov 2019 19:12:04 +0100 Subject: [PATCH] fix comments --- alib2cli/src/lexer/Lexer.cpp | 18 ++++++++++++------ alib2cli/src/parser/Parser.cpp | 8 ++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/alib2cli/src/lexer/Lexer.cpp b/alib2cli/src/lexer/Lexer.cpp index c163aa97a8..9aae858212 100644 --- a/alib2cli/src/lexer/Lexer.cpp +++ b/alib2cli/src/lexer/Lexer.cpp @@ -593,8 +593,10 @@ qComment : m_source.advance ( readNextLine ); } - res.m_raw += m_source.getCharacter ( ); - m_source.advance ( true ); + if ( m_source.getCharacter ( ) == '\n' ) { + res.m_raw += m_source.getCharacter ( ); + m_source.advance ( readNextLine ); + } } else if ( m_source.getCharacter ( ) == '*' ) { res.m_value = ""; res.m_raw += m_source.getCharacter ( ); @@ -606,12 +608,16 @@ qComment : m_source.advance ( true ); } - res.m_raw += m_source.getCharacter ( ); - m_source.advance ( true ); + if ( m_source.getCharacter ( ) == '*' ) { + 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 ); + if ( m_source.getCharacter ( ) == '/' ) { + res.m_raw += m_source.getCharacter ( ); + m_source.advance ( readNextLine ); + } } else { return res; } diff --git a/alib2cli/src/parser/Parser.cpp b/alib2cli/src/parser/Parser.cpp index 465587f9c5..aba9526eba 100644 --- a/alib2cli/src/parser/Parser.cpp +++ b/alib2cli/src/parser/Parser.cpp @@ -362,6 +362,12 @@ std::unique_ptr < Command > Parser::introspect_command ( ) { std::unique_ptr < CommandList > Parser::parse ( ) { ext::vector < std::unique_ptr < Command > > list; + + if ( check ( cli::Lexer::TokenType::EOS, cli::Lexer::TokenType::EOT ) ) { + list.emplace_back ( std::make_unique < EOTCommand > ( ) ); + return std::make_unique < CommandList > ( std::move ( list ) ); + } + list.emplace_back ( command ( ) ); while ( check ( cli::Lexer::TokenType::SEMICOLON_SIGN ) ) { match ( cli::Lexer::TokenType::SEMICOLON_SIGN ); @@ -424,8 +430,6 @@ std::unique_ptr < Command > Parser::command ( ) { match ( cli::Lexer::TokenType::FILE, cli::Lexer::TokenType::STRING ); return std::make_unique < UnloadCommand > ( std::move ( libraryName ) ); - } else if ( check ( cli::Lexer::TokenType::EOT ) ) { - return std::make_unique < EOTCommand > ( ); } else { throw exception::CommonException ( "Mismatched set while expanding parse rule. Token is " + Lexer::tokenTypeToString ( m_current.m_type ) + "." ); } -- GitLab