# EBNF dialect used in the Racket docs

Hi,

Is there somewhere a description of the subj?

1 Like

The documentation search-bar is your friend, if I understood the question correctly:
scribble/bnf

Edit, clarification:

I've seen this. It's a utility package, but I want just a formal definition of the grammar notation used throughout the docs. It should be one of the first entries in the Reference, but I can't see it.

It might be in "Notation for Documentation" https://docs.racket-lang.org/reference/notation.html

Okay, I see, I jumped the shark.

I'm not sure, but racketgrammar might be a pointer in the right direction if I am reading the tea-leaves properly:

Extended BNF is loosely defined, derived from Backus-Naur Form (https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form). While a Wikipedia entry exists for EBNF (https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form), you will find many authors using slightly different variants.

[[ In essence, a BNF definition is merely a CS reinvention of inductive definitions. For example, you may see expressions defined like this:

e = n | (+ e e) | (* e e)
n is a natural number

which denotes

e is either
— a natural number,
— a sequence of the tokens “(“, “+”, followed by two e and the token “)”
— a sequence of the tokens “(“, “*”, followed by two e and the token “)”
and nothing else. (This is an important, often omitted part.)

A mathematician or a logician will recognize this as a system of two equations over sets to be solved in e and n. The solution we usually use is the least fix point in the lattice of all sets that extend n appropriately. ]]

2 Likes

This is an answer to a slightly different question .

1. With this (taken from a book on LLVM) I feel right at home. Good ol' Wirth, only he used = instead of :, [] instead of ()?, {} instead of ()*, and . instead of ;. Also Wirth used a{a} instead of ()+. I don't have to consult any appendices to get it. Nonetheless, they devote a whole paragraph to explain the following:
calc : ("with" ident ("," ident)* ":")? expr ;
expr : term (( "+" | "-" ) term)* ;
term : factor (( "*" | "/") factor)* ;
factor : ident | number | "(" expr ")" ;
ident : ([a-zAZ])+ ;
number : ([0-9])+ ;
1. On the other hand, I feel a bit uncomfortable when I see ... vs ...+, wonder whether this or that is a grammar identifier or a keyword, or have to guess whether those parentheses are literal or belong to the EBNF notation. There should be a page with an exhaustive definition of the notation used throughout the docs.

Yes, the link above (2 Notation for Documentation) is the answer we have.