Skip to content
Snippets Groups Projects
Commit 401122a2 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

allow escape in identifiers and strings as file args

parent ed2f45cf
No related branches found
No related tags found
No related merge requests found
Pipeline #27657 canceled
...@@ -126,6 +126,11 @@ q0: if ( m_source->isEndOfTransmition ( ) ) { ...@@ -126,6 +126,11 @@ q0: if ( m_source->isEndOfTransmition ( ) ) {
goto q3; goto q3;
} }
   
if ( m_source->getCharacter ( ) == '\\' ) {
m_source->advance ( true );
goto q3Escape;
}
res.m_type = TokenType::ERROR; res.m_type = TokenType::ERROR;
return res; return res;
   
...@@ -160,6 +165,9 @@ q2: if ( m_source->isEndOfSequence ( ) ) { ...@@ -160,6 +165,9 @@ q2: if ( m_source->isEndOfSequence ( ) ) {
res.m_value += m_source->getCharacter ( ); res.m_value += m_source->getCharacter ( );
m_source->advance ( readNextLine ); m_source->advance ( readNextLine );
goto q3; goto q3;
} else if ( m_source->getCharacter ( ) == '\\' ) {
m_source->advance ( true );
goto q3Escape;
} }
   
res.m_value = ""; res.m_value = "";
...@@ -178,11 +186,25 @@ q3: if ( m_source->isEndOfSequence ( ) ) { ...@@ -178,11 +186,25 @@ q3: if ( m_source->isEndOfSequence ( ) ) {
res.m_value += m_source->getCharacter ( ); res.m_value += m_source->getCharacter ( );
m_source->advance ( readNextLine ); m_source->advance ( readNextLine );
goto q3; goto q3;
} else if ( m_source->getCharacter ( ) == '\\' ) {
m_source->advance ( true );
goto q3Escape;
} else { } else {
res.m_type = is_kw ( res.m_value ); res.m_type = is_kw ( res.m_value );
return res; 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 ( ) ) { q4: if ( m_source->isEndOfSequence ( ) ) {
res.m_type = TokenType::ERROR; res.m_type = TokenType::ERROR;
return res; return res;
......
...@@ -98,7 +98,12 @@ std::shared_ptr < Statement > Parser::in_redirect_file ( ) { ...@@ -98,7 +98,12 @@ std::shared_ptr < Statement > Parser::in_redirect_file ( ) {
templateArgs.emplace_back ( template_arg ( ) ); 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 ) ); 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 ) { ...@@ -223,7 +228,12 @@ void Parser::out_redirect_file ( std::shared_ptr < StatementList > & list ) {
match ( cli::Lexer::TokenType::RIGHT_BRACKET ); 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 ) ) ); list->append ( std::make_unique < ResultFileStatement > ( std::move ( file ), std::move ( fileType ) ) );
} }
   
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment