home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / a / armbob / doc / Ref / Syntax < prev    next >
Encoding:
Text File  |  1994-06-06  |  4.3 KB  |  122 lines

  1. ArmBob v.1.02 Reference                                GCW 06/06/94
  2.  
  3.          ----------------- SYNTAX ---------------
  4.  
  5. Bob Syntax follows that of C, with some extensions and some omissions.
  6.  
  7. Comments
  8. --------
  9.  
  10. Bob has two kinds of comment: single- and multi-line.
  11.  
  12. Single-line comments are introduced by // and are terminated by the
  13. end of the line or file.
  14.  
  15. Multi-line comments are as in C; that is, they start with /* and end
  16. with the next */. They are not nestable.
  17.  
  18. Names
  19. -----
  20. Blank spaces, tab characters and newlines are ignored in Bob, except 
  21. in so far as they mark the end of a name. Names must begin with a letter 
  22. of the alphabet, and subsequently must consist of letters of the 
  23. alphabet ('A'-'Z', 'a'-'z'), digits ('0'-'9'), or the underscore
  24. character '_'. ArmBob also permits '@', '$', '£' and '`' in names.
  25.  
  26. It may be useful, but it is not mandatory, to use these extra characters
  27. as prefixes or suffixes on names, to indicate the type of object they
  28. denote, in the following way
  29.  
  30.     @    for addresses of buffers in memory,
  31.     $    for strings,
  32.     £    for integers or 4-byte words,
  33.     `    for bytes or characters.
  34.  
  35. This mnemonic convention fits the names for the storage functions
  36. needed for low-level access. Thus, if s is a string, @(s) denotes
  37. the integer address at which the contents of s are held. If a is
  38. an address, $(a) denotes the string at a, terminated by a control
  39. character, £(a) denotes the word stored at a, and `(a) denotes the
  40. byte stored at a. 
  41.  
  42. Names may be up to 50 characters long. Program lines may be up to 
  43. 200 characters long.
  44.  
  45. Grammar
  46. -------
  47. The grammar is very similar to that of C, without type declarations,
  48. coercions or pointer arithmetic.
  49.  
  50. Syntactic classes (non-terminal symbols) are written in angle 
  51. brackets. Square brackets denote optional items, while '[' and 
  52. ']' denote actual square brackets (terminal symbols). A solidus
  53. (|) denotes an alternative.
  54.  
  55. Program ::= [ <Defs> ] <Main_def> [ <Defs> ]
  56. Defs ::= <Def> [ <Defs> ]
  57. Def  ::= <Class_def> | <Fun_def>
  58. Class_def ::= class <CName> [ : <CName> ] { <Class_body> }
  59. Fun_def ::= [ <Cname> :: ] <FName> ( [ <FArgs> ] ) { <Fun_body> }
  60. Main_def ::= main() { <Fun_body> }
  61. Class_body ::=  <Member> ; [ <Class_body> ] 
  62. Member ::= [static] <Data> | [static] <FName> ( [ <FArgs> ] )
  63. Data ::= <Variable> [ , <Data> ]
  64. FArgs ::= <Variable> [ , <FArgs> ]
  65. Fun_body ::= [ local <Args> ; ] <Statements>
  66. Statements ::= <Statement> <Statements>
  67. Statement ::= [ <Single> ] ; | { <Statements> } | <Control>
  68. Control ::= if ( <Expr> ) <Statement> [ else <Statement> ]
  69.           | while ( <Expr> ) <Statement>
  70.           | do <Statement> while ( <Expr> ) 
  71.           | repeat <Statement> until ( <Expr> )
  72.           | do <Statement> until ( <Expr> )
  73.           | repeat <Statement> while ( <Expr> )
  74.           | for ( <Expr> ; <Expr> ; <Expr> ) <Statement>
  75.           | switch ( <Expr> ) { <Alternatives> [ default : <Statements> }
  76.           | in <Expr> put { <Items> }
  77. Single ::= break | continue | return <Expr> | <Expr>
  78. Items ::= <Expr> ; <Items>
  79. Alternatives ::= case <Expr> : <Statements> <Alternatives>
  80. Expr ::= <Expr> , <Expr>
  81.        | <Lval> <Assign> <Expr>
  82.        | <Expr> ? <Expr> : <Expr>
  83.        | <Expr> <Binop> <Expr>
  84.        | <Unop> <Expr>
  85.        | ++ <Lvalue>
  86.        | <Lvalue> ++
  87.        | -- <Lvalue>
  88.        | <Lvalue> --
  89.        | new <Cname> ( [ <Expr> ] )
  90.        | <Expr> ( [ <Expr> ] )
  91.        | <Expr> -> <Fname> ( [ <Expr> ] )
  92.        | <Expr> '[' <Expr> ']'
  93.        | ( <Expr> )
  94.        | <Variable>
  95.        | <Number>
  96.        | "<String>"
  97.        | '<Character>'
  98.        | nil
  99.        | <Constant>
  100. Assign ::= = | += | -= | *= | /= | %= | &= | |= | ^= | <<= | >>=
  101. Binop ::= || | && | '|' | ^ | & | == | != | < | <= | >= | >
  102.         | >> | << | + | - | * | % | /
  103. Unop ::= - | ! | ~ 
  104. Lvalue ::= <Variable> | <Expr> '[' <Expr> ']'
  105. Number ::= <Decimal> | &<Hexnumber>
  106. Decimal ::= <Digit><Decimal>
  107. Hexnumber ::= <Hexdigit><Hexnumber>
  108. Digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
  109. Hexdigit ::= a | b | c | d | e | f | <Digit>
  110. Character ::= <Char> | "
  111. String ::= <Char><String>
  112. Char ::= Any ASCII character except ", \ or control codes | \n | \t | \\
  113. Cname ::= <Identifier>
  114. Fname ::= <Identifier>
  115. Variable ::= <Identifier>
  116. Identifier ::= <Alpha><Alphanum>
  117. Alphanum ::= <Alpha> | <Digit>
  118. Alpha ::= [A-Z] | [a-z] | _ | @ | $ | £ | `
  119.  
  120.  
  121.                                             
  122.              --------- END -----------