bauer.opp.exp 1.88 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Warning: you are using the standard library and/or the %inline keyword. We
recommend switching on --infer in order to avoid obscure type error messages.
%{
  open Prolog
%}
%start clauses
%token <string> VARIABLE
%token RPARENT
%token LPARENT
%token INFERS
%token <string> IDENTIFIER
%token EOF
%token DOT
%token COMMA

%type <Prolog.clause list> clauses
%%

clauses:
20
| xs0 = loption_separated_nonempty_list_DOT_clause__ _2 = EOF
21 22
    {let clauses =
  let xs = xs0 in
23
      ( xs )
24
in
25
                                                     ( clauses )}
26 27 28

term:
| name = IDENTIFIER p = option_params_
29
    {                                        ( 
30 31
    let ts = match p with None -> [] | Some l -> l in
      Struct (name, ts)
32
  )}
33
| v = VARIABLE
34
    {                 ( Var (0, v) )}
35 36

params:
37
| _10 = LPARENT xs00 = loption_separated_nonempty_list_COMMA_term__ _30 = RPARENT
38
    {let terms =
39
  let _3 = _30 in
40
  let xs0 = xs00 in
41
  let _1 = _10 in
42 43
  let x =
    let xs = xs0 in
44
        ( xs )
45
  in
46
      ( x )
47
in
48
         ( terms )}
49 50 51

option_params_:
| 
52
    {    ( None )}
53
| x = params
54
    {    ( Some x )}
55 56 57

loption_separated_nonempty_list_DOT_clause__:
| 
58
    {    ( [] )}
59
| x = separated_nonempty_list_DOT_clause_
60
    {    ( x )}
61 62 63

loption_separated_nonempty_list_COMMA_term__:
| 
64
    {    ( [] )}
65
| x = separated_nonempty_list_COMMA_term_
66
    {    ( x )}
67 68 69

separated_nonempty_list_DOT_clause_:
| x = clause
70 71 72
    {    ( [ x ] )}
| x = clause _2 = DOT xs = separated_nonempty_list_DOT_clause_
    {    ( x :: xs )}
73 74 75

separated_nonempty_list_COMMA_term_:
| x = term
76 77 78
    {    ( [ x ] )}
| x = term _2 = COMMA xs = separated_nonempty_list_COMMA_term_
    {    ( x :: xs )}
79 80

clause:
81
| tm = term _2 = INFERS xs0 = loption_separated_nonempty_list_COMMA_term__
82 83
    {let ts =
  let xs = xs0 in
84
      ( xs )
85
in
86
                                                        ( (tm, ts) )}
87
| fact = term
88
    {                 ( (fact, []) )}
89 90 91 92 93

%%