2.3.18. - Grammar Rules
This syntax summary defines how all the built-in keywords, operators and commands of spec can be combined. These grammar rules are similar to those given in standard C-language manuals. Operators are listed in order of precedence, with the highest precedence operators listed first.
The following terms are used in the grammar rules:
lvalue |
- | "Left value", something on the left side of an equals sign. |
binop |
- | A binary operator (+, -, etc.). |
asgnop |
- | An assignment operator (=, +=, etc.). |
assoc-array |
- | An associative (original-style) array. |
assoc-elem-list |
- | A space- or comma-separated list of associative array elements. |
identifier |
- | A variable. |
identifier-list |
- | A space- or comma-separated list of identifiers. |
pattern |
- | An alphanumeric string possibly containing the metacharacters ? or * . |
pattern-list-opt |
- | An optional space-separated list of patterns. |
expression-list |
- | A comma-separated list of expressions. |
expr-opt |
- | An optional expression. |
; |
- | A semicolon or a newline. (A semicolon after a statement is optional if the statement is followed by a newline.) |
Note, that in the following list, the entry
expression in assoc-arrayis included in the rules of what constitutes an expression. This is a special expression that evaluates to nonzero (or true ) if
assoc-array[
expr]
is an existing element of the array, and
zero (or
false ) otherwise.
For a two-dimensional associative array,
expr1 in assoc-array[expr2]is nonzero if
assoc-array[
expr2]
[
expr1]
is an element of the array.
These are the grammar rules:
expression: lvalue numeric-constant string-constant(
expression)
function(
expression-list)
-
expression!
expression~
expression++
lvalue--
lvalue lvalue++
lvalue--
expression?
expression:
expression expression binop expression expressionin
assoc-array lvalue asgnop expression expression,
expression expression expression
lvalue: identifier identifier[
expression]
identifier[
expression]
[
expression]
binop:* / %
+ -
>> <<
> < <= >=
== !=
&
^
|
&&
||
asgnop:
= += -= *= /= %= >>= <<= &= ^= |=
data-array-type string byte ubyte short ushort long ulong long64 ulong64 float double
data-array-declaration:array
identifier[
expression]
data-array-typearray
identifier[
expression]
array
identifier[
expression][
expression]
data-array-typearray
identifier[
expression][
expression]
compound-statement:{
statement-list}
statement-list: statement statement statement-list
statement: compound-statement expression ; if ( expression ) statement if ( expression ) statement else statement while ( expression ) statement for ( expr-opt ; expr-opt ; expr-opt ) statement for ( identifier in assoc-array ) statement break ; continue ; exit ; history expr-opt ; lscmd pattern-list-opt ; print expression-list ; global identifier-list ; constant identifier expression ; constant identifier = expression ; unglobal identifier-list ; delete assoc-elem-list ; delete assoc-array ; local identifier-list ; syms pattern-list-opt ; data-array-declaration ; local data-array-declaration ; global data-array-declaration ; shared data-array-declaration ; extern shared data-array-declaration ; def identifier string-constant ; rdef identifier expression ; undef identifier-list ; prdef pattern-list-opt ; lsdef pattern-list-opt ; memstat ; savstate ; reconfig ; getcounts ; move_all ; move_cnt ; sync ;