I have a fragment of grammar in Yacc notation:
stylesheet
: [ CHARSET_SYM STRING ';' ]?
[S|CDO|CDC]* [ import [ CDO S* | CDC S* ]* ]*
[ [ ruleset | media | page ] [ CDO S* | CDC S* ]* ]*
;
How do I implement this fragment in Irony? I can't find any equivalent of ?
, which means 0 or 1 occurrence in Yacc.
You can use the
BnfTerm.Q
method to represent '?' (0 or 1 occurrences). This was a reasonable design decision since C# does not let you write a custom implementation of the?
operator, unlike+
and*
.From the Non Terminals page on the Irony Wikibook: