-
Notifications
You must be signed in to change notification settings - Fork 24
parsing error for rules with [x] followed by x #41
Copy link
Copy link
Open
Description
Try the following script:
from jsgf import parser, Grammar
rule1 = parser.parse_rule_string('public <test1> = [la] lady;')
rule2 = parser.parse_rule_string('public <test2> = [la] bady;')
grammar = Grammar()
grammar.add_rule(rule1)
grammar.add_rule(rule2)
print(grammar.compile())
matching1 = grammar.find_matching_rules('lady')
matching2 = grammar.find_matching_rules('bady')
print('Matching "lady":', matching1)
print('Matching "bady":', matching2)The output will show the following:
#JSGF V1.0;
grammar default;
public <test1> = [la] lady;
public <test2> = [la] bady;
Matching "lady": []
Matching "bady": [Rule(name='test2', visible=True, expansion=Sequence(OptionalGrouping(Literal('la')), Literal('bady')))]
Notice that the string "lady" is not matched by the grammar, even though rule test1 expands to it.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels