Skip to content

Grammar

Positron edited this page Mar 3, 2015 · 13 revisions
library:
   region-body
   (empty)

region:
   region region-name { }
   region region-name { region-body }

region-name:
   identifier
   region-name :: identifier

region-body:
   region-item
   region-body region-item

region-item:
   region
   import-statement
   directive
   declaration
   script
   ;

import-statement:
   import import-list ;
   import import-list , import-selection ;
   import import-selection ;

import-list:
   import-item
   import-list , import-item

import-item:
   import-alias path
   import-alias path :: *

import-alias:
   identifier =
   (empty)

import-selection:
   import-alias path : import-selection-list

import-selection-list:
   import-selection-item
   import-selection-list , import-selection-item

import-selection-item:
   import-alias identifier
   import-alias path :: *
   struct import-alias identifier
   enum import-alias identifier
   import-selection-item-deprecated

import-selection-item-deprecated:
   identifier = region
   region = identifier
   region = region

path:
   upmost
   region
   identifier
   path :: identifier

directive:
   # directive-body

// The parsing of the directive body depends on the value of the
// directive name. Below, each rule starts with a specific name.
// The name is in bold, but it is not a keyword.
directive-body:
   include string
   import string
   library string
   encryptstrings
   define
   libdefine
   nocompact
   // Not supported in bcc:
   // - wadauthor
   // - nowadauthor

declaration:
   qualifier storage specifier ;
   qualifier storage specifier variable-list ;
   qualifier storage specifier function
   function qualifier storage specifier function

qualifier:
   static
   (empty)

storage:
   world
   global
   (empty)

storage-index:
   decimal-number :
   (empty)

specifier:
   int
   str
   bool
   void
   enumeration
   structure

enumeration:
   enum { enumerator-list }
   enum { enumerator-list , }

enumerator-list:
   enumerator
   enumerator-list , enumerator

enumerator:
   identifier
   identifier = expression

structure:
   struct { structure-member-list }
   struct identifier { structure-member-list }
   struct path

structure-member-list:
   declaration
   structure-member-list declaration

variable-list:
   variable
   variable-list , variable

variable:
   storage-index identifier dimension initial

dimension:
   dimension-list
   (empty)

dimension-list:
   [ ]
   [ expression ]
   dimension-list [ ]
   dimension-list [ expression ]

initial:
   = expression
   = multi-value
   (empty)

multi-value:
   { multi-value-list }
   { multi-value-list , }

multi-value-list:
   expression
   multi-value
   multi-value-list , expression
   multi-value-list , multi-value

function:
   storage-index identifier ( ) block-statement
   storage-index identifier ( void ) block-statement
   storage-index identifier ( parameter-list ) block-statement

parameter-list:
   parameter
   parameter-list , parameter

parameter:
   parameter-specifier parameter-name
   parameter-specifier parameter-name = expression

parameter-specifier:
   int
   str
   bool

parameter-name:
   identifier
   (empty)

manifest-constant:
   enum identifier = expression ;

script:
   script script-id script-parameter-list script-type
      script-flag statement

script-id:
   << 0 >>
   // Parsing of function calls is ignored in the expression because
   // it conflicts with the start of the parameter list.
   expression

script-parameter-list:
   ( )
   ( void )
   ( parameter-list )
   (empty)

script-type:
   open
   respawn
   death
   enter
   pickup
   bluereturn
   redreturn
   whitereturn
   lightning
   unloading
   disconnect
   return
   event
   (empty)

script-flag:
   script-flag-list
   (empty)

script-flag-list:
   net
   clientside 
   script-flag-list net
   script-flag-list clientside

statement:
   block-statement
   if ( expression ) statement
   if ( expression ) statement else statement
   switch ( expression ) statement
   while ( expression ) statement
   until ( expression ) statement
   do statement while ( expression ) ;
   do statement until ( expression ) ;
   for ( for-initialization for-condition for-increment ) statement
   break ;
   continue ;
   terminate ;
   suspend ;
   restart ;
   return ;
   return expression ;
   return expression := block-statement
   goto identifier ;
   assert-statement
   format-item ;
   palette-translation ;
   inline-assembly
   expression ;
   expression := block-statement
   ;

block-statement:
   { }
   { block-statement-item-list }

block-statement-item-list:
   block-statement-item
   block-statement-item-list block-statement-item

block-statement-item:
   declaration
   identifier :                   
   case expression :
   default :
   import-statement
   statement

for-initialization:
   declaration
   expression-list ;
   ;

for-condition:
   expression ;
   ;

for-increment:
   expression-list
   (empty)

palette-translation:
   createtranslation ( expression )
   createtranslation ( expression , palette-range-list )

palette-range-list:
   palette-range
   palette-range-list , palette-range

palette-range:
   // Parsing of assignments is ignored in the second expression
   // because it conflicts with the assignment token that follows.
   expression : expression = palette-range-value

palette-range-value:
   expression : expression
   [ expression , expression , expression ] :
      [ expression , expression , expression ]

format-item:
   format-cast := expression
   format-item , format-cast := expression

assert-statement:
   assert ( expression ) ;
   assert ( expression , string ) ;
   static assert ( expression ) ;
   static assert ( expression , string ) ;

// The newline character becomes significant for inline-assembly.
// It is the terminating token of a line of inline-assembly code.
inline-assembly:
   > identifier newline
   > identifier inline-assembly-argument-list newline

inline-assembly-argument-list:
   expression
   inline-assembly-argument-list , expression

Keywords

Certain identifiers are reserved by the language and are used in specific ways. They cannot be used as names for your own objects. These identifiers are:

  1. bluereturn
  2. bool
  3. break
  4. case
  5. clientside
  6. const
  7. continue
  8. createtranslation
  9. death
  10. default
  11. disconnect
  12. do
  13. else
  14. enter
  15. enum
  16. false
  17. for
  18. function
  19. global
  20. goto
  21. if
  22. import
  23. int
  24. lightning
  25. net
  26. open
  27. pickup
  28. redreturn
  29. region
  30. respawn
  31. restart
  32. return
  33. script
  34. static
  35. str
  36. struct
  37. suspend
  38. switch
  39. terminate
  40. true
  41. unloading
  42. until
  43. upmost
  44. void
  45. while
  46. whitereturn
  47. world

--

The following identifiers are reserved but are not used:

  1. fixed
  2. special

--

The following identifiers are no longer reserved and can be used as names for your own objects:

  1. acs_executewait
  2. define
  3. encryptstrings
  4. hudmessage
  5. hudmessagebold
  6. include
  7. libdefine
  8. library
  9. log
  10. nocompact
  11. nowadauthor
  12. print
  13. printbold
  14. strcpy
  15. strparam
  16. wadauthor
Clone this wiki locally