home *** CD-ROM | disk | FTP | other *** search
- ArmBob v.2.1 Reference GCW 29/11/94
-
- ----------------- SYNTAX ---------------
-
- Armbob Syntax follows that of C, with some extensions and some omissions.
- Every statement returns a value, including assignment statements.
- This is one of the features of C that gives it its particular flavour.
-
- Comments
- --------
-
- Armbob has two kinds of comment: single- and multi-line. They have
- the same syntax as comments in C++.
-
- Single-line comments are introduced by // and are terminated by the
- end of the line or file.
-
- Multi-line comments start with /* and end with the next */. They are
- not nestable.
-
- Names
- -----
- Blank spaces, tab characters and newlines are ignored in Armbob, except
- in so far as they mark the end of a name. Names must begin with a letter
- of the alphabet, and subsequently must consist of letters of the
- alphabet ('A'-'Z', 'a'-'z'), digits ('0'-'9'), or the underscore
- character '_'. ArmBob also permits '@', '$', '£' and '`' in names.
-
- It may be useful, but it is not mandatory, to use these extra characters
- as prefixes or suffixes on names, to indicate the type of object they
- denote, in the following way
-
- @ for addresses of buffers in memory,
- $ for strings,
- £ for integers or 4-byte words,
- ` for bytes or characters.
-
- This mnemonic convention fits the names for the storage functions
- needed for low-level access. Thus, if s is a string, @(s) denotes
- the integer address at which the contents of s are held. If a is
- an address, $(a) denotes the string at a, terminated by a control
- character, £(a) denotes the word stored at a, and `(a) denotes the
- byte stored at a.
-
- Names may be up to 50 characters long. Program lines may be up to
- 200 characters long.
-
- Grammar
- -------
- The grammar is very similar to that of C.
-
- Syntactic classes (non-terminal symbols) are written in angle
- brackets. Square brackets denote optional items, while '[' and
- ']' denote actual square brackets (terminal symbols). A solidus
- (|) denotes an alternative.
-
- Program ::= [ <Defs> ] <Main_def> [ <Defs> ]
- Defs ::= <Def> [ <Defs> ]
- Def ::= <Class_def> | <Fun_def>
- Class_def ::= class <CName> [ : <CName> ] { <Class_body> }
- Fun_def ::= [ <Cname> :: ] <FName> ( [ <FArgs> ] ) { <Fun_body> }
- Main_def ::= main() { <Fun_body> }
- Class_body ::= <Member> ; [ <Class_body> ]
- Member ::= [static] <Data> | [static] <FName> ( [ <FArgs> ] )
- Data ::= <Variable> [ , <Data> ]
- FArgs ::= <Variable> [ , <FArgs> ]
- Fun_body ::= [ local <Args> ; ] <Statements>
- Statements ::= <Statement> <Statements>
- Statement ::= [ <Single> ] ; | { <Statements> } | <Control>
- Control ::= if ( <Expr> ) <Statement> [ else <Statement> ]
- | while ( <Expr> ) <Statement>
- | do <Statement> while ( <Expr> )
- | repeat <Statement> until ( <Expr> )
- | do <Statement> until ( <Expr> )
- | repeat <Statement> while ( <Expr> )
- | for ( <Expr> ; <Expr> ; <Expr> ) <Statement>
- | switch ( <Expr> ) { <Alternatives> [ default : <Statements> }
- | in <Expr> put { <Items> }
- Single ::= break | continue | return <Expr> | <Expr>
- Items ::= <Expr> ; <Items>
- Alternatives ::= case <Expr> : <Statements> <Alternatives>
- Expr ::= <Expr> , <Expr>
- | <Lval> <Assign> <Expr>
- | <Expr> ? <Expr> : <Expr>
- | <Expr> <Binop> <Expr>
- | <Unop> <Expr>
- | ++ <Lvalue>
- | <Lvalue> ++
- | -- <Lvalue>
- | <Lvalue> --
- | new <Cname> ( [ <Expr> ] )
- | <Expr> ( [ <Expr> ] )
- | <Expr> -> <Fname> ( [ <Expr> ] )
- | <Expr> '[' <Expr> ']'
- | vector { <Components> }
- | enum { <Data> }
- | ( <Expr> )
- | <Variable>
- | <Number>
- | "<String>"
- | '<Character>'
- | nil
- | <Constant>
- Components = <Expr> ; [<Components>]
- Assign ::= = | += | -= | *= | /= | %= | &= | |= | ^= | <<= | >>=
- Binop ::= || | && | '|' | ^ | & | == | != | < | <= | >= | >
- | >> | << | + | - | * | % | /
- Unop ::= - | ! | ~
- Lvalue ::= <Variable> | <Expr> '[' <Expr> ']'
- Number ::= <Decimal>[.<Decimal>] | &<Hexnumber>
- Decimal ::= <Digit><Decimal>
- Hexnumber ::= <Hexdigit><Hexnumber>
- Digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
- Hexdigit ::= a | b | c | d | e | f | <Digit>
- Character ::= <Char> | "
- String ::= <Char><String>
- Char ::= Any ASCII character except ", \ or control codes | \n | \t | \\
- Cname ::= <Identifier>
- Fname ::= <Identifier>
- Variable ::= <Identifier>
- Identifier ::= <Alpha><Alphanum>
- Alphanum ::= <Alpha> | <Digit>
- Alpha ::= [A-Z] | [a-z] | _ | @ | $ | £ | `
-
-
- The differences from C are:
-
- No type declarations in Armbob. Use classes instead.
-
- The use of vectors or methods instead of pointers.
-
- Automatic memory allocation and garbage collection for strings
- and vectors.
-
- The 'in b put { x1; ... xn; }' structure.
-
- The synonym 'repeat' for 'do'.
-
- The use of 'nil' as well as zero as a conditional.
-
- The absence of coercion between integer and real numbers in addition
- and subtraction.
-
- All datatypes are first-class. For example, functions and instance
- objects can be arguments to functions or returned by functions.
-
- --------- END -----------