Grammar of OIL

1. BNF of OIL

start: unit
     ;

unit: unit function 
    | 
    ;

function: IDENT args '' 
        ;

args: '(' ')' 
    | '(' ident_list ')' 
    ;

ident_list: IDENT    
          | IDENT ',' ident_list
          ;

stmt_list: stmt_list stmt ';' 
         | stmt_list label 
         |    
         ;

label: IDENT ':'
     ;
      

stmt: IF '(' operand ')' GOTO IDENT
    | RETURN operand
    | GOTO IDENT
    | expr
    ;

expr: IDENT args
    | ind_access '=' rhs
    | IDENT '=' rhs
    ;

ind_access : '*' '(' operand')'
           ;

rhs : operand   
    | operand bin_op operand 
    | un_op operand
    | IDENT args   
    | ind_access    
    ;

un_op: '~'                              
     | '-'                              
     ;
            
bin_op: '+'                             
      | '-'                             
      | '*'                             
      | '/'                             
      | '&'                             
      | '|'                             
      | '<'                             
      | '>'                             
      | '<=' 
      | '>='
      | '!='
      | '==' 
      ;

operand: IDENT       /* identifier */                    
       | NUMBER      /* number */ 
       ; 

Back.