diff --git a/alib2cli/src/lexer/Lexer.cpp b/alib2cli/src/lexer/Lexer.cpp index f9a332702f4a2b00db64bf53babf5043c1a548c7..12731fa3f08693c49bca2a134f5aad293a2d8606 100644 --- a/alib2cli/src/lexer/Lexer.cpp +++ b/alib2cli/src/lexer/Lexer.cpp @@ -126,6 +126,11 @@ q0: if ( m_source->isEndOfTransmition ( ) ) { goto q3; } + if ( m_source->getCharacter ( ) == '\\' ) { + m_source->advance ( true ); + goto q3Escape; + } + res.m_type = TokenType::ERROR; return res; @@ -160,6 +165,9 @@ q2: if ( m_source->isEndOfSequence ( ) ) { res.m_value += m_source->getCharacter ( ); m_source->advance ( readNextLine ); goto q3; + } else if ( m_source->getCharacter ( ) == '\\' ) { + m_source->advance ( true ); + goto q3Escape; } res.m_value = ""; @@ -178,11 +186,25 @@ q3: if ( m_source->isEndOfSequence ( ) ) { res.m_value += m_source->getCharacter ( ); m_source->advance ( readNextLine ); goto q3; + } else if ( m_source->getCharacter ( ) == '\\' ) { + m_source->advance ( true ); + goto q3Escape; } else { res.m_type = is_kw ( res.m_value ); return res; } +q3Escape: + if ( m_source->isEndOfSequence ( ) ) { + res.m_type = TokenType::ERROR; + return res; + } + + res.m_value += m_source->getCharacter ( ); + + m_source->advance ( readNextLine ); + goto q3; + q4: if ( m_source->isEndOfSequence ( ) ) { res.m_type = TokenType::ERROR; return res; diff --git a/alib2cli/src/parser/Parser.cpp b/alib2cli/src/parser/Parser.cpp index 104cf25f943e1a074106494b0ee66a27153d4725..e17125823ae740273c792a83275ae28d7af84179 100644 --- a/alib2cli/src/parser/Parser.cpp +++ b/alib2cli/src/parser/Parser.cpp @@ -98,7 +98,12 @@ std::shared_ptr < Statement > Parser::in_redirect_file ( ) { templateArgs.emplace_back ( template_arg ( ) ); } - std::unique_ptr < Arg > file = arg ( ); + std::unique_ptr < Arg > file; + if ( check ( cli::Lexer::TokenType::STRING ) ) + file = std::make_unique < ImmediateArg > ( matchString ( ) ); + else { + file = arg ( ); + } return std::make_shared < FileStatement > ( std::move ( file ), std::move ( fileType ), std::move ( type ), std::move ( templateArgs ) ); } @@ -223,7 +228,12 @@ void Parser::out_redirect_file ( std::shared_ptr < StatementList > & list ) { match ( cli::Lexer::TokenType::RIGHT_BRACKET ); } - std::unique_ptr < Arg > file = arg ( ); + std::unique_ptr < Arg > file; + if ( check ( cli::Lexer::TokenType::STRING ) ) + file = std::make_unique < ImmediateArg > ( matchString ( ) ); + else { + file = arg ( ); + } list->append ( std::make_unique < ResultFileStatement > ( std::move ( file ), std::move ( fileType ) ) ); }