4.23 The Syntax in BNF
This section contains the definition of the GAP syntax in Backus-Naur
form. A few recent additions to the syntax may be missing from this definition.
A BNF is a set of rules, whose left side is the name of a syntactical
construct. Those names are enclosed in angle brackets and written in
italics. The right side of each rule contains a possible form for that
syntactic construct. Each right side may contain names of other
syntactic constructs, again enclosed in angle brackets and written in
italics, or character sequences that must occur literally; they are
written in typewriter style.
Furthermore each righthand side can contain the following metasymbols
written in boldface. If the right hand side contains forms separated
by a pipe symbol ( |) this means that one of the possible forms can
occur. If a part of a form is enclosed in square brackets ([ ]) this
means that this part is optional, i.e. might be present or missing. If
part of the form is enclosed in curly braces ({ }) this means that
the part may occur arbitrarily often, or possibly be missing.
|
<Permutation> |
:= |
`(' <Expr> {`,' <Expr> } `)'
{ `(' <Expr> {`,' <Expr> } `)' } |
|
<Ident> |
:= |
`a'|...|`z'|`A'|...|`Z'|`_'
{`a'|...|`z'|`A'|...|`Z'|`0'|...|`9'|`_'} |
|
|
| |
<Var> `.' `(' <Expr> `)' |
|
|
| |
<Var> `(' [ <Expr> { ,<Expr> } ] `)' |
|
|
| |
<Var> `!.' `(' <Expr> `)' |
|
<List> |
:= |
`[' [ <Expr> ] {`,' [ <Expr> ] } `]' |
|
|
| |
`[' <Expr> [, <Expr> ] `..' <Expr> `]' |
|
<Record> |
:= |
`rec(' [ <Ident> `:=' <Expr>
{`,' <Ident> `:=' <Expr> } ] `)' |
|
<Permutation> |
:= |
`(' <Expr> {`,' <Expr> } `)'
{ `(' <Expr> {`,' <Expr> } `)' } |
|
<Function> |
:= |
`function (' [ <Ident> {`,' <Ident> } ] `)' |
|
|
|
[ `local' <Ident> {`,' <Ident> } `;' ] |
|
<Char> |
:= |
'<any character> ' |
|
<String> |
:= |
`"' { <any character> } `"' |
|
<Int> |
:= |
`0'|`1'|...|`9'
{`0'|`1'|...|`9'} |
|
<Factor> |
:= |
{`+'|`-'} <Atom>
[ `^' {`+'|`-'} <Atom> ] |
|
<Term> |
:= |
<Factor> { `*'|`/'|`mod' <Factor> } |
|
<Arith> |
:= |
<Term> { `+'|`-' <Term> } |
|
<Rel> |
:= |
{ `not' } <Arith>
[ `='|`\<>'|`\<'|`>'|`\<='|`>='|`in' <Arith> ] |
|
<And> |
:= |
<Rel> { `and' <Rel> } |
|
<Logical> |
:= |
<And> { `or' <And> } |
|
|
| |
`if' <Expr> `then' <Statements> |
|
|
|
{ `elif' <Expr> `then' |
<Statements> } |
|
|
|
[ `else' |
<Statements> ] `fi' |
|
|
| |
`for' <Var> `in' <Expr> `do' <Statements> `od' |
|
|
| |
`while' <Expr> `do' <Statements> `od' |
|
|
| |
`repeat' <Statements> `until' <Expr> |
|
<Statements> |
:= |
{ <Statement> `;' } |
[Top] [Previous] [Up] [Index]
GAP 4 manual
February 2000