]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/bin/recomm/recommParser.mly
5686e747effbe3efe959aaf0203f3dc1f33dcbd1
[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 inn_r:
18   | SP { $1 }
19   | NL { $1 }
20   | SW { $1 }
21   | OT { $1 }
22
23 inn:
24   | inn_r { $1 }
25   | KW      { $1 }
26   | CW      { $1 }
27   | HW      { $1 }
28
29 inns_r:
30   | inn_r      { $1      }
31   | inn_r inns { $1 ^ $2 }
32
33 inns:
34   | inn      { $1      }
35   | inn inns { $1 ^ $2 }
36
37 out:
38   | SP { $1 }
39   | SR { $1 }
40   | KW { $1 }
41   | CW { $1 }
42   | HW { $1 }
43   | SW { $1 }
44   | OT { $1 }
45
46 outs:
47   | out      { $1      }
48   | out outs { $1 ^ $2 } 
49
50 sw:
51   | HW { lc $1 }
52   | SW { lc $1 }
53
54 cws:
55   |           { []       }
56   | SP        { []       }
57   | SP CW cws { $2 :: $3 }
58
59 sws:
60   |           { []       }
61   | SP        { []       }
62   | SP sw sws { $2 :: $3 }
63
64 src_l:
65   | NL               { ET.Line  $1                     }
66   | OP PP inns CP    { ET.Mark  $3                     }
67   | OP KW inns CP    { ET.Key   ($2, $3)               }
68   | OP CW cws CP     { ET.Title ($2 :: $3)             }
69   | OP HW sws CP     { ET.Slice (lc $2 :: $3)          }
70   | OP CP            { ET.Other ($1, "", $2)           }
71   | OP inns_r CP     { ET.Other ($1, $2, $3)           }
72   | OP SR inns CP    { ET.Other ($1, $2 ^ $3, $4)      }
73   | OP SR SR inns CP { ET.Other ($1, $2 ^ $3 ^ $4, $5) }
74
75 src:
76   | outs { ET.Text $1 }
77
78 srcs_l:
79   | EF         { []       }
80   | src_l srcs { $1 :: $2 }
81
82 srcs:
83   | srcs_l     { $1       }
84   | src srcs_l { $1 :: $2 }