From 61a84a21fe4f71327d652b183a4cd80900510f4f Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Thu, 7 Mar 2019 19:17:02 +0100 Subject: [PATCH] yaml: more examples --- examples/parse-yaml/cond.yaml | 43 ++++++++++++++++++++++++++++++++++ examples/parse-yaml/cross.yaml | 16 +++++++++++++ examples/parse-yaml/test.yaml | 4 ++++ 3 files changed, 63 insertions(+) create mode 100644 examples/parse-yaml/cond.yaml create mode 100644 examples/parse-yaml/cross.yaml diff --git a/examples/parse-yaml/cond.yaml b/examples/parse-yaml/cond.yaml new file mode 100644 index 0000000..49483ab --- /dev/null +++ b/examples/parse-yaml/cond.yaml @@ -0,0 +1,43 @@ +type: re_lex +patterns: +- pattern: "[_a-zA-Z][._a-zA-Z0-9]*" + keep: true + attr: a_identifier +- pattern: "\\(" + keep: true + attr: a_open +- pattern: "\\)" + keep: true + attr: a_close +- pattern: "," + keep: true +- pattern: "[ ]+" + keep: false +child: + &term + id: term + type: or + children: + - type: seq + id: function + children: + - type: any + id: function_name + attr: a_identifier + - type: any + attr: a_open + - type: option + id: term_list + child: + type: seq + children: + - *term + - type: many + child: + type: seq + children: + - type: str + string: "," + - *term + - type: any + attr: a_close diff --git a/examples/parse-yaml/cross.yaml b/examples/parse-yaml/cross.yaml new file mode 100644 index 0000000..e6e35fa --- /dev/null +++ b/examples/parse-yaml/cross.yaml @@ -0,0 +1,16 @@ +# matches "x", "x + x", "x + x + x", ... +&term +id: term +type: or +children: +- type: seq + children: + - &value + id: value + type: str + string: x + - id: operator + type: str + string: + + - *term +- *value diff --git a/examples/parse-yaml/test.yaml b/examples/parse-yaml/test.yaml index 5642766..4191d94 100644 --- a/examples/parse-yaml/test.yaml +++ b/examples/parse-yaml/test.yaml @@ -1,4 +1,8 @@ type: or +attrs: + key1: val1 + key2: val2 + key3: children: - type: seq id: hello -- 2.39.5