diff options
Diffstat (limited to 'stdlib/source/documentation/lux/data')
-rw-r--r-- | stdlib/source/documentation/lux/data/collection/tree.lux | 46 | ||||
-rw-r--r-- | stdlib/source/documentation/lux/data/format/json.lux | 71 | ||||
-rw-r--r-- | stdlib/source/documentation/lux/data/format/xml.lux | 44 | ||||
-rw-r--r-- | stdlib/source/documentation/lux/data/text.lux | 168 |
4 files changed, 322 insertions, 7 deletions
diff --git a/stdlib/source/documentation/lux/data/collection/tree.lux b/stdlib/source/documentation/lux/data/collection/tree.lux index f0d165a5b..fca76d251 100644 --- a/stdlib/source/documentation/lux/data/collection/tree.lux +++ b/stdlib/source/documentation/lux/data/collection/tree.lux @@ -5,12 +5,54 @@ [data ["[0]" text (.only \n) ["%" \\format (.only format)]]]]] + ["[0]" \\parser] [\\library ["[0]" /]] ["[0]" / ["[1][0]" finger] ["[1][0]" zipper]]) +(`` (.def \\parser + (.List $.Module) + ($.module \\parser._ + "" + [($.default \\parser.cannot_move_further) + + ($.documentation (\\parser.Parser it) + "A parser of arbitrary trees.") + + ($.documentation \\parser.result' + "Applies the parser against a tree zipper." + [(result' parser zipper)]) + + ($.documentation \\parser.result + "Applies the parser against a tree." + [(result parser tree)]) + + ($.documentation \\parser.value + "Yields the value inside the current tree node.") + + (,, (with_template [<name> <doc>] + [($.documentation <name> + <doc>)] + + [\\parser.down "Move down."] + [\\parser.up "Move up."] + + [\\parser.right "Move to the right."] + [\\parser.rightmost "Move to the rightmost node."] + + [\\parser.left "Move to the left."] + [\\parser.leftmost "Move to the leftmost node."] + + [\\parser.next "Move to the next node."] + [\\parser.end "Move to the last node."] + + [\\parser.previous "Move to the previous node."] + [\\parser.start "Move to the root node."] + ))] + []))) + (.def .public documentation (.List $.Module) ($.module /._ @@ -41,5 +83,7 @@ {34 {} 56 {} 78 {90 {}}}))])] - [/finger.documentation + [..\\parser + + /finger.documentation /zipper.documentation])) 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])) diff --git a/stdlib/source/documentation/lux/data/text.lux b/stdlib/source/documentation/lux/data/text.lux index 3be4f68f6..03023fcc1 100644 --- a/stdlib/source/documentation/lux/data/text.lux +++ b/stdlib/source/documentation/lux/data/text.lux @@ -1,16 +1,20 @@ (.require [library [lux (.except) - ["$" documentation]]] + ["$" documentation] + [meta + [macro + ["[0]" template]]]]] ["[0]" / ["[1][0]" buffer] ["[1][0]" encoding] ["[1][0]" escape] ["[1][0]" regex] ["[1][0]" unicode]] - ["[0]" \\format] + ["[0]" \\format (.only format)] + ["[0]" \\parser] [\\library - ["[0]" /]]) + ["[0]" / (.only \n)]]) (.def \\format (.List $.Module) @@ -70,6 +74,163 @@ [(format "Static part " (text static) " does not match URI: " uri)])] [])) +(`` (.def \\parser + (.List $.Module) + ($.module \\parser._ + "" + [($.default \\parser.unconsumed_input) + ($.default \\parser.expected_to_fail) + ($.default \\parser.cannot_parse) + ($.default \\parser.cannot_slice) + ($.default \\parser.cannot_match) + ($.default \\parser.character_should_be) + ($.default \\parser.character_should_not_be) + ($.default \\parser.character_does_not_satisfy_predicate) + + ($.documentation \\parser.Offset + "An offset into a block of text.") + + ($.documentation (\\parser.Parser it) + "A parser for text.") + + ($.documentation \\parser.Slice + "A slice of a block of text.") + + ($.documentation \\parser.result + (format "Executes a parser against a block of text." + \n "Verifies that the entire input has been processed.") + [(result parser input)]) + + ($.documentation \\parser.offset + "Yields the current offset into the input.") + + ($.documentation \\parser.any + "Yields the next character without applying any logic.") + + ($.documentation \\parser.any! + "Yields the next character (as a slice) without applying any logic.") + + (,, (with_template [<name> <caveat>] + [(`` ($.documentation <name> + (format "Produce a character" (,, (template.text [<caveat>])) " if the parser fails.")))] + + [\\parser.not ""] + [\\parser.not! " (as a slice)"] + )) + + ($.documentation \\parser.this + "Checks that a specific text shows up in the input." + [(this reference)]) + + ($.documentation \\parser.end + "Ensure the parser's input is empty.") + + ($.documentation \\parser.next + "Yields the next character (without consuming it from the input).") + + ($.documentation \\parser.remaining + "Get all of the remaining input (without consuming it).") + + ($.documentation \\parser.range + "Only yields characters within a range." + [(range bottom top)]) + + (,, (with_template [<name> <desc>] + [($.documentation <name> + (format "Only yields " <desc> " characters."))] + + [\\parser.upper "uppercase"] + [\\parser.lower "lowercase"] + [\\parser.decimal "decimal"] + [\\parser.octal "octal"] + )) + + ($.documentation \\parser.alpha + "Yields alphabetic characters.") + + ($.documentation \\parser.alpha_num + "Yields alphanumeric characters.") + + ($.documentation \\parser.hexadecimal + "Yields hexadecimal digits.") + + (,, (with_template [<name> <description_modifier>] + [($.documentation <name> + (format "Yields characters that are" <description_modifier> " part of a piece of text."))] + + [\\parser.one_of ""] + [\\parser.none_of " not"] + )) + + (,, (with_template [<name> <description_modifier>] + [($.documentation <name> + (format "Yields characters (as a slice) that are" <description_modifier> " part of a piece of text."))] + + [\\parser.one_of! ""] + [\\parser.none_of! " not"] + )) + + ($.documentation \\parser.satisfies + "Yields characters that satisfy a predicate." + [(satisfies parser)]) + + ($.documentation \\parser.space + "Yields white-space.") + + ($.documentation \\parser.and + "Yields the outputs of both parsers composed together." + [(and left right)]) + + ($.documentation \\parser.and! + "Yields the outputs of both parsers composed together (as a slice)." + [(and! left right)]) + + (,, (with_template [<text> <slice>] + [(`` ($.documentation <text> + (format "Yields " (,, (template.text [<name>])) " characters as a single continuous text."))) + (`` ($.documentation <slice> + (format "Yields " (,, (template.text [<name>])) " characters as a single continuous text (as a slice).")))] + + [\\parser.some \\parser.some!] + [\\parser.many \\parser.many!] + )) + + (,, (with_template [<text> <slice> <doc_modifier>] + [(`` ($.documentation <text> + (format "Yields " <doc_modifier> " N characters."))) + (`` ($.documentation <slice> + (format "Yields " <doc_modifier> " N characters (as a slice).")))] + + [\\parser.exactly \\parser.exactly! "exactly"] + [\\parser.at_most \\parser.at_most! "at most"] + [\\parser.at_least \\parser.at_least! "at least"] + )) + + ($.documentation \\parser.between + "" + [(between minimum additional parser)]) + + ($.documentation \\parser.between! + "" + [(between! minimum additional parser)]) + + ($.documentation \\parser.enclosed + "" + [(enclosed [start end] parser)]) + + ($.documentation \\parser.local + "Applies a parser against the given input." + [(local local_input parser)]) + + ($.documentation \\parser.slice + "Converts a slice to a block of text." + [(slice parser)]) + + ($.documentation \\parser.then + "Embeds a text parser into an arbitrary parser that yields text." + [(then structured text)])] + []))) + (.def .public documentation (.List $.Module) ($.module /._ @@ -197,6 +358,7 @@ "Checks whether the character is white-space." [(space? char)])] [..\\format + ..\\parser /buffer.documentation /encoding.documentation |