Skip to content
Benjamin Kowarsch edited this page Sep 26, 2018 · 6 revisions

GLL EBNF

The notation used to specify grammars is an extended BNF notation, or EBNF.

The syntax of GLL EBNF is described in itself in the GLL grammar file:

gll-grammar.gll

Its semantics are as follows:

Reserved Words

Reserved Words are denoted by all-uppercase names.

Example: FOOBAR

Terminal Symbols

Names that start with a capital letter represent terminal symbols.

Example: Foobar

Non-Terminal Symbols

Names that start with a lowercase letter represent non-terminal symbols.

Example: foobar

Literals

Literals are enclosed in single or double quotes.

Examples: 'foo', "bar"

Literal Ranges

A double-period .. is used between digit or character literals to denote a range.

Example: '0' .. '9'

Rule Definition

The definition symbol := is used between a name of a production rule and its body.

Example: foo := bar ;

Rule Termination

A semicolon ; is used to terminate a production rule.

Example: foo := bar ;

Aliases

Reserved word alias is used as a prefix to denote an alias name definition.

Example: alias foo = bar ;

Fragments

A period . is used as a prefix to denote a fragment definition. Fragments may be used within terminal symbol definitions to inline syntactic entities. Unlike names of terminal symbols, fragment names are not tokens.

Example: .Digit := '0' .. '9' ;

Non-Semantic Symbols

An asterisk * is used as a prefix to denote a non-semantic symbol definition, such as pragmas and comments.

Example: *Comment := '/*' ( AnyChar | Newline )* '*/' ;

Alternatives

A vertical bar | is used to separate logical alternatives.

Example: foo := bar | baz ;

Optional Occurence

A trailing question mark ? is used to denote zero or one occurrence.

Example: foo := bar baz? ;

Non-Empty Repetition

A trailing plus + is used to denote one or more occurrences.

Example: foo := bar baz+ ;

Optional Repetition

A trailing asterisk * is used to denote zero or more occurrences.

Example: foo := bar baz* ;

Grouping
  • Parentheses ( and ) are used to group syntactic entities.
  • A comma , is used to group syntactic entities and to indicate a wrap-around point when generating diagrams.

Examples:

list := foo ( ',' foo )* ;

foo := bar baz, bam | boo ;

Comments

Opening delimiter /* is used to start a comment and closing delimiter */ is used to terminate it.

Example: /* this is a comment */

[END OF FILE]