Search code examples
parsingcomputer-sciencebnfebnf

Are there any modification of BNF with parameters


I mean something like

LISTOF(EL) := "[" EL ("," EL)* "]"
LISTNUM := LISTOF(NUMBER)
LISTID := LISTOF(IDENT)

so, with definitions

NUMBER := ('0'-'9')*
IDENT := ('a'-'z'|'A'-'Z')*

we have following

[435,657,44] is example of LISTNUM,

[dsf,thg,ewre] is example of LISTID.

Or another example (e means empty string)

A(0) := e 
A(n) := "a" A(n-1) | e

so, A(5) is set of all strings consist of 'a' with length not more than 5

Are there any science works describing something similar to this? Can we describe our grammars in such way and still be able to parse it in acceptable time?


Solution

  • The commonly used meta syntaxes such as Bnf, Abnf and Ebnf doesn't have parameterized rules. However Iso Ebnf is extensible as per the standard. If I remember correctly, the standard actually shows an example of introducing parameters.

    You can get the standard here for free.