cime-parameterized-signatures.opp.exp 2.37 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
%{

  open Parameterized_signatures
  open Parameterized_signatures_syntax
  
%}
%start cword_eof
%start rules_eof
%start signature_eof
%token SEMICOLON
%token RPAR
%token POWER
%token PIPE
%token LPAR
%token <string> IDENT
%token FP
%token <string> FORMULA
%token EOF
%token ARROW

%type <Parameterized_signatures_syntax.constrained_word> cword_eof
%type <Parameterized_signatures_syntax.rules> rules_eof
%type <Parameterized_signatures_syntax.signature> signature_eof
%%

signature_eof:
27 28 29 30
| _1 = EOF
    {        ([])}
| _1 = signature _2 = EOF
    {                  (_1)}
31 32

signature:
33 34 35 36 37 38
| _1 = elt
    {        ([_1])}
| _1 = elt _2 = SEMICOLON
    {                  ([_1])}
| _1 = elt _2 = SEMICOLON _3 = signature
    {                            (_1::_3)}
39 40

elt:
41 42 43 44
| _1 = IDENT _2 = expr_l
    {      (_1,_2,Abstract_constraint.True)}
| _1 = IDENT _2 = expr_l _3 = PIPE _4 = constr
    {      (_1,_2,_4)}
45 46

cword_eof:
47 48
| _1 = cword _2 = EOF
    {              (_1)}
49 50

cword:
51 52 53 54
| _1 = word
    {      ( (_1,Abstract_constraint.True) )}
| _1 = word _2 = PIPE _3 = constr
    {      ( (_1,_3) )}
55 56 57

word:
| 
58 59 60 61 62
    {    ( [] )}
| _1 = factor _2 = word
    {    ( _1::_2 )}
| _1 = simple_word _2 = word_no_simple
    {    ( Simple(_1)::_2 )}
63 64 65

word_no_simple:
| 
66 67 68
    {    ( [] )}
| _1 = factor _2 = word
    {    ( _1::_2 )}
69 70

factor:
71 72 73 74 75 76 77 78
| _1 = letter _2 = POWER _3 = expr
    {      ( Exp([_1],_3) )}
| _1 = LPAR _2 = simple_word _3 = RPAR _4 = POWER _5 = expr
    {      ( Exp(_2,_5) )}
| _1 = FP _2 = FORMULA _3 = expr _4 = expr _5 = LPAR _6 = simple_word _7 = RPAR
    {      ( Product(_2,_3,_4,_6) )}
| _1 = FP _2 = FORMULA _3 = expr _4 = expr _5 = letter
    {      ( Product(_2,_3,_4,[_5]) )}
79 80

simple_word:
81 82 83 84
| _1 = letter
    {      ( [_1] )}
| _1 = simple_word _2 = letter
    {      ( _1@[_2] )}
85 86

letter:
87 88
| _1 = IDENT _2 = expr_l
    {      ( (_1,_2) )}
89 90

rules_eof:
91 92
| _1 = rules _2 = EOF
    {      ( _1 )}
93 94 95

rules:
| 
96 97 98 99 100
    {      ( [] )}
| _1 = rule
    {      ( [_1] )}
| _1 = rule _2 = SEMICOLON _3 = rules
    {      ( _1 :: _3 )}
101 102

rule:
103 104 105 106
| _1 = word _2 = ARROW _3 = word _4 = PIPE _5 = constr
    {      ( (_1,_3,_5) )}
| _1 = word _2 = ARROW _3 = word
    {      ( (_1,_3,Abstract_constraint.True) )}
107 108 109

expr_l:
| 
110 111 112
    {      ( [] )}
| _1 = expr _2 = expr_l
    {      ( _1::_2 )}
113 114

expr:
115 116
| _1 = FORMULA
    {            (Poly_syntax.expr_of_string _1)}
117 118

constr:
119 120
| _1 = FORMULA
    {            (Poly_syntax.constraint_of_string _1)}
121 122 123 124 125

%%