Skip to content
Snippets Groups Projects
Commit b74adc1e authored by Tomáš Pecka's avatar Tomáš Pecka Committed by Jan Trávníček
Browse files

Hotfix/Hack for #95

parent 9a3bae7e
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -31,7 +31,22 @@ grammar::RightRG < SymbolType > stringApi < grammar::RightRG < SymbolType > >::p
if(token.type != grammar::GrammarFromStringLexer::TokenType::RIGHT_RG)
throw exception::CommonException("Unrecognised RightRG token.");
 
return grammar::GrammarFromStringParserCommon::parseCFLikeGrammar < grammar::RightRG < SymbolType > > ( input );
grammar::RightRG < SymbolType > g = grammar::GrammarFromStringParserCommon::parseCFLikeGrammar < grammar::RightRG < SymbolType > > ( input );
if ( g.getGeneratesEpsilon( ) ) {
for ( const auto& rule : g.getRules ( ) ) {
const ext::set < ext::variant < SymbolType, ext::pair < SymbolType, SymbolType > > >& rhsSet = rule.second;
for ( const auto& elem : rhsSet ) {
if ( elem.template is < ext::pair < SymbolType, SymbolType > > ( ) ) {
const ext::pair < SymbolType, SymbolType > & rhs = elem.template get < ext::pair < SymbolType, SymbolType > > ( );
if ( g.getInitialSymbol ( ) == rhs.second )
throw exception::CommonException("Init on RHS when generate eps");
}
}
}
}
return g;
}
 
template<class SymbolType >
......
......@@ -61,7 +61,7 @@ void GrammarTest::stringParserTest() {
"{a, b},\n"
"{ A -> a | a A,\n"
" B -> b | b B,\n"
" S -> | a A | a S | b B},\n"
" S -> | a A | b A | b B},\n"
"S)\n";
grammar::Grammar grammar = alib::StringDataFactory::fromString (input);
 
......
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