SRDIO - Memory target can ignore comments

This commit is contained in:
Emmanuel BENOîT 2017-11-06 10:53:54 +01:00
parent 073fcb3d5e
commit 3adfdadd11
3 changed files with 40 additions and 8 deletions

View file

@ -126,6 +126,7 @@ void T_SRDListFixer::end(
T_SRDMemoryTarget::T_SRDMemoryTarget( bool structured )
: structured_( structured ) ,
clearFlushToken_( false ) ,
clearComments_( false ) ,
list_( T_SRDToken::List( T_SRDList( ) ) ) ,
stack_( 128 )
{ }
@ -141,6 +142,8 @@ void T_SRDMemoryTarget::push( T_SRDErrors& errors , T_SRDToken&& token )
assert( current_ != nullptr );
const auto tt( token.type( ) );
// Handle list starts
if ( tt == E_SRDTokenType::START ) {
if ( structured_ ) {
auto& c( current_->list( ) );
@ -156,8 +159,11 @@ void T_SRDMemoryTarget::push( T_SRDErrors& errors , T_SRDToken&& token )
l.add( std::move( token ) );
stack_.add( &( l[ l.size( ) - 1 ] ) );
}
return;
}
} else if ( tt == E_SRDTokenType::END ) {
// Handle list ends
if ( tt == E_SRDTokenType::END ) {
if ( stack_.size( ) == 0 ) {
errors.add( "unexpected ')'" , token );
} else {
@ -169,10 +175,18 @@ void T_SRDMemoryTarget::push( T_SRDErrors& errors , T_SRDToken&& token )
}
stack_.remove( last );
}
} else if ( tt != E_SRDTokenType::FLUSH || !clearFlushToken_ ) {
current_->list( ).add( std::move( token ) );
return;
}
// Ignore flushes and comments if requested
if ( tt == E_SRDTokenType::FLUSH && clearFlushToken_ ) {
return;
}
if ( tt == E_SRDTokenType::COMMENT && clearComments_ ) {
return;
}
current_->list( ).add( std::move( token ) );
}
void T_SRDMemoryTarget::end( T_SRDErrors& errors )