Closed TheresaSchmidt closed 5 years ago
thanks theresa.
can you try putting the tag earlier in grammar b? (between brauche
and ich
?) I'm surprised it doesn't work, I really would have thought it should.
As for the other versions:
input
does not know the rule term_z
.)also, can you try to do this without underscores?
Thanks for the quick answer. Unfortunately, neither moving the tag around nor omitting the underscore changes anything.
Oh, I work on Windows 7 if that matters...
Hi, I have looked at grammar B. The problem is that you do not define a tag for the rule $input = $zutaten
, and therefore DialogOS will simply return the matched input string for $input
.
A variant of grammar B that works as you intended looks as follows (note the {$ = $zutaten}
in the rule for $input = $zutaten
):
root $input;
$input = $zutaten {$ = $zutaten} | Hallo Welt ;
$zutaten = Wie viel $term_z brauche ich {$=$term_z} ;
$term_z = Milch | Zucker ;
I have clarified the documentation on the Wiki page for grammars.
@timobaumann already explained why grammars A and C should not be expected to behave as you intended.
I hope this helps you. If not, feel free to reopen the issue.
Happy new year!
Hi, I have an issue with the use of tags in grammars. I found out that tags are only recognized as such if they are used in the extension of the start symbol of the grammar. However, if you want to use variables (non-terminals) as value of the tag, the tag has to be used in the same line as the variable.
The following example grammars illustrate the problem. I also include the dialog in which I tested the grammars. Beispiel Tags.zip
In Grammar A and C for the input "Hallo Welt" I get "Hallo Welt" as output of the grammar (as expected). For "Wie viel Milch brauche ich" and "Wie viel Zucker brauche ich" I get the following error message:
In Grammar B the output of the grammar equals its input. However, I would expect to get "Zucker" as output for the input "Wie viel Zucker brauche ich". The tag seems to be ignored in the evaluation of the grammar.
Grammar A:
Grammar B:
Grammar C: