jocaml-ambients.opp.exp 1.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
%{
open Syntax;;
%}
%start main
%token ZERO
%token <string> STRING
%token SEMISEMI
%token RPOINT
%token RPAREN
%token RBRACKET
%token OUT
%token OPEN
%token NEW
%token LPOINT
%token LPAREN
%token LBRACKET
%token IN
%token <string> IDENT
%token PAR
%token BANG
%token DOT
%token DOLLAR
%right PAR 
%nonassoc BANG 
%right DOT 
%nonassoc DOLLAR 
%type <Syntax.process> main
%%

main:
| proc SEMISEMI
    { $1 }

proc:
| proc PAR proc
    { Par ($1, $3) }
| LPAREN proc RPAREN
    { $2 }
| capa DOT proc
    { Seq ($1, $3) }
| DOLLAR ident LBRACKET proc RBRACKET
    { Amb ($2, $4, true) }
| ident LBRACKET proc RBRACKET
    { Amb ($1, $3, false) }
| NEW str DOT proc
    { New ($2, $4) }
| BANG proc
    { Bang $2 }
| LPAREN str RPAREN DOT proc
    { Comm_in ($2, $5) }
| LPOINT capa RPOINT
    { Comm_out $2 }
| ZERO
    { Zero }

capa:
| IN ident
    { In $2 }
| OUT ident
    { Out $2 }
| OPEN ident
    { Open $2 }
| ident
    { Name $1 }
| STRING
    { Yell $1 }
| capa DOT capa
    { Seq_capa ($1, $3) }

ident:
| IDENT
    { Ident $1 }

str:
| IDENT
    { $1 }

%%