aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/data/format
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/documentation/lux/data/format/json.lux71
-rw-r--r--stdlib/source/documentation/lux/data/format/xml.lux44
2 files changed, 112 insertions, 3 deletions
diff --git a/stdlib/source/documentation/lux/data/format/json.lux b/stdlib/source/documentation/lux/data/format/json.lux
index 25026ef6f..d263a0dfa 100644
--- a/stdlib/source/documentation/lux/data/format/json.lux
+++ b/stdlib/source/documentation/lux/data/format/json.lux
@@ -4,10 +4,77 @@
["$" documentation]
[data
[text (.only \n)
- ["%" \\format (.only format)]]]]]
+ ["%" \\format (.only format)]]]
+ [meta
+ [macro
+ ["[0]" template]]]]]
+ ["[0]" \\parser]
[\\library
["[0]" /]])
+(`` (.def \\parser
+ (.List $.Module)
+ ($.module \\parser._
+ ""
+ [($.default \\parser.unconsumed_input)
+ ($.default \\parser.empty_input)
+ ($.default \\parser.unexpected_value)
+ ($.default \\parser.value_mismatch)
+
+ ($.documentation (\\parser.Parser it)
+ "A JSON parser.")
+
+ ($.documentation \\parser.result
+ (format "Executes the parser against a JSON object."
+ \n "Verifies that all of the JSON was consumed by the parser.")
+ [(result parser json)])
+
+ ($.documentation \\parser.any
+ "Just returns the JSON input without applying any logic.")
+
+ (,, (with_template [<name>]
+ [(`` ($.documentation <name>
+ (format "Reads a JSON value as " (,, (template.text [<name>])) ".")))]
+
+ [\\parser.null]
+ [\\parser.boolean]
+ [\\parser.number]
+ [\\parser.string]
+ ))
+
+ (,, (with_template [<test> <check> <read>]
+ [(`` ($.documentation <test>
+ (format "Asks whether a JSON value is a " (,, (template.text [<read>])) ".")))
+ (`` ($.documentation <check>
+ (format "Ensures a JSON value is a " (,, (template.text [<read>])) ".")))]
+
+ [\\parser.boolean? \\parser.this_boolean ..boolean]
+ [\\parser.number? \\parser.this_number ..number]
+ [\\parser.string? \\parser.this_string ..string]
+ ))
+
+ ($.documentation \\parser.nullable
+ "Enhances parser by adding NULL-handling."
+ [(nullable parser)])
+
+ ($.documentation \\parser.array
+ "Parses the contents of a JSON array."
+ [(array parser)])
+
+ ($.documentation \\parser.object
+ (format "Parses the contents of a JSON object."
+ \n "Use this with the 'field' combinator.")
+ [(object parser)])
+
+ ($.documentation \\parser.field
+ (format "Parses a field inside a JSON object."
+ \n "Use this inside the 'object' combinator.")
+ [(field field_name parser)])
+
+ ($.documentation \\parser.dictionary
+ "Parses a dictionary-like JSON object.")]
+ [])))
+
(`` (.def .public documentation
(.List $.Module)
($.module /._
@@ -63,4 +130,4 @@
[/.array_field "arrays"]
[/.object_field "objects"]
))]
- [])))
+ [..\\parser])))
diff --git a/stdlib/source/documentation/lux/data/format/xml.lux b/stdlib/source/documentation/lux/data/format/xml.lux
index d49299af6..70f4855b0 100644
--- a/stdlib/source/documentation/lux/data/format/xml.lux
+++ b/stdlib/source/documentation/lux/data/format/xml.lux
@@ -5,9 +5,51 @@
[data
[text (.only \n)
["%" \\format (.only format)]]]]]
+ ["[0]" \\parser]
[\\library
["[0]" /]])
+(.def \\parser
+ (.List $.Module)
+ ($.module \\parser._
+ ""
+ [($.default \\parser.empty_input)
+ ($.default \\parser.unexpected_input)
+ ($.default \\parser.wrong_tag)
+ ($.default \\parser.unknown_attribute)
+ ($.default \\parser.unconsumed_inputs)
+ ($.default \\parser.nowhere)
+
+ ($.documentation (\\parser.Parser it)
+ "A parser of XML-encoded data.")
+
+ ($.documentation \\parser.result
+ (format "Applies a parser against a stream of XML documents."
+ \n "Verifies that all of the inputs are consumed by the parser.")
+ [(result parser documents)])
+
+ ($.documentation \\parser.text
+ "Yields text from a text node.")
+
+ ($.documentation \\parser.tag
+ "Yields the tag from the next node.")
+
+ ($.documentation \\parser.attribute
+ "Yields the value of an attribute in the current node."
+ [(attribute name)])
+
+ ($.documentation \\parser.node
+ "Parses the contents of the next node if the tag matches."
+ [(node expected parser)])
+
+ ($.documentation \\parser.any
+ "Yields the next node.")
+
+ ($.documentation \\parser.somewhere
+ "Applies the parser somewhere among the remaining inputs; instead of demanding that the parser succeeds against the immediate inputs."
+ [(somewhere parser)])]
+ []))
+
(.def .public documentation
(.List $.Module)
($.module /._
@@ -28,4 +70,4 @@
($.documentation /.attribute
"The text format of a XML attribute.")]
- []))
+ [..\\parser]))