Skip to content

Commit

Permalink
Fix endless loop when parsing invalid nested rules (fixes #144)
Browse files Browse the repository at this point in the history
  • Loading branch information
TinoDidriksen committed Jul 9, 2024
1 parent b25c871 commit 1c8c32a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/GrammarApplicator_runRules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1894,7 +1894,7 @@ uint32_t GrammarApplicator::runRulesOnSingleWindow(SingleWindow& current, const
splitMappings(mappings, *get_apply_to().cohort, *get_apply_to().subreading, true);
}
if (wf && wf != get_apply_to().subreading->parent->wordform) {
for (auto r : get_apply_to().subreading->parent->readings) {
for (auto r : get_apply_to().subreading->parent->readings) {
delTagFromReading(*r, get_apply_to().subreading->parent->wordform);
addTagToReading(*r, wf);
}
Expand Down
4 changes: 3 additions & 1 deletion src/TextualParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,9 @@ void TextualParser::parseRule(UChar*& p, KEYWORDS key) {
AST_OPEN(RuleSubrules);
result->lines += SKIPWS(p);
do {
maybeParseRule(p);
if (!maybeParseRule(p)) {
error("%s: Error: Expected rule on line %u near `%S`!\n", p);
}
result->lines += SKIPWS(p, '}', ';');
if (*p == ';') {
++p;
Expand Down

0 comments on commit 1c8c32a

Please sign in to comment.