简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM