문제

I have the following 2 production rules in EBNF:

<CharLiteral> ::= ' " ' [ <Printable> ] ' " '

and

<StringLiteral> ::= ' " ' { <Printable> } ' " '

What is the difference between the two? [] imply 1 or more repetitions and {} imply 0 or more repetitions?

도움이 되었습니까?

해결책

In EBNF, [X] means 0 or 1 X and {X} means 0 or more X.

In JavaCC, [X] means 0 or 1 X for grammar productions; in regular expression productions, you should use (X)? instead. To express 0 or more X in JavaCC use (X)*.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top