buzz_syntax_bnf_specification

This is an old revision of the document!


Buzz Syntax BNF Specification

An identifier in Buzz is any sequence of alphanumeric characters starting with a letter or an underscore (_). The recognized tokens are:

Token Id
_identifier_ TOKID
_numeric constant_ TOKCONST
'_string_' _string_ TOKSTRING
var TOKVAR
nil TOKNIL
if TOKIF
else TOKELSE
function TOKFUN
return TOKRETURN
for TOKFOR
while TOKWHILE
and, or TOKANDOR
not TOKNOT
+, - TOKADDSUB
*, / TOKMULDIV
% TOKMOD
^ TOKPOW
{ TOKBLOCKOPEN
} TOKBLOCKCLOSE
( TOKPAROPEN
) TOKPARCLOSE
[ TOKIDXOPEN
] TOKIDXCLOSE
; \n TOKSTATEND
, TOKLISTSEP
= TOKASSIGN
. TOKDOT
< > >= == != TOKCMP
  script             ::= statlist
  statlist           ::= stat | statlist stat
  stat               ::= <nil> | vardef | fundef | if | loop | command
  block              ::= TOKBLOCKOPEN statlist TOKBLOCKCLOSE
  vardef             ::= TOKVAR TOKID | TOKVAR TOKID assignment
  fundef             ::= TOKFUN TOKID TOKPAROPEN idlist TOKPARCLOSE block
  if                 ::= TOKIF TOKPAROPEN condition TOKPARCLOSE block endif
  endif              ::= <nil> |  TOKELSE block
  loop               ::= forloop | whileloop
  forloop            ::= TOKFOR TOKPAROPEN idref TOKASSIGN expression TOKLISTSEP
                         condition TOKLISTSEP idref TOKASSIGN expression TOKPARCLOSE block
  whileloop          ::= TOKWHILE TOKPAROPEN condition TOKPARCLOSE block
  conditionlist      ::= condition | conditionlist TOKLISTSEP condition
  condition          ::= comparison | condition TOKANDOR comparison
  comparison         ::= TOKPAROPEN condition TOKPARCLOSE | NOT comparison | expression | expression TOKCMP expression
  expression         ::= product | expression TOKADDSUB product
  product            ::= modulo | product TOKMULDIV modulo
  modulo             ::= power | modulo TOKMOD power
  power              ::= operand powerrest
  powerrest          ::= <nil> | TOKPOW power
  operand            ::= TOKNIL | TOKBLOCKOPEN assignmentlist TOKBLOCKCLOSE | TOKCONST | TOKSTRING | TOKPAROPEN expression TOKPARCLOSE | TOKADDSUB power | idref | lambda
  command            ::= idref | idref assignment | TOKRETURN expression
  assignment         ::= TOKASSIGN expression
  assignmentlist     ::= <nil> | idref assignment | assignmentlist TOKLISTSEP idref assignment
  idlist             ::= <nil> | TOKID | idlist TOKLISTSEP TOKID
  idreflist          ::= idref | idreflist TOKLISTSEP idref
  idref              ::= TOKID | idref TOKDOT TOKID | idref TOKIDXOPEN expression TOKIDXCLOSE | idref TOKPAROPEN conditionlist TOKPARCLOSE
  lambda             ::= TOKFUN TOKPAROPEN idlist TOKPARCLOSE block
  • buzz_syntax_bnf_specification.1438031407.txt.gz
  • Last modified: 2015/07/27 21:10
  • by ilpincy