Recording as miscellaneous the old way to do series of items.

This commit is contained in:
Christian Rinderknecht 2019-08-29 17:09:43 +02:00
parent 95b2111a8b
commit 3f47bb2e85

View File

@ -0,0 +1,27 @@
(* The rule [series(Item,TERM)] parses a non-empty list of [Item]
separated by semicolons and optionally terminated by a semicolon,
then the terminal TERM. *)
series(Item,TERM):
Item after_item(Item,TERM) { $1,$2 }
after_item(Item,TERM):
SEMI item_or_closing(Item,TERM) {
match $2 with
`Some (item, items, term, closing) ->
($1, item)::items, term, closing
| `Closing closing ->
[], Some $1, closing
}
| TERM {
[], None, $1
}
item_or_closing(Item,TERM):
TERM {
`Closing $1
}
| series(Item,TERM) {
let item, (items, term, closing) = $1
in `Some (item, items, term, closing)
}