]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/bin/recomm/recommParser.mly
update in ground
[helm.git] / matita / matita / contribs / lambdadelta / bin / recomm / recommParser.mly
1 %{
2
3   module ET = RecommTypes
4
5   let lc = String.lowercase_ascii
6
7 %}
8
9 %token <string> SP NL OP CP PP SR KW CW HW SW OT
10 %token EF
11
12 %start srcs
13 %type <RecommTypes.srcs> srcs
14
15 %%
16
17 sp:
18   |    { "" }
19   | SP { $1 }
20
21 inn_r:
22   | NL { $1 }
23   | SW { $1 }
24   | OT { $1 }
25
26 inn:
27   | inn_r { $1 }
28   | SP    { $1 }
29   | KW    { $1 }
30   | CW    { $1 }
31   | HW    { $1 }
32
33 inns_r:
34   | inn_r      { $1      }
35   | inn_r inns { $1 ^ $2 }
36
37 inns:
38   | inn      { $1      }
39   | inn inns { $1 ^ $2 }
40
41 out:
42   | SP { $1 }
43   | SR { $1 }
44   | KW { $1 }
45   | CW { $1 }
46   | HW { $1 }
47   | SW { $1 }
48   | OT { $1 }
49
50 outs:
51   | out      { $1      }
52   | out outs { $1 ^ $2 } 
53
54 cc:
55   | CW { $1 }
56   | OT { $1 }
57
58 cw:
59   | cc    { $1      }
60   | cc cw { $1 ^ $2 }
61
62 cws:
63   |           { []       }
64   | SP        { []       }
65   | SP cw cws { $2 :: $3 }
66
67 sc:
68   | HW { lc $1 }
69   | SW { lc $1 }
70   | OT { $1    }
71
72 sw:
73   | sc    { $1      }
74   | sc sw { $1 ^ $2 }
75
76 sws:
77   |           { []       }
78   | SP        { []       }
79   | SP sw sws { $2 :: $3 }
80
81 src_l:
82   | NL               { ET.Line  $1                     }
83   | OP sp PP inns CP { ET.Mark  $4                     }
84   | OP sp KW inns CP { ET.Key   ($3, $4)               }
85   | OP sp CW cws CP  { ET.Title ($3 :: $4)             }
86   | OP sp HW sws CP  { ET.Slice (lc $3 :: $4)          }
87   | OP sp CP         { ET.Other ($1, $2, $3)           }
88   | OP sp inns_r CP  { ET.Other ($1, $2 ^ $3, $4)      }
89   | OP SR inns CP    { ET.Other ($1, $2 ^ $3, $4)      }
90   | OP SR SR inns CP { ET.Other ($1, $2 ^ $3 ^ $4, $5) }
91   | OP SP SR inns CP { ET.Mark  $4                     }
92
93 src:
94   | outs { ET.Text $1 }
95
96 srcs_l:
97   | EF         { []       }
98   | src_l srcs { $1 :: $2 }
99
100 srcs:
101   | srcs_l     { $1       }
102   | src srcs_l { $1 :: $2 }