]> git.droids-corp.org - protos/libecoli.git/commitdiff
yaml: more examples
authorOlivier Matz <zer0@droids-corp.org>
Thu, 7 Mar 2019 18:17:02 +0000 (19:17 +0100)
committerOlivier Matz <zer0@droids-corp.org>
Thu, 7 Mar 2019 18:17:06 +0000 (19:17 +0100)
examples/parse-yaml/cond.yaml [new file with mode: 0644]
examples/parse-yaml/cross.yaml [new file with mode: 0644]
examples/parse-yaml/test.yaml

diff --git a/examples/parse-yaml/cond.yaml b/examples/parse-yaml/cond.yaml
new file mode 100644 (file)
index 0000000..49483ab
--- /dev/null
@@ -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 (file)
index 0000000..e6e35fa
--- /dev/null
@@ -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
index 56427660eb7e41f8d0a87103a43305621210786a..4191d94a312ce4b6048c3d0b230f9c2a700f9e0e 100644 (file)
@@ -1,4 +1,8 @@
 type: or
+attrs:
+  key1: val1
+  key2: val2
+  key3:
 children:
 - type: seq
   id: hello