bauer.opp.exp 1.88 KB
Newer Older
1
2
3
4
5
6
7
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 COMMA
8
9
10
11
12
13
14
%token DOT
%token EOF
%token <string> IDENTIFIER
%token INFERS
%token LPARENT
%token RPARENT
%token <string> VARIABLE
15
16
17
18
%type <Prolog.clause list> clauses
%%

option_params_:
19
  
20
    {    ( None )}
21
| x = params
22
    {    ( Some x )}
23

24
loption_separated_nonempty_list_COMMA_term__:
25
  
26
    {    ( [] )}
27
| x = separated_nonempty_list_COMMA_term_
28
    {    ( x )}
29

30
loption_separated_nonempty_list_DOT_clause__:
31
  
32
    {    ( [] )}
33
| x = separated_nonempty_list_DOT_clause_
34
    {    ( x )}
35

36
37
38
39
40
41
separated_nonempty_list_COMMA_term_:
  x = term
    {    ( [ x ] )}
| x = term _2 = COMMA xs = separated_nonempty_list_COMMA_term_
    {    ( x :: xs )}

42
separated_nonempty_list_DOT_clause_:
43
  x = clause
44
45
46
    {    ( [ x ] )}
| x = clause _2 = DOT xs = separated_nonempty_list_DOT_clause_
    {    ( x :: xs )}
47

48
49
50
51
52
53
54
clauses:
  xs0 = loption_separated_nonempty_list_DOT_clause__ _2 = EOF
    {let clauses =
  let xs = xs0 in
      ( xs )
in
                                                     ( clauses )}
55
56

clause:
57
  tm = term _2 = INFERS xs0 = loption_separated_nonempty_list_COMMA_term__
58
59
    {let ts =
  let xs = xs0 in
60
      ( xs )
61
in
62
                                                        ( (tm, ts) )}
63
| fact = term
64
    {                 ( (fact, []) )}
65

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
term:
  name = IDENTIFIER p = option_params_
    {                                        ( 
    let ts = match p with None -> [] | Some l -> l in
      Struct (name, ts)
  )}
| v = VARIABLE
    {                 ( Var (0, v) )}

params:
  _10 = LPARENT xs00 = loption_separated_nonempty_list_COMMA_term__ _30 = RPARENT
    {let terms =
  let _3 = _30 in
  let xs0 = xs00 in
  let _1 = _10 in
  let x =
    let xs = xs0 in
        ( xs )
  in
      ( x )
in
         ( terms )}

89
90
91
%%