buzz_syntax_bnf_specification

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
buzz_syntax_bnf_specification [2016/04/08 15:13] rootbuzz_syntax_bnf_specification [2016/04/10 00:15] (current) – removed ilpincy
Line 1: Line 1:
-====== Buzz Syntax BNF Specification ====== 
  
-===== Tokens ===== 
- 
-An **identifier** in Buzz is defined by this regular expression: 
- 
-  [[:alpha:]_][[:alnum:]_]* 
- 
-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''        | 
- 
-===== Grammar ===== 
- 
-  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> | TOKDOT idref TOKASSIGN expression | TOKDOT TOKCONST TOKASSIGN expression | assignmentlist TOKLISTSEP assignmentlist 
- 
-  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.1460128430.txt.gz
  • Last modified: 2016/04/08 15:13
  • by root