From 3f47bb2e857b17df581c50196dccfa09a29eefeb Mon Sep 17 00:00:00 2001 From: Christian Rinderknecht Date: Thu, 29 Aug 2019 17:09:43 +0200 Subject: [PATCH] Recording as miscellaneous the old way to do series of items. --- src/parser/pascaligo/Doc/misc.txt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/parser/pascaligo/Doc/misc.txt diff --git a/src/parser/pascaligo/Doc/misc.txt b/src/parser/pascaligo/Doc/misc.txt new file mode 100644 index 000000000..49fb5b8bd --- /dev/null +++ b/src/parser/pascaligo/Doc/misc.txt @@ -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) + }