2

In the ISO 14977 EBNF standard, section 4.7, the legal contents of an exception is described. I'm fairly certain that an exception may consist of any valid syntactic factor, as long that it doesn't contain any meta-identifiers. Which means that could use a special sequence as an exception like this

syntax =
    my rule - ? Something clever ? ;

Is this the case?

You can get the standard for free at ISO here.

Guy Coder
  • 24,501
  • 8
  • 71
  • 136
Uran
  • 141
  • 2
  • 12
  • Yes, that's more or less the case. §4.7 Syntactic exception _A syntactic-exception consists of a syntactic-factor subject to the restriction that the sequences of symbols represented by the syntactic-exception could equally be represented by a syntactic-factor containing no meta-identifiers. NOTE — If a syntactic-exception is permitted to be an arbitrary syntactic-factor, Extended BNF could define a wider class of languages than the context-free grammars, including attempts which lead to Russell-like paradoxes, e.g. `xx="A"-xx;` Is `"A"` an example of `xx`?_ – Jonathan Leffler May 17 '16 at 22:10
  • Is the exception supposed to be the same length in characters as the rule? What happens if the rule starts with an "A" but it's longer? – Jens Jan 26 '17 at 19:37
  • The length of the rule and exception don't have to match. – Uran Feb 08 '17 at 09:16
  • The length of the rule and exception don't have to match. syntax = name - ( "A" | "ABC" ) ; name = letter, { letter } ; Input such as "AB" and "ABCD" is valid, however "A" and "ABC" is not. If the exception is longer than the rule then the input is not valid according to the rule. – Uran Feb 08 '17 at 09:22

1 Answers1

2

No that is not correct. You can use meta-identifiers in an exception as long as when fully evaluated they result in terminals. The example given in section 4.7 shows a meta-identifier defined in terms of itself, which can never fully resolve to a terminal. That is what they mean when they say:

...could equally be represented by a syntactic-factor containing no meta-identifiers.

There are lots of examples of this in the standard itself - checkout section 8. For example:

gap free symbol = terminal character - (first quote symbol | second quote symbol)