B: Grammar
The following is an incomplete formal grammar for the bushelscript_en language. The form is similar to BNF:
- Anything inside
<and>refers to a "rule" or "production", i.e., a named grammar element. ::denotes the definition of a rule.- Any non-[
<>()[]|::whitespace] characters occur literally. (and)group elements.- Elements inside
[and]may or may not occur. Whether they occur can alter semantics. - A
|between two elements indicates that either may occur. Which one occurs can alter semantics.
To simplify the grammar, we allow rules to be templates. We write rule R templated on X as R( X ).
For example:
| Source code | Matches <foo>? |
|---|---|
| foo | ✓ |
| bar | ✗ |
| foo bar | ✗ |
| foo baz | ✗ |
| foo bar baz | ✓ |
| foo bar bar baz | ✓ |
Some informal notions are defined in (parentheses). Please note that this only a good approximation of the language syntax, not a complete grammar. Devising one is not a goal at the moment.
The rules are organized more or less top-down.
Meta rules#
As a reminder, to simplify this grammar, we allow rules to be templates, writing rule R templated on X as R( X ). Here are some generally applicable templates we'll use:
Blank#
<blank> applies zero/one (depending on context) or more times between all syntax elements.