Changes between Version 7 and Version 8 of CIVLite


Ignore:
Timestamp:
09/22/23 07:37:22 (3 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CIVLite

    v7 v8  
    99No boolean type.  Instead, int is used.   0 is false, every other int is true (like C).
    1010
    11 Parameters have a value that is fixed for the lifetime of the program.  They can be
    12 hard coded into the program, or set on command line, like CIVL's $input variables.
     11Parameters have a value that is fixed for the lifetime of the program.
     12They don't go in the state.
     13They can be hard coded into the program, or set on command line, like CIVL's $input variables.
    1314
    1415There is a global scope and a local scope for each function.  That's it.
     
    1617No need to "declare" a function before it is used.   There is no notion of a function declaration.
    1718
    18 print?
    19 
    2019Grammar:
    2120
    2221{{{
     22constant: INT | 'null' | '{' (constant (',' constant)*)? '}'
     23string: '"' .* '"'
     24type: 'int' | 'proc' | type[] | 'void'
     25typedvar: type ID
     26paramdecl: 'param' typedvar ('=' constant)? ';'
     27vardecl: 'var' typedvar ';'
     28formallist: typedvar (',' typedvar)*
     29function: 'fun' type ID '(' formallist? ')' '{' (typedvar ';')* transition* '}'
    2330
    24 constant: INT | 'null' | '{' (constant (',' constant)*)? '}'
     31// OOPS I messed this up.   Need to have multiple transitions departing from
     32// one location....
    2533
    26 string: '"' .* '"'
    27 
    28 type: 'int' | 'proc' | type[]
    29 
    30 typedvar: type ID
    31 
    32 paramdecl: 'param' typedvar ('=' constant)? ';'
    33 
    34 vardecl: 'var' typedvar ';'
    35 
    36 formallist: typedvar (',' typedvar)*
    37 
    38 function: 'fun' type ID '(' formallist? ')' '{' (typedvar ';')* transition* '}'
    3934
    4035transition: (ID ':')? ('when' expr)? action ('goto' ID ';')?
     
    4439
    4540action: assignment call spawn noop return wait begin_atomic end_atomic assertion print
    46 
    4741assignment: lval '=' expr ';'
    48 
    4942invocation: ID '(' exprlist? ')'
    50 
    5143call: (lval '=')? 'call' invocation ';'
    52 
    5344spawn: (lval '=')? 'spawn' invocation ';'
    54 
    5545noop: ';'
    56 
    5746return: 'return' expr? ';'
    58 
    5947wait : 'wait' expr ';'
    60 
    6148begin_atomic: 'begin_atomic' ';'
    62 
    6349end_atomic: 'end_atomic' ';'
    64 
    6550assertion: 'assert' expr ';'
    66 
    6751print: 'print' exprstrlst ';'
    68 
    6952exprstrlst: exprstr (',' exprstr)*
    70 
    7153exprstr: expr | string
    72 
    7354exprlist: expr (',' expr)*
    74 
    7555lval: ID | lval '[' expr ']'
    7656
     
    7858  | 'array' '(' type ',' expr ',' expr ')' // array(element-type, length, value)
    7959
     60program: paramdecl* vardecl* function*
     61}}}
    8062
    81 program: paramdecl* vardecl* function*
    82 
    83 Example:
    84 
     63Array example:
     64{{{
    8565fun int[][] %zero2d(int %n, int %m) {
    8666  int[][] %a;
     
    8868  return %a;
    8969}
    90 
    9170}}}
    9271
     72Example: two threads are generated and go through a barrier:
     73{{{
     74int %s[];
     75fun void %thread(int %id) {
     76  print "Hello from thread ", %id, "\n";
     77  when %id==0 %s[0]=1; goto L1;
     78 
     79}
     80}}}