@temperlang/std 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/regex.js.map CHANGED
@@ -1 +1 @@
1
- { "version": 3, "file": "js/std/regex.js", "sources": [ "std/regex.temper.md" ], "sourcesContent": [ "# Regex Data Model and Functionality\n\nThe structural data model for regex patterns enables direct construction, and\nthe Temper regex dialect compiles static regex text patterns to these objects.\n\nA focus here is on providing tools people can actually reach for when they need\nto do text processing. The execution should be faster on backends like Python\nthan writing raw code, and the implementation in backends like C should\napproximate what you'd like to have written manually.\n\nDue to inadequate and distinct Unicode handling in backend regex engines, the\ninitial feature set avoids character classes and properties but is still aware\nof code points. Parsing focused on limited sets of delimiters works best for\nnow.\n\nThe core feature set here focuses on both the data model and utility functions,\nsuch as matching regexes against strings.\n\n## Regex Data Model\n\nTemper regex representation is composed hierarchically of `RegexNode` objects.\nAnd perhaps the most fundamental `RegexNode` is the [Sequence](#sequence),\nbecause it enables multiple regex components to be strung together. For example,\n`/hi./` is a sequence of [CodePoints](#codepoints) `/hi/` and dot `/./`, but all\ncomponent types extend the `RegexNode` interface.\n\n```\nexport /*sealed*/ interface RegexNode {\n```\n\nBefore a regex is used, it must be compiled. This transforms a `RegexNode` tree\ninto a backend-native [Regex](#regex). Some helper functions compile on the fly,\nalthough it is faster to reuse a pre-compiled regex.\n\n```\n // TODO(tjp, regex): Make this into a macro behind the scenes.\n // TODO(tjp, regex): `compiled\u003cT\u003e(): Regex\u003cT\u003e`\n public compiled(): Regex { new Regex(this) }\n```\n\nThe simplest use of a regular expression is if it is found in a string.\nAgain, it is better to compile to a `Regex` in advance than to repeatedly call\nconvenience methods on a `RegexNode`.\n\n```\n public found(text: String): Boolean { compiled().found(text) }\n```\n\nYou can also return match details or perform text replacement. The returned\ngroups map contains an entry for each key in the order defined in the regex\npattern. If no \u0022full\u0022 group is defined, one is added automatically to capture\nthe full matched text.\n\nIn the future, we intend to support customized match types with fields to match\ncapture groups, statically checked where possible.\n\n```\n // TODO(tjp, regex): Also macro because reification.\n\n public find(text: String): Map\u003cString, Group\u003e | Bubble {\n compiled().find(text)\n }\n\n public replace(\n text: String, format: fn (Map\u003cString, Group\u003e): String\n ): String {\n compiled().replace(text, format)\n }\n```\n\nThat's it for what you can do with regex patterns in Temper today, but there's\nmuch more to say on what kinds of regexes can be built.\n\n```\n}\n```\n\n## Regex Item Types\n\nA `Regex` is composed of a potential variety of subtypes.\n\n### Groups\n\nMultiple types of groups exist:\n\n- [Capture](#capture) `/(?\u003cname\u003e...)/` to remember match groups for later use.\n- Non-capturing group syntax `/(?:...)/`, which is simply a [Regex](#regex)\n instance in the data model.\n\n### Capture\n\nTODO(tjp, regex): Change to named captures only!\n\n`Capture` is a [group](#groups) that remembers the matched text for later\naccess. Temper supports only named matches, with current intended syntax\n`/(?name = ...)/`.\n\n```\nexport class Capture extends RegexNode {\n public name: String;\n public /*early*/ item: RegexNode;\n}\n```\n\n### CodePart\n\nA component of a [CodeSet][#codeset], aka character class, which applies to a\nsubset of regex data types.\n\nHere, \u0022code\u0022 is short for \u0022code point\u0022 although \u0022char\u0022 might work better,\ndepending on expectations.\n\n```\nexport /*sealed*/ interface CodePart extends RegexNode {}\n```\n\n### CodePoints\n\nOne or more verbatim code points, where the sequence matters if within a\n[Regex](#regex) or not if within a [CodeSet](#codeset). Some escapes in\ntextual regex source, such as `/\\t/`, can be stored as raw code points.\n\nThe `String` here can enable more efficient storage than individual code\npoints, although the source text may require non-capture grouping. For example,\n`/(?:abc)?/` optionally matches the string `\u0022abc\u0022`, whereas `/abc?/` matches\n`\u0022ab\u0022` with an optional `\u0022c\u0022`.\n\n```\nexport class CodePoints extends CodePart {\n public value: String;\n}\n```\n\n### Specials\n\nA number of special match forms exist. In the data model, these are empty\nclasses.\n\n- `.` - `Dot` In default mode, matches any Unicode code point except newline.\n- `^` - `Begin` in default mode matches zero-length at the beginning of a\n string.\n- `\u0024` - `End` in default mode matches zero-length at the end of a string.\n- `\\b` - `WordBoundary` matches zero-length at the boundary between word and\n non-word code points. More sophisticated Unicode compliance is TBD.\n- `\\s` (negated as `\\S`) - `Space` matches any horizontal space code point.\n Details are TBD.\n- `\\w` (negated as `\\W`) - `Word` matches any word code point. Details are TBD.\n This is currently defined in terms of old ASCII definitions because those are\n clear. Perhaps this will stay that way, and Unicode properties like `\\p{L}`\n will be used for human language needs.\n- `\\X` - `GraphemeCluster` might not be supported, but [here is some discussion\n of how to implement it](\n https://github.com/rust-lang/regex/issues/54#issuecomment-661905060).\n\n\u003cdetails\u003e\n\n```\nexport /*sealed*/ interface Special extends RegexNode {}\nexport let Begin: Special = do { class Begin extends Special {}; new Begin() };\nexport let Dot: Special = do { class Dot extends Special {}; new Dot() };\nexport let End: Special = do { class End extends Special {}; new End() };\n// TODO(tjp, regex): We can't easily support this at present across backends.\n// export let GraphemeCluster = do {\n// class GraphemeCluster extends Special {}; new GraphemeCluster()\n// };\nexport let WordBoundary: Special = do {\n class WordBoundary extends Special {}; new WordBoundary()\n};\n\nexport /*sealed*/ interface SpecialSet extends CodePart \u0026 Special {}\nexport let Digit: SpecialSet = do {\n class Digit extends SpecialSet {}; new Digit()\n};\nexport let Space: SpecialSet = do {\n class Space extends SpecialSet {}; new Space()\n};\nexport let Word: SpecialSet = do {\n class Word extends SpecialSet {}; new Word()\n};\n```\n\n\u003c/details\u003e\n\n### CodeRange\n\nA code point range matches any code point in its inclusive bounds, such as\n`/[a-c]/`. In source, `-` is included in a code set either by escaping or by\nincluding it as the first or last character. A `CodeRange` is usually contained\ninside a [CodeSet](#codeset), and syntactically always is.\n\n```\nexport class CodeRange extends CodePart {\n public min: Int;\n public max: Int;\n}\n```\n\n### Itemized Regex Types\n\nMake an abstraction over Regex types that have lists of subitems. This can make\nprocessing more convenient.\n\n export interface ItemizedRegex\u003cITEM extends RegexNode\u003e extends RegexNode {\n public get items(): List\u003cITEM\u003e;\n }\n\n### CodeSet\n\nA set of code points, any of which can match, such as `/[abc]/` matching any of\n`\u0022a\u0022`, `\u0022b\u0022`, or `\u0022c\u0022`. Alternatively, a negated set is the inverse of the code\npoints given, such as `/[^abc]/`, matching any code point that's not any of\nthese. This is also often called a character class.\n\nFurther, a subset of [specials](#specials) can also be used in code sets. A\nnegated code set of just a special set often has custom syntax. For example,\nnon-space can be said as either `/[^\\s]/` or `/\\S/`.\n\n```\nexport class CodeSet extends ItemizedRegex\u003cCodePart\u003e {\n public items: List\u003cCodePart\u003e;\n public negated: Boolean = false;\n}\n```\n\n### Or\n\n`Or` matches any one of multiple options, such as `/ab|cd|e*/`.\n\n```\nexport class Or extends ItemizedRegex\u003cRegexNode\u003e {\n public /*early*/ items: List\u003cRegexNode\u003e;\n}\n```\n\n### Repeat\n\n`Repeat` matches from an minimum to a maximum number of repeats of a\nsubregex. This can be represented in regex source in a number of ways:\n\n- `?` matches 0 or 1.\n- `*` matches 0 or more.\n- `+` matches 1 or more.\n- `{m}` matches exactly `m` repetitions.\n- `{m,n}` matches between `m` and `n`. Missing `n` is a max of infinity. For\n example, `{0,1}` is equivalent to `?`, and `{1,}` is equivalent to `+`.\n\nBy default, repetitions are greedy, matching as many repetitions as possible.\nIn regex source, any of the above can have `?` appended to indicated reluctant\n(aka non-greedy), matching as few repetitions as possible.\n\n```\nexport class Repeat extends RegexNode {\n public /*early*/ item: RegexNode;\n public min: Int;\n public max: Int | Null; // where null means infinite\n public reluctant: Boolean = false;\n}\n```\n\nWe also have convenience builders.\n\n```\nexport let entire(item: RegexNode): RegexNode {\n new Sequence([Begin, item, End])\n}\n\nexport let oneOrMore(item: RegexNode, reluctant: Boolean = false): Repeat {\n { item, min: 1, max: null, reluctant }\n}\n\nexport let optional(item: RegexNode, reluctant: Boolean = false): Repeat {\n { item, min: 0, max: 1, reluctant }\n}\n```\n\n### Sequence\n\n`Sequence` strings along multiple other regexes in order.\n\n```\nexport class Sequence extends ItemizedRegex\u003cRegexNode\u003e {\n public /*early*/ items: List\u003cRegexNode\u003e;\n}\n```\n\n## Match Objects\n\nFor detailed match results, call `find` on a regex to get a `Map` object from\n`String` keys to `Group` values.\n\n```\n// TODO Go back to a `Match` object with `groups` as a member so we can also\n// TODO easily return metadata alongside groups? Or is simpler better?\n// export class Match { // interface ... \u003cT = Map\u003cString, Group\u003e\u003e {\n// public let groups: Map\u003cString, Group\u003e;\n// }\n\nexport class Group {\n public let name: String;\n public let value: String;\n public let codePointsBegin: Int;\n}\n```\n\n## Compiled Regex Objects\n\nThe compiled form of a regex is mostly opaque, but it can be cached for more\nefficient reuse than working from a source [RegexNode](#regex-data-model).\n\n\u003cdetails\u003e\n\n```\n// Provides a workaround for access to std/regex from extension methods.\nclass RegexRefs {\n public let codePoints: CodePoints = new CodePoints(\u0022\u0022);\n public let group: Group = { name: \u0022\u0022, value: \u0022\u0022, codePointsBegin: 0 }\n public let orObject: Or = new Or([]);\n}\n\nlet regexRefs = new RegexRefs();\n```\n\n\u003c/details\u003e\n\n```\n// TODO(tjp, regex): Generate subtypes of this interface later.\nexport class Regex { // interface ... \u003cT\u003e {\n```\n\nThe source `Regex` data is still available on compiled objects in case it's\nneeded for composition or other purposes.\n\n```\n public let data: RegexNode;\n\n public constructor(data: RegexNode) {\n this.data = data;\n compiled = compileFormatted(format());\n }\n```\n\nA compiled regex exposes many of the same capabilities as `Regex`, but they are\nmore efficient to use repeatedly.\n\n```\n public found(text: String): Boolean { compiledFound(compiled, text) }\n\n public find(text: String): Map\u003cString, Group\u003e | Bubble {\n compiledFind(compiled, text, regexRefs)\n }\n\n public replace(\n text: String, format: fn (Map\u003cString, Group\u003e): String\n ): String {\n compiledReplace(compiled, text, format, regexRefs)\n }\n```\n\nTODO(tjp, regex): Public method for replace with named references.\nTODO(tjp, regex): Any static checking?\n\n\u003cdetails\u003e\n\n```\n let compiled: AnyValue;\n\n // Extension functions on some backends need the private `compiled` value\n // passed in directly.\n @connected(\u0022Regex::compiledFound\u0022)\n compiledFound(compiled: AnyValue, text: String): Boolean;\n\n @connected(\u0022Regex::compiledFind\u0022)\n compiledFind(\n compiled: AnyValue, text: String, regexRefs: RegexRefs\n ): Map\u003cString, Group\u003e | Bubble;\n\n @connected(\u0022Regex::compileFormatted\u0022)\n compileFormatted(formatted: String): AnyValue;\n\n @connected(\u0022Regex::compiledReplace\u0022)\n compiledReplace(\n compiled: AnyValue,\n text: String,\n format: fn (Map\u003cString, Group\u003e): String,\n regexRefs: RegexRefs,\n ): String;\n\n @connected(\u0022Regex::format\u0022)\n format(): String { new RegexFormatter().format(data) }\n```\n\n\u003c/details\u003e\n\n```\n}\n```\n\n## Private implementation matters\n\nSome regex logic can be shared across backends. These features aren't directly\nexported to the user, however.\n\nThe intent is that these support features only get included in compiled Temper\ncode if usage depends on dynamically constructed regexes. If all regex building\nis done as stable values, we hope to generated backend compiled regexes purely\nat Temper compile time.\n\n### RegexFormatter\n\n\u003cdetails\u003e\n\n```\nclass RegexFormatter {\n let out: ListBuilder\u003cString\u003e = new ListBuilder\u003cString\u003e();\n\n public format(regex: RegexNode): String {\n pushRegex(regex)\n out.join(\u0022\u0022) { (x);; x }\n }\n\n pushRegex(regex: RegexNode): Void {\n match (regex) {\n // Aggregate types.\n is Capture -\u003e pushCapture(regex);\n is CodePoints -\u003e pushCodePoints(regex, false);\n is CodeRange -\u003e pushCodeRange(regex);\n is CodeSet -\u003e pushCodeSet(regex);\n is Or -\u003e pushOr(regex);\n is Repeat -\u003e pushRepeat(regex);\n is Sequence -\u003e pushSequence(regex);\n // Specials.\n // Some of these will need to be customized on future backends.\n Begin -\u003e out.add(\u0022^\u0022);\n Dot -\u003e out.add(\u0022.\u0022);\n End -\u003e out.add(\u0022\u0024\u0022);\n WordBoundary -\u003e out.add(\u0022\\\\b\u0022);\n // Special sets.\n Digit -\u003e out.add(\u0022\\\\d\u0022);\n Space -\u003e out.add(\u0022\\\\s\u0022);\n Word -\u003e out.add(\u0022\\\\w\u0022);\n // ...\n }\n }\n\n pushCapture(capture: Capture): Void {\n out.add(\u0022(\u0022);\n // TODO(tjp, regex): Consistent name validation rules for all backends???\n // TODO(tjp, regex): Validate here or in `Capture` constructor???\n // TODO(tjp, regex): Validate here or where against reused names???\n pushCaptureName(out, capture.name);\n pushRegex(capture.item);\n out.add(\u0022)\u0022);\n }\n\n @connected(\u0022RegexFormatter::pushCaptureName\u0022)\n pushCaptureName(out: ListBuilder\u003cString\u003e, name: String): Void {\n // All so far except Python use this form.\n out.add(\u0022?\u003c\u0024{name}\u003e\u0022);\n }\n\n pushCode(code: Int, insideCodeSet: Boolean): Void {\n // Expose private property to extension.\n pushCodeTo(out, code, insideCodeSet);\n // TODO(tjp, regex): Implement more in Temper once we can.\n // if (escapeCodes[code] \u0026\u0026 false) {\n // out.add(\u0022\\\\\u0022);\n // // TODO(tjp, regex): How to convert back to strings?\n // }\n }\n\n @connected(\u0022RegexFormatter::pushCodeTo\u0022)\n pushCodeTo(out: ListBuilder\u003cString\u003e, code: Int, insideCodeSet: Boolean): Void;\n\n pushCodePoints(codePoints: CodePoints, insideCodeSet: Boolean): Void {\n for (\n var slice = codePoints.value.codePoints;\n !slice.isEmpty;\n slice = slice.advance(1)\n ) {\n pushCode(slice.read(), insideCodeSet);\n }\n }\n\n pushCodeRange(codeRange: CodeRange): Void {\n out.add(\u0022[\u0022);\n pushCodeRangeUnwrapped(codeRange);\n out.add(\u0022]\u0022);\n }\n\n pushCodeRangeUnwrapped(codeRange: CodeRange): Void {\n pushCode(codeRange.min, true);\n out.add(\u0022-\u0022);\n pushCode(codeRange.max, true);\n }\n\n pushCodeSet(codeSet: CodeSet): Void {\n let adjusted = adjustCodeSet(codeSet, regexRefs);\n match (adjusted) {\n is CodeSet -\u003e do {\n out.add(\u0022[\u0022);\n if (adjusted.negated) {\n out.add(\u0022^\u0022);\n }\n for (var i = 0; i \u003c adjusted.items.length; i += 1) {\n pushCodeSetItem(adjusted.items[i]);\n }\n out.add(\u0022]\u0022);\n }\n else -\u003e pushRegex(adjusted);\n }\n }\n\n @connected(\u0022RegexFormatter::adjustCodeSet\u0022)\n adjustCodeSet(codeSet: CodeSet, regexRefs: RegexRefs): RegexNode { codeSet }\n\n pushCodeSetItem(codePart: CodePart): Void {\n match (codePart) {\n is CodePoints -\u003e pushCodePoints(codePart, true);\n is CodeRange -\u003e pushCodeRangeUnwrapped(codePart);\n is SpecialSet -\u003e pushRegex(codePart);\n }\n }\n\n pushOr(or: Or): Void {\n if (!or.items.isEmpty) {\n out.add(\u0022(?:\u0022);\n // TODO(tjp, regex): See #822. Until `this` works better, no this in funs.\n // TODO(tjp, regex): So just manually loop here. Sometimes faster, anyway?\n pushRegex(or.items[0]);\n for (var i = 1; i \u003c or.items.length; i += 1) {\n out.add(\u0022|\u0022);\n pushRegex(or.items[i]);\n }\n out.add(\u0022)\u0022);\n }\n }\n\n pushRepeat(repeat: Repeat): Void {\n // Always wrap the main sub-pattern here to make life easy\n out.add(\u0022(?:\u0022);\n pushRegex(repeat.item);\n out.add(\u0022)\u0022);\n // Then add the repetition part.\n let min = repeat.min;\n let max = repeat.max;\n if (false) {\n } else if (min == 0 \u0026\u0026 max == 1) {\n out.add(\u0022?\u0022);\n } else if (min == 0 \u0026\u0026 max == null) {\n out.add(\u0022*\u0022);\n } else if (min == 1 \u0026\u0026 max == null) {\n out.add(\u0022+\u0022);\n } else {\n out.add(\u0022{\u0024{min.toString()}\u0022);\n if (min != max) {\n out.add(\u0022,\u0022);\n if (max != null) {\n out.add(max.as\u003cInt\u003e().toString());\n }\n }\n out.add(\u0022}\u0022);\n }\n if (repeat.reluctant) {\n out.add(\u0022?\u0022);\n }\n }\n\n pushSequence(sequence: Sequence): Void {\n // TODO(tjp, regex): Foreach loop/function would be nice.\n for (var i = 0; i \u003c sequence.items.length; i += 1) {\n pushRegex(sequence.items[i]);\n }\n }\n\n // Put this here instead of the data model for now because I'm not sure this\n // makes sense to be part of the public api right now.\n public maxCode(codePart: CodePart): Int | Null {\n match (codePart) {\n is CodePoints -\u003e do {\n // Iterating code points is the hardest of the current cases.\n let value = codePart.value;\n if (value.isEmpty) {\n null\n } else {\n // My kingdom for a fold, or even just a max, in builtins.\n var max = 0;\n for (\n var slice = value.codePoints;\n !slice.isEmpty;\n slice = slice.advance(1)\n ) {\n let next = slice.read();\n if (next \u003e max) {\n max = next;\n }\n }\n max\n }\n }\n // Others below are easy for now.\n is CodeRange -\u003e codePart.max;\n Digit -\u003e \u00229\u0022.codePoints.read();\n Space -\u003e \u0022 \u0022.codePoints.read();\n Word -\u003e \u0022z\u0022.codePoints.read();\n // Actually unexpected, ever, but eh.\n else -\u003e null;\n }\n }\n}\n```\n\n\u003c/details\u003e\n" ], "names": [ "Regex", "text", "format", "RegexNode", "compiled", "found", "find", "replace", "Capture", "name", "item", "CodePart", "CodePoints", "value", "Special", "SpecialSet", "CodeRange", "min", "max", "ItemizedRegex", "get.items", "CodeSet", "items", "negated", "Or", "Repeat", "reluctant", "Sequence", "Group", "codePointsBegin", "RegexRefs", "codePoints", "group", "orObject", "data", "regexRefs", "RegexFormatter", "out", "regex", "fn", "x", "return", "Begin", "Dot", "End", "WordBoundary", "Digit", "Space", "Word", "capture", "code", "insideCodeSet", "slice", "codeRange", "codeSet", "adjusted", "i", "codePart", "or", "repeat", "sequence", "next", "entire", "oneOrMore", "optional" ], "mappings": "AA2BA;AAAA;AAAA;AAUS,QAAqC,gBAAA,AAArC,EAAqC,AAAnB;AAAE,YAAI,CAAAA,KAAK,CAAC,IAAI,CAAC;AAAA;AAQnC,QAAuD,aAAA,AAAvD,CAAMC,MAAY,CAAqC,AAA1B;AAAE,QAAW,AAAX,KAAQ,CAAA,AAAR,QAAQ,EAAE,CAAC,KAAK,CAACA,MAAI,CAAC;AAAA;AAcrD,QAEN,YAAA,AAFM,CAAKA,MAAY,CAEvB,AAFsD;AACrD,QAAW,AAAX,KAAQ,CAAA,AAAR,QAAQ,EAAE,CAAC,IAAI,CAACA,MAAI,CAAC;AAAA;AAGhB,QAIN,eAAA,AAJM,CACLA,MAAY,CAAE,CAAAC,QAAuC,CAGtD,AAFS;AACR,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": 3, "file": "js/std/regex.js", "sources": [ "std/regex/regex.temper.md" ], "sourcesContent": [ "# Regex Data Model and Functionality\n\nThe structural data model for regex patterns enables direct construction, and\nthe Temper regex dialect compiles static regex text patterns to these objects.\n\nA focus here is on providing tools people can actually reach for when they need\nto do text processing. The execution should be faster on backends like Python\nthan writing raw code, and the implementation in backends like C should\napproximate what you'd like to have written manually.\n\nDue to inadequate and distinct Unicode handling in backend regex engines, the\ninitial feature set avoids character classes and properties but is still aware\nof code points. Parsing focused on limited sets of delimiters works best for\nnow.\n\nThe core feature set here focuses on both the data model and utility functions,\nsuch as matching regexes against strings.\n\n## Regex Data Model\n\nTemper regex representation is composed hierarchically of `RegexNode` objects.\nAnd perhaps the most fundamental `RegexNode` is the [Sequence](#sequence),\nbecause it enables multiple regex components to be strung together. For example,\n`/hi./` is a sequence of [CodePoints](#codepoints) `/hi/` and dot `/./`, but all\ncomponent types extend the `RegexNode` interface.\n\n```\nexport interface RegexNode {\n```\n\nBefore a regex is used, it must be compiled. This transforms a `RegexNode` tree\ninto a backend-native [Regex](#regex). Some helper functions compile on the fly,\nalthough it is faster to reuse a pre-compiled regex.\n\n```\n // TODO(tjp, regex): Make this into a macro behind the scenes.\n // TODO(tjp, regex): `compiled\u003cT\u003e(): Regex\u003cT\u003e`\n public compiled(): Regex { new Regex(this) }\n```\n\nThe simplest use of a regular expression is if it is found in a string.\nAgain, it is better to compile to a `Regex` in advance than to repeatedly call\nconvenience methods on a `RegexNode`.\n\nTODO Remove convenience methods on RegexNode since we emphasize CompiledRegex\nnow?\n\n```\n public found(text: String): Boolean { compiled().found(text) }\n```\n\nYou can also return match details. The returned groups map contains an entry for\neach key in the order defined in the regex pattern. If no \u0022full\u0022 group is\ndefined, one is added automatically to capture the full matched text.\n\nIn the future, we intend to support customized match types with fields to match\ncapture groups, statically checked where possible.\n\n```\n // TODO(tjp, regex): Also macro because reification.\n\n public find(text: String): Match | Bubble {\n compiled().find(text)\n }\n```\n\nReplace and split functions are also available. Both apply to all matches in\nthe string, replacing all or splitting at all.\n\n```\n public replace(text: String, format: fn (Match): String): String {\n compiled().replace(text, format)\n }\n\n public split(text: String): List\u003cString\u003e {\n compiled().split(text)\n }\n```\n\nThat's it for what you can do with regex patterns in Temper today, but there's\nmuch more to say on what kinds of regexes can be built.\n\n```\n}\n```\n\n## Regex Item Types\n\nA `Regex` is composed of a potential variety of subtypes.\n\n### Groups\n\nMultiple types of groups exist:\n\n- [Capture](#capture) `/(?\u003cname\u003e...)/` to remember match groups for later use.\n- Non-capturing group syntax `/(?:...)/`, which is simply a [Regex](#regex)\n instance in the data model.\n\n### Capture\n\n`Capture` is a [group](#groups) that remembers the matched text for later\naccess. Temper supports only named matches, with current intended syntax\n`/(?name = ...)/`.\n\n```\nexport class Capture(\n public let name: String,\n public /*early*/ let item: RegexNode,\n) extends RegexNode {}\n```\n\n### CodePart\n\nA component of a [CodeSet][#codeset], aka character class, which applies to a\nsubset of regex data types.\n\nHere, \u0022code\u0022 is short for \u0022code point\u0022 although \u0022char\u0022 might work better,\ndepending on expectations.\n\n```\nexport interface CodePart extends RegexNode {}\n```\n\n### CodePoints\n\nOne or more verbatim code points, where the sequence matters if within a\n[Regex](#regex) or not if within a [CodeSet](#codeset). Some escapes in\ntextual regex source, such as `/\\t/`, can be stored as raw code points.\n\nThe `String` here can enable more efficient storage than individual code\npoints, although the source text may require non-capture grouping. For example,\n`/(?:abc)?/` optionally matches the string `\u0022abc\u0022`, whereas `/abc?/` matches\n`\u0022ab\u0022` with an optional `\u0022c\u0022`.\n\n```\nexport class CodePoints(\n public let value: String,\n) extends CodePart {}\n```\n\n### Specials\n\nA number of special match forms exist. In the data model, these are empty\nclasses.\n\n- `.` - `Dot` In default mode, matches any Unicode code point except newline.\n- `^` - `Begin` in default mode matches zero-length at the beginning of a\n string.\n- `\u0024` - `End` in default mode matches zero-length at the end of a string.\n- `\\b` - `WordBoundary` matches zero-length at the boundary between word and\n non-word code points. More sophisticated Unicode compliance is TBD.\n- `\\s` (negated as `\\S`) - `Space` matches any horizontal space code point.\n Details are TBD.\n- `\\w` (negated as `\\W`) - `Word` matches any word code point. Details are TBD.\n This is currently defined in terms of old ASCII definitions because those are\n clear. Perhaps this will stay that way, and Unicode properties like `\\p{L}`\n will be used for human language needs.\n- `\\X` - `GraphemeCluster` might not be supported, but [here is some discussion\n of how to implement it](\n https://github.com/rust-lang/regex/issues/54#issuecomment-661905060).\n\n\u003cdetails\u003e\n\n```\nexport interface Special extends RegexNode {}\nexport let Begin: Special = do { class Begin extends Special {}; new Begin() };\nexport let Dot: Special = do { class Dot extends Special {}; new Dot() };\nexport let End: Special = do { class End extends Special {}; new End() };\n// TODO(tjp, regex): We can't easily support this at present across backends.\n// export let GraphemeCluster = do {\n// class GraphemeCluster extends Special {}; new GraphemeCluster()\n// };\nexport let WordBoundary: Special = do {\n class WordBoundary extends Special {}; new WordBoundary()\n};\n\nexport interface SpecialSet extends CodePart \u0026 Special {}\nexport let Digit: SpecialSet = do {\n class Digit extends SpecialSet {}; new Digit()\n};\nexport let Space: SpecialSet = do {\n class Space extends SpecialSet {}; new Space()\n};\nexport let Word: SpecialSet = do {\n class Word extends SpecialSet {}; new Word()\n};\n```\n\n\u003c/details\u003e\n\n### CodeRange\n\nA code point range matches any code point in its inclusive bounds, such as\n`/[a-c]/`. In source, `-` is included in a code set either by escaping or by\nincluding it as the first or last character. A `CodeRange` is usually contained\ninside a [CodeSet](#codeset), and syntactically always is.\n\n```\nexport class CodeRange(\n public let min: Int,\n public let max: Int,\n) extends CodePart {}\n```\n\n### CodeSet\n\nA set of code points, any of which can match, such as `/[abc]/` matching any of\n`\u0022a\u0022`, `\u0022b\u0022`, or `\u0022c\u0022`. Alternatively, a negated set is the inverse of the code\npoints given, such as `/[^abc]/`, matching any code point that's not any of\nthese. This is also often called a character class.\n\nFurther, a subset of [specials](#specials) can also be used in code sets. A\nnegated code set of just a special set often has custom syntax. For example,\nnon-space can be said as either `/[^\\s]/` or `/\\S/`.\n\n```\nexport class CodeSet(\n public let items: List\u003cCodePart\u003e,\n public let negated: Boolean = false,\n) extends RegexNode {}\n```\n\n### Or\n\n`Or` matches any one of multiple options, such as `/ab|cd|e*/`.\n\n```\nexport class Or(\n public /*early*/ let items: List\u003cRegexNode\u003e,\n) extends RegexNode {}\n```\n\n### Repeat\n\n`Repeat` matches from an minimum to a maximum number of repeats of a\nsubregex. This can be represented in regex source in a number of ways:\n\n- `?` matches 0 or 1.\n- `*` matches 0 or more.\n- `+` matches 1 or more.\n- `{m}` matches exactly `m` repetitions.\n- `{m,n}` matches between `m` and `n`. Missing `n` is a max of infinity. For\n example, `{0,1}` is equivalent to `?`, and `{1,}` is equivalent to `+`.\n\nBy default, repetitions are greedy, matching as many repetitions as possible.\nIn regex source, any of the above can have `?` appended to indicated reluctant\n(aka non-greedy), matching as few repetitions as possible.\n\n```\nexport class Repeat(\n public /*early*/ let item: RegexNode,\n public let min: Int,\n public let max: Int?, // where null means infinite\n public let reluctant: Boolean = false,\n) extends RegexNode {}\n```\n\nWe also have convenience builders.\n\n```\nexport let entire(item: RegexNode): RegexNode {\n new Sequence([Begin, item, End])\n}\n\nexport let oneOrMore(item: RegexNode, reluctant: Boolean = false): Repeat {\n { item, min: 1, max: null, reluctant }\n}\n\nexport let optional(item: RegexNode, reluctant: Boolean = false): Repeat {\n { item, min: 0, max: 1, reluctant }\n}\n```\n\n### Sequence\n\n`Sequence` strings along multiple other regexes in order.\n\n```\nexport class Sequence(\n public /*early*/ let items: List\u003cRegexNode\u003e,\n) extends RegexNode {}\n```\n\n## Match Objects\n\nFor detailed match results, call `find` on a regex to get a `Match` object\nincluding a map from `String` keys to `Group` values. The iteration order of the\ngroup map is undefined.\n\nWe might support custom match types in the future with static properties instead\nof string-keyed groups. For example: `regex.find\u003cMyCapture\u003e(\u0022....\u0022)`\n\nTODO And sooner than that, we plan connected types for abstract mapping to\nbackend match objects that might not be maps.\n\n```\nexport class Match(\n public let full: Group,\n public let groups: Map\u003cString, Group\u003e,\n) {} // interface ... \u003cT = Map\u003cString, Group\u003e\u003e {\n\nexport class Group(\n public let name: String,\n public let value: String,\n public let begin: StringIndex,\n public let end: StringIndex,\n) {}\n```\n\n## Compiled Regex Objects\n\nThe compiled form of a regex is mostly opaque, but it can be cached for more\nefficient reuse than working from a source [RegexNode](#regex-data-model).\n\n\u003cdetails\u003e\n\n```\n// Provides a workaround for access to std/regex from extension methods that\n// sometimes get defined in temper-core for some backends. Also useful for\n// reference values for the interpreter.\n// TODO Avoid defining regex support in temper-core.\nclass RegexRefs(\n public let codePoints: CodePoints = new CodePoints(\u0022\u0022),\n public let group: Group = {\n name: \u0022\u0022, value: \u0022\u0022, begin: String.begin, end: String.begin\n },\n public let match: Match = {\n full: group,\n groups: new Map\u003cString, Group\u003e([new Pair(\u0022\u0022, group)]),\n },\n public let orObject: Or = new Or([]),\n) {}\n\nlet regexRefs = new RegexRefs();\n```\n\n\u003c/details\u003e\n\nTODO Make Regex a connected type for lighter weight usage?\n\n```\nexport class Regex {\n```\n\nThe source `Regex` data is still available on compiled objects in case it's\nneeded for composition or other purposes.\n\n```\n public let data: RegexNode;\n\n public constructor(data: RegexNode) {\n this.data = data;\n // TODO Pull formatting out of here into a separate library or module???\n let formatted = RegexFormatter.regexFormat(data);\n compiled = RegexFormatter.regexCompileFormatted(data, formatted);\n }\n```\n\nA compiled regex exposes many of the same capabilities as `RegexNode`, but they\nare more efficient to use repeatedly.\n\n```\n public found(text: String): Boolean {\n compiledFound(compiled, text)\n }\n\n public find(text: String, begin: StringIndex = String.begin): Match | Bubble {\n compiledFind(compiled, text, begin, regexRefs)\n }\n\n public replace(text: String, format: fn (Match): String): String {\n compiledReplace(compiled, text, format, regexRefs)\n }\n\n public split(text: String): List\u003cString\u003e {\n compiledSplit(compiled, text, regexRefs)\n }\n```\n\nTODO(tjp, regex): Any static checking for stable frontend regex values?\n\n\u003cdetails\u003e\n\n```\n private let compiled: AnyValue;\n\n // Extension functions on some backends need the private `compiled` value\n // passed in directly.\n @connected(\u0022Regex::compiledFound\u0022)\n private compiledFound(compiled: AnyValue, text: String): Boolean;\n\n @connected(\u0022Regex::compiledFind\u0022)\n private compiledFind(\n compiled: AnyValue, text: String, begin: StringIndex, regexRefs: RegexRefs\n ): Match | Bubble;\n\n @connected(\u0022Regex::compiledReplace\u0022)\n private compiledReplace(\n compiled: AnyValue,\n text: String,\n format: fn (Match): String,\n regexRefs: RegexRefs,\n ): String;\n\n @connected(\u0022Regex::compiledSplit\u0022)\n private compiledSplit(\n compiled: AnyValue,\n text: String,\n regexRefs: RegexRefs,\n ): List\u003cString\u003e;\n```\n\n\u003c/details\u003e\n\n```\n}\n```\n\n## Private implementation matters?\n\nSome regex logic can be shared across backends. These features aren't directly\nexported to the user, however.\n\nTODO But we do want this exported for pre-compiling where possible in backends.\n\nThe intent is that these support features only get included in compiled Temper\ncode if usage depends on dynamically constructed regexes. If all regex building\nis done as stable values, we hope to generated backend compiled regexes purely\nat Temper compile time.\n\n### RegexFormatter\n\n\u003cdetails\u003e\n\n```\nclass RegexFormatter {\n private let out: StringBuilder = new StringBuilder();\n\n @connected(\u0022Regex::compileFormatted\u0022)\n public static regexCompileFormatted(\n data: RegexNode, formatted: String\n ): AnyValue;\n\n @connected(\u0022Regex::format\u0022)\n public static regexFormat(data: RegexNode): String {\n new RegexFormatter().format(data)\n }\n\n public format(regex: RegexNode): String {\n pushRegex(regex)\n out.toString()\n }\n\n private pushRegex(regex: RegexNode): Void {\n when (regex) {\n // Aggregate types.\n is Capture -\u003e pushCapture(regex);\n is CodePoints -\u003e pushCodePoints(regex, false);\n is CodeRange -\u003e pushCodeRange(regex);\n is CodeSet -\u003e pushCodeSet(regex);\n is Or -\u003e pushOr(regex);\n is Repeat -\u003e pushRepeat(regex);\n is Sequence -\u003e pushSequence(regex);\n // Specials.\n // Some of these will need to be customized on future backends.\n Begin -\u003e out.append(\u0022^\u0022);\n Dot -\u003e out.append(\u0022.\u0022);\n End -\u003e out.append(\u0022\u0024\u0022);\n WordBoundary -\u003e out.append(\u0022\\\\b\u0022);\n // Special sets.\n Digit -\u003e out.append(\u0022\\\\d\u0022);\n Space -\u003e out.append(\u0022\\\\s\u0022);\n Word -\u003e out.append(\u0022\\\\w\u0022);\n // ...\n }\n }\n\n private pushCapture(capture: Capture): Void {\n out.append(\u0022(\u0022);\n // TODO(tjp, regex): Consistent name validation rules for all backends???\n // TODO(tjp, regex): Validate here or in `Capture` constructor???\n // TODO(tjp, regex): Validate here or where against reused names???\n pushCaptureName(out, capture.name);\n pushRegex(capture.item);\n out.append(\u0022)\u0022);\n }\n\n @connected(\u0022RegexFormatter::pushCaptureName\u0022)\n private pushCaptureName(out: StringBuilder, name: String): Void {\n // All so far except Python use this form.\n out.append(\u0022?\u003c\u0024{name}\u003e\u0022);\n }\n\n private pushCode(code: Int, insideCodeSet: Boolean): Void { do {\n // Goal here is to be pretty where commonly accepted by regex dialects.\n // Start with pretty escapes to avoid needing numeric escapes.\n let specialEscape = when (code) {\n Codes.carriageReturn -\u003e \u0022r\u0022;\n Codes.newline -\u003e \u0022n\u0022;\n Codes.tab -\u003e \u0022t\u0022;\n else -\u003e \u0022\u0022;\n };\n if (specialEscape != \u0022\u0022) {\n out.append(\u0022\\\\\u0022);\n out.append(specialEscape);\n return;\n }\n // Look up in table for ascii range.\n if (code \u003c= 0x7F) {\n let escapeNeed = escapeNeeds[code];\n if (\n escapeNeed == needsSimpleEscape ||\n (insideCodeSet \u0026\u0026 code == Codes.dash)\n ) {\n out.append(\u0022\\\\\u0022);\n out.append(String.fromCodePoint(code));\n return;\n } else if (escapeNeed == needsNoEscape) {\n out.append(String.fromCodePoint(code));\n return;\n }\n }\n // Not handled, so check additional ranges for plain vs numeric escape.\n if (\n code \u003e= Codes.supplementalMin || (\n code \u003e Codes.highControlMax \u0026\u0026\n !(\n (Codes.surrogateMin \u003c= code \u0026\u0026 code \u003c= Codes.surrogateMax) ||\n code == Codes.uint16Max\n )\n )\n ) {\n out.append(String.fromCodePoint(code));\n } else {\n // No pretty options above, so go numeric. Each backend often varies here.\n pushCodeTo(out, code, insideCodeSet);\n }\n } orelse panic() } // fromCodePoint bubbles\n\n @connected(\u0022RegexFormatter::pushCodeTo\u0022)\n private pushCodeTo(out: StringBuilder, code: Int, insideCodeSet: Boolean): Void;\n\n private pushCodePoints(codePoints: CodePoints, insideCodeSet: Boolean): Void {\n let value = codePoints.value;\n for (\n var index = String.begin;\n value.hasIndex(index);\n index = value.next(index)\n ) {\n pushCode(value[index], insideCodeSet);\n }\n }\n\n private pushCodeRange(codeRange: CodeRange): Void {\n out.append(\u0022[\u0022);\n pushCodeRangeUnwrapped(codeRange);\n out.append(\u0022]\u0022);\n }\n\n private pushCodeRangeUnwrapped(codeRange: CodeRange): Void {\n pushCode(codeRange.min, true);\n out.append(\u0022-\u0022);\n pushCode(codeRange.max, true);\n }\n\n private pushCodeSet(codeSet: CodeSet): Void {\n let adjusted = adjustCodeSet(codeSet, regexRefs);\n when (adjusted) {\n is CodeSet -\u003e do {\n out.append(\u0022[\u0022);\n if (adjusted.negated) {\n out.append(\u0022^\u0022);\n }\n for (var i = 0; i \u003c adjusted.items.length; i += 1) {\n pushCodeSetItem(adjusted.items[i]);\n }\n out.append(\u0022]\u0022);\n }\n else -\u003e pushRegex(adjusted);\n }\n }\n\n @connected(\u0022RegexFormatter::adjustCodeSet\u0022)\n private adjustCodeSet(codeSet: CodeSet, regexRefs: RegexRefs): RegexNode { codeSet }\n\n private pushCodeSetItem(codePart: CodePart): Void {\n when (codePart) {\n is CodePoints -\u003e pushCodePoints(codePart, true);\n is CodeRange -\u003e pushCodeRangeUnwrapped(codePart);\n is SpecialSet -\u003e pushRegex(codePart);\n }\n }\n\n private pushOr(or: Or): Void {\n if (!or.items.isEmpty) {\n out.append(\u0022(?:\u0022);\n // TODO(tjp, regex): See #822. Until `this` works better, no this in funs.\n // TODO(tjp, regex): So just manually loop here. Sometimes faster, anyway?\n pushRegex(or.items[0]);\n for (var i = 1; i \u003c or.items.length; i += 1) {\n out.append(\u0022|\u0022);\n pushRegex(or.items[i]);\n }\n out.append(\u0022)\u0022);\n }\n }\n\n private pushRepeat(repeat: Repeat): Void {\n // Always wrap the main sub-pattern here to make life easy\n out.append(\u0022(?:\u0022);\n pushRegex(repeat.item);\n out.append(\u0022)\u0022);\n // Then add the repetition part.\n let min = repeat.min;\n let max = repeat.max;\n if (false) {\n } else if (min == 0 \u0026\u0026 max == 1) {\n out.append(\u0022?\u0022);\n } else if (min == 0 \u0026\u0026 max == null) {\n out.append(\u0022*\u0022);\n } else if (min == 1 \u0026\u0026 max == null) {\n out.append(\u0022+\u0022);\n } else {\n out.append(\u0022{\u0024{min}\u0022);\n if (min != max) {\n out.append(\u0022,\u0022);\n if (max != null) {\n out.append(max.toString());\n }\n }\n out.append(\u0022}\u0022);\n }\n if (repeat.reluctant) {\n out.append(\u0022?\u0022);\n }\n }\n\n private pushSequence(sequence: Sequence): Void {\n // TODO(tjp, regex): Foreach loop/function would be nice.\n for (var i = 0; i \u003c sequence.items.length; i += 1) {\n pushRegex(sequence.items[i]);\n }\n }\n\n // Put this here instead of the data model for now because I'm not sure this\n // makes sense to be part of the public api right now.\n public maxCode(codePart: CodePart): Int? {\n when (codePart) {\n is CodePoints -\u003e do {\n // Iterating code points is the hardest of the current cases.\n let value = codePart.value;\n if (value.isEmpty) {\n null\n } else {\n // My kingdom for a fold, or even just a max, in builtins.\n var max = 0;\n for (\n var index = String.begin;\n value.hasIndex(index);\n index = value.next(index)\n ) {\n let next = value[index];\n if (next \u003e max) {\n max = next;\n }\n }\n max\n }\n }\n // Others below are easy for now.\n is CodeRange -\u003e codePart.max;\n Digit -\u003e Codes.digit9;\n Space -\u003e Codes.space;\n Word -\u003e Codes.lowerZ;\n // Actually unexpected, ever, but eh.\n else -\u003e null;\n }\n }\n}\n\n// Cache which chars you just but a blackslash in front of for escaping.\nlet escapeNeeds = buildEscapeNeeds();\nlet needsNoEscape = 0;\nlet needsNumericEscape = 1;\nlet needsSimpleEscape = 2;\nlet buildEscapeNeeds(): List\u003cInt\u003e {\n let escapeNeeds = new ListBuilder\u003cInt\u003e();\n for (var code = 0; code \u003c 0x7F; code += 1) {\n escapeNeeds.add(\n if (\n // Dash needs escaping in code sets, but we'll handle that specially.\n code == Codes.dash ||\n code == Codes.space ||\n code == Codes.underscore ||\n (Codes.digit0 \u003c= code \u0026\u0026 code \u003c= Codes.digit9) ||\n (Codes.upperA \u003c= code \u0026\u0026 code \u003c= Codes.upperZ) ||\n (Codes.lowerA \u003c= code \u0026\u0026 code \u003c= Codes.lowerZ)\n ) {\n needsNoEscape\n } else if (\n // Ampersand and tilde need escaped only in python for now, but meh.\n code == Codes.ampersand ||\n code == Codes.backslash ||\n code == Codes.caret ||\n code == Codes.curlyLeft ||\n code == Codes.curlyRight ||\n code == Codes.dot ||\n code == Codes.peso ||\n code == Codes.pipe ||\n code == Codes.plus ||\n code == Codes.question ||\n code == Codes.roundLeft ||\n code == Codes.roundRight ||\n code == Codes.slash ||\n code == Codes.squareLeft ||\n code == Codes.squareRight ||\n code == Codes.star ||\n code == Codes.tilde\n ) {\n needsSimpleEscape\n } else {\n // We'll also handle \\r, \\n, and \\t specially.\n needsNumericEscape\n },\n );\n }\n escapeNeeds.toList()\n}\n\nclass Codes {\n public static ampersand: Int = char'\u0026';\n public static backslash: Int = char'\\\\';\n public static caret: Int = char'^';\n public static carriageReturn: Int = char'\\r';\n public static curlyLeft: Int = char'{';\n public static curlyRight: Int = char'}';\n public static dash: Int = char'-';\n public static dot: Int = char'.';\n public static highControlMin: Int = 0x7F;\n public static highControlMax: Int = 0x9F;\n public static digit0: Int = char'0';\n public static digit9: Int = char'9';\n public static lowerA: Int = char'a';\n public static lowerZ: Int = char'z';\n public static newline: Int = char'\\n';\n public static peso: Int = char'\u0024';\n public static pipe: Int = char'|';\n public static plus: Int = char'+';\n public static question: Int = char'?';\n public static roundLeft: Int = char'(';\n public static roundRight: Int = char')';\n public static slash: Int = char'/';\n public static squareLeft: Int = char'[';\n public static squareRight: Int = char']';\n public static star: Int = char'*';\n public static tab: Int = char'\\t';\n public static tilde: Int = char'*';\n public static upperA: Int = char'A';\n public static upperZ: Int = char'Z';\n public static space: Int = char' ';\n public static surrogateMin: Int = 0xD800;\n public static surrogateMax: Int = 0xDFFF;\n public static supplementalMin: Int = 0x10000;\n public static uint16Max: Int = 0xFFFF;\n public static underscore: Int = char'_';\n}\n\n```\n\n\u003c/details\u003e\n" ], "names": [ "RegexNode", "Regex", "text", "format", "Capture", "name", "item", "CodePart", "CodePoints", "value", "Special", "SpecialSet", "CodeRange", "min", "max", "CodeSet", "items", "negated", "Or", "Repeat", "reluctant", "Sequence", "Match", "full", "groups", "Group", "begin", "end", "RegexRefs", "codePoints", "group", "match", "orObject", "data", "formatted", "RegexFormatter", "compiled", "regexRefs", "out", "regex", "pushRegex", "pushCapture", "pushCodePoints", "pushCodeRange", "pushCodeSet", "pushOr", "pushRepeat", "pushSequence", "Begin", "Dot", "End", "WordBoundary", "Digit", "Space", "Word", "capture", "pushCaptureName", "pushCode", "code", "insideCodeSet", "return", "fn", "specialEscape", "Codes", "escapeNeed", "escapeNeeds", "index", "codeRange", "pushCodeRangeUnwrapped", "codeSet", "adjusted", "i", "pushCodeSetItem", "codePart", "or", "repeat", "sequence", "next", "ampersand", "backslash", "caret", "carriageReturn", "curlyLeft", "curlyRight", "dash", "dot", "highControlMin", "highControlMax", "digit0", "digit9", "lowerA", "lowerZ", "newline", "peso", "pipe", "plus", "question", "roundLeft", "roundRight", "slash", "squareLeft", "squareRight", "star", "tab", "tilde", "upperA", "upperZ", "space", "surrogateMin", "surrogateMax", "supplementalMin", "uint16Max", "underscore", "buildEscapeNeeds", "entire", "oneOrMore", "optional" ], "mappings": "AA2BA;AAAA;AAAA;AAAiB,aAAAA,SAAA,iBAiDd,EAAA,AAvCM;AAAA;AAAqC,UAAA,AAArC,EAAqC,AAAnB;AAAE,cAAI,CAAAC,KAAK,CAAC,IAAI,CAAC;AAAA;AAWnC;AAAuD,OAAA,AAAvD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,CAAAb,QAAI,CAAO,EAAC,CAAO,EAAC,CAAE,CAAAc,aAAS,CAAE;AAAA,CACpC" }
package/temporal.js CHANGED
@@ -1,59 +1,109 @@
1
1
  import {
2
- modIntInt as modIntInt_299, listify as listify_69, intToString as intToString_190, stringCodePoints as stringCodePoints_140, strCat as strCat_129
2
+ JsonProducer as JsonProducer_1006, JsonSyntaxTree as JsonSyntaxTree_1011, InterchangeContext as InterchangeContext_1012, JsonAdapter as JsonAdapter_1013, JsonString as JsonString_1021
3
+ } from "./json.js";
4
+ import {
5
+ type as type__1014, requireInstanceOf as requireInstanceOf__1022, modIntInt as modIntInt_1029, stringGet as stringGet_1040, stringNext as stringNext_1041, stringCountBetween as stringCountBetween_1043
3
6
  } from "@temperlang/core";
4
- // Type nym`std//temporal.temper.md`.Date connected to globalThis.Date
7
+ class DateJsonAdapter_1001 extends type__1014(JsonAdapter_1013) {
8
+ /**
9
+ * @param {globalThis.Date} x_1003
10
+ * @param {JsonProducer_1006} p_1004
11
+ */
12
+ encodeToJson(x_1003, p_1004) {
13
+ encodeToJson_1005(x_1003, p_1004);
14
+ return;
15
+ }
16
+ /**
17
+ * @param {JsonSyntaxTree_1011} t_1008
18
+ * @param {InterchangeContext_1012} ic_1009
19
+ * @returns {globalThis.Date}
20
+ */
21
+ decodeFromJson(t_1008, ic_1009) {
22
+ return decodeFromJson_1010(t_1008, ic_1009);
23
+ }
24
+ constructor() {
25
+ super ();
26
+ return;
27
+ }
28
+ }
29
+ // Type `std/temporal/`.Date connected to globalThis.Date
30
+ /**
31
+ * @param {globalThis.Date} this_1015
32
+ * @param {JsonProducer_1006} p_1016
33
+ */
34
+ function encodeToJson_1005(this_1015, p_1016) {
35
+ let t_1017 = this_1015.toISOString().split("T")[0];
36
+ p_1016.stringValue(t_1017);
37
+ return;
38
+ }
39
+ /**
40
+ * @param {JsonSyntaxTree_1011} t_1018
41
+ * @param {InterchangeContext_1012} ic_1019
42
+ * @returns {globalThis.Date}
43
+ */
44
+ function decodeFromJson_1010(t_1018, ic_1019) {
45
+ let t_1020;
46
+ t_1020 = requireInstanceOf__1022(t_1018, JsonString_1021);
47
+ return new (globalThis.Date)(globalThis.Date.parse(t_1020.content));
48
+ }
49
+ /** @returns {JsonAdapter_1013<globalThis.Date>} */
50
+ function jsonAdapter_1023() {
51
+ return new DateJsonAdapter_1001();
52
+ }
5
53
  /** @type {Array<number>} */
6
- const daysInMonth_294 = listify_69(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
54
+ const daysInMonth_1024 = Object.freeze([0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]);
7
55
  /**
8
- * @param {number} year_296
56
+ * @param {number} year_1026
9
57
  * @returns {boolean}
10
58
  */
11
- function isLeapYear_295(year_296) {
12
- let return_297;
13
- let t_298;
14
- if (modIntInt_299(year_296, 4) === 0) {
15
- if (modIntInt_299(year_296, 100) !== 0) {
16
- return_297 = true;
59
+ function isLeapYear_1025(year_1026) {
60
+ let return_1027;
61
+ let t_1028;
62
+ if (modIntInt_1029(year_1026, 4) === 0) {
63
+ if (modIntInt_1029(year_1026, 100) !== 0) {
64
+ return_1027 = true;
17
65
  } else {
18
- t_298 = modIntInt_299(year_296, 400);
19
- return_297 = t_298 === 0;
66
+ t_1028 = modIntInt_1029(year_1026, 400);
67
+ return_1027 = t_1028 === 0;
20
68
  }
21
69
  } else {
22
- return_297 = false;
70
+ return_1027 = false;
23
71
  }
24
- return return_297;
72
+ return return_1027;
25
73
  }
26
74
  /**
27
- * @param {string} padding_301
28
- * @param {number} num_302
29
- * @returns {string}
75
+ * @param {number} minWidth_1031
76
+ * @param {number} num_1032
77
+ * @param {globalThis.Array<string>} sb_1033
30
78
  */
31
- function pad_300(padding_301, num_302) {
32
- let return_303;
33
- let t_304;
34
- const decimal_305 = intToString_190(num_302, 10);
35
- let t_306 = stringCodePoints_140(decimal_305);
36
- let decimalCodePoints_307 = t_306;
37
- let sign_308;
38
- if (decimalCodePoints_307.read() === 45) {
39
- sign_308 = "-";
40
- t_304 = decimalCodePoints_307.advance(1);
41
- decimalCodePoints_307 = t_304;
79
+ function padTo_1030(minWidth_1031, num_1032, sb_1033) {
80
+ let t_1034;
81
+ let t_1035;
82
+ let t_1036;
83
+ const decimal_1037 = num_1032.toString(10);
84
+ let decimalIndex_1038 = 0;
85
+ const decimalEnd_1039 = decimal_1037.length;
86
+ if (decimalIndex_1038 < decimalEnd_1039) {
87
+ t_1034 = stringGet_1040(decimal_1037, decimalIndex_1038);
88
+ t_1036 = t_1034 === 45;
42
89
  } else {
43
- sign_308 = "";
90
+ t_1036 = false;
44
91
  }
45
- const paddingCp_309 = stringCodePoints_140(padding_301);
46
- const nNeeded_310 = paddingCp_309.length - decimalCodePoints_307.length;
47
- if (nNeeded_310 <= 0) {
48
- return_303 = decimal_305;
49
- } else {
50
- const pad_311 = paddingCp_309.limit(nNeeded_310).toString();
51
- const decimalOnly_312 = decimalCodePoints_307.toString();
52
- return_303 = strCat_129(sign_308, pad_311, decimalOnly_312);
92
+ if (t_1036) {
93
+ sb_1033[0] += "-";
94
+ t_1035 = stringNext_1041(decimal_1037, decimalIndex_1038);
95
+ decimalIndex_1038 = t_1035;
96
+ }
97
+ let t_1042 = stringCountBetween_1043(decimal_1037, decimalIndex_1038, decimalEnd_1039);
98
+ let nNeeded_1044 = minWidth_1031 - t_1042;
99
+ while (nNeeded_1044 > 0) {
100
+ sb_1033[0] += "0";
101
+ nNeeded_1044 = nNeeded_1044 - 1;
53
102
  }
54
- return return_303;
103
+ sb_1033[0] += decimal_1037.substring(decimalIndex_1038, decimalEnd_1039);
104
+ return;
55
105
  }
56
106
  /** @type {Array<number>} */
57
- const dayOfWeekLookupTableLeapy_313 = listify_69(0, 0, 3, 4, 0, 2, 5, 0, 3, 6, 1, 4, 6);
107
+ const dayOfWeekLookupTableLeapy_1045 = Object.freeze([0, 0, 3, 4, 0, 2, 5, 0, 3, 6, 1, 4, 6]);
58
108
  /** @type {Array<number>} */
59
- const dayOfWeekLookupTableNotLeapy_314 = listify_69(0, 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5);
109
+ const dayOfWeekLookupTableNotLeapy_1046 = Object.freeze([0, 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5]);
package/temporal.js.map CHANGED
@@ -1 +1 @@
1
- { "version": 3, "file": "js/std/temporal.js", "sources": [ "std/temporal.temper.md" ], "sourcesContent": [ "# Temporal\n\nWe're creating an initial Date type to help with developing\nTemper's machinery to connect to existing Date types in\ntarget languages.\n\nSome facts about the Gregorian calendar.\n\n /** Indexed by the month number: 1 = January */\n let daysInMonth = [\n 0,\n /* January */ 31,\n /* February */ 28, // Special case leap days\n /* March */ 31,\n /* April */ 30,\n /* May */ 31,\n /* June */ 30,\n /* July */ 31,\n /* August */ 31,\n /* September */ 30,\n /* October */ 31,\n /* November */ 30,\n /* December */ 31,\n ];\n\n let isLeapYear(year: Int): Boolean {\n year % 4 == 0 \u0026\u0026 (year % 100 != 0 || year % 400 == 0)\n }\n\n /**\n * If the decimal representation of \\|num\\| is longer than [padding],\n * then that representation.\n * Otherwise any sign for [num] followed by the prefix of [padding]\n * that would bring the integer portion up to the length of [padding].\n *\n * ```temper\n * pad(\u00220000\u0022, 123) == \u00220123\u0022) \u0026\u0026\n * pad(\u0022000\u0022, 123) == \u0022123\u0022) \u0026\u0026\n * pad(\u002200\u0022, 123) == \u0022123\u0022) \u0026\u0026\n * pad(\u00220000\u0022, -123) == \u0022-0123\u0022) \u0026\u0026\n * pad(\u0022000\u0022, -123) == \u0022-123\u0022) \u0026\u0026\n * pad(\u002200\u0022, -123) == \u0022-123\u0022)\n * ```\n */\n let pad(padding: String, num: Int): String {\n let decimal = num.toString(10);\n var decimalCodePoints = decimal.codePoints;\n let sign: String;\n if (decimalCodePoints.read() == 45 /* - */) {\n sign = \u0022-\u0022;\n decimalCodePoints = decimalCodePoints.advance(1);\n } else {\n sign = \u0022\u0022;\n }\n let paddingCp = padding.codePoints;\n let nNeeded = paddingCp.length - decimalCodePoints.length;\n if (nNeeded \u003c= 0) {\n decimal\n } else {\n let pad = paddingCp.limit(nNeeded).toString();\n let decimalOnly = decimalCodePoints.toString();\n \u0022\u0024{sign}\u0024{pad}\u0024{decimalOnly}\u0022\n }\n }\n\n // Relates months (one-indexed) to numbers used in day-of-week\n // computations non-leapy.\n let dayOfWeekLookupTableLeapy: List\u003cInt\u003e = [\n 0, // Not a month\n 0, 3, 4, 0, 2, 5, 0, 3, 6, 1, 4, 6,\n ];\n let dayOfWeekLookupTableNotLeapy: List\u003cInt\u003e = [\n 0, // Not a month\n 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5,\n ];\n\nHere's just enough of a Date type to get us started.\n\n /**\n * A Date identifies a day in the proleptic Gregorian calendar.\n * It is unconnected to a time of day or a timezone.\n */\n @connected(\u0022Date\u0022)\n export class Date {\n /** The year. 1900 means 1900. */\n @connected(\u0022Date::getYear\u0022)\n public year: Int;\n /** The month of the year in [1, 12]. */\n @connected(\u0022Date::getMonth\u0022)\n public month: Int;\n /**\n * The day of the month in [1, 31]\n * additionally constrained by the length of [month].\n */\n @connected(\u0022Date::getDay\u0022)\n public day: Int;\n\n @connected(\u0022Date::constructor\u0022)\n public constructor(year: Int, month: Int, day: Int): Void | Bubble {\n if (1 \u003c= month \u0026\u0026 month \u003c= 12 \u0026\u0026\n 1 \u003c= day \u0026\u0026 (\n (month != 2 || day != 29)\n ? day \u003c= daysInMonth[month]\n : isLeapYear(year))) {\n this.year = year;\n this.month = month;\n this.day = day;\n } else {\n bubble();\n }\n }\n\n /** An ISO 8601 Date string with dashes like \u00222000-12-31\u0022. */\n @connected(\u0022Date::toString\u0022)\n public toString(): String {\n \u0022\u0024{pad(\u00220000\u0022, year)\n }-\u0024{pad(\u002200\u0022, month)\n }-\u0024{pad(\u002200\u0022, day)}\u0022\n }\n\n /**\n * The count of whole years between the two dates.\n *\n * Think of this as floor of the magnitude of a range:\n *\n * ⌊ [start, end] ⌋\n *\n * If you think of it as subtraction, you have to reverse\n * the order of arguments.\n *\n * ⌊ end - start ⌋, NOT ⌊ start - end ⌋\n *\n * \u0022Whole year\u0022 is based on month/day calculations, not\n * day-of-year. This means that there is one full year\n * between 2020-03-01 and 2021-03-01 even though, because\n * February of 2020 has 29 days, 2020-03-01 is the 61st\n * day of 2020 but 2021-03-01 is only the 60th day of\n * that year.\n */\n @connected(\u0022Date::yearsBetween\u0022)\n public static let yearsBetween(start: Date, end: Date): Int {\n let yearDelta = end.year - start.year;\n let monthDelta = end.month - start.month;\n yearDelta - (\n // If the end month/day is before the start's then we\n // don't have a full year.\n (monthDelta \u003c 0 || monthDelta == 0 \u0026\u0026 end.day \u003c start.day)\n ? 1 : 0)\n }\n\n /** Today's date in UTC */\n // TODO: take a zone\n @connected(\u0022Date::today\u0022)\n public static let today(): Date;\n\n /**\n * ISO 8601 weekday number.\n *\n * | Number | Weekday |\n * | ------ | -------- |\n * | 1 | Monday |\n * | 2 | Tuesday |\n * | 3 | Monday |\n * | 4 | Thursday |\n * | 5 | Friday |\n * | 6 | Saturday |\n * | 7 | Sunday |\n */\n @connected(\u0022Date::getDayOfWeek\u0022)\n public get dayOfWeek(): Int {\n // Gauss's method.\n let y = year;\n let c = if (y \u003e= 0) { y / 100 } else { -(-y / 100) };\n let yy = y - (c * 100);\n // See note below about avoiding negative modulus to see why\n // some of the offsets differ from Wikipedia's rendering of\n // Gauss's formula.\n let janFirst = (8 + 5*((yy + 3) % 4) + 3*(yy - 1) + 5*(c % 4)) % 7;\n let table = if (isLeapYear(y)) {\n dayOfWeekLookupTableLeapy\n } else {\n dayOfWeekLookupTableNotLeapy\n };\n let monthOffset = table[month];\n // Gauss's method produces a number in 0..6 but\n // ISO assigns 1..7 where all values are the same\n // except that Sunday is 7 instead of 0.\n // Below we do (day + 6) since that is equivalent to\n // (day - 1) where we end up % 7 but avoids any chance\n // of a negative left operand to `%`.\n let gaussWeekday = (janFirst + (day + 6) + monthOffset) % 7;\n gaussWeekday == 0 ? 7 : gaussWeekday\n }\n };\n\nTODO: an auto-balancing Date builder.\nParse from ISO\nOther temporal values\nDay of week\n" ], "names": [ "daysInMonth", "isLeapYear", "year", "return", "pad", "padding", "num", "decimal", "decimalCodePoints", "sign", "paddingCp", "nNeeded", "decimalOnly", "dayOfWeekLookupTableLeapy", "dayOfWeekLookupTableNotLeapy" ], "mappings": "AASI;AAAA;AAAA;AA0Ea,sEA6GV;AAvLC,4BAAW;AAAf,KAAI,CAAAA,eAAW,EAAG,WAAC,CACjB,CAAC,CACe,GAAE,CACF,GAAE,CACF,GAAE,CACF,GAAE,CACF,GAAE,CACF,GAAE,CACF,GAAE,CACF,GAAE,CACF,GAAE,CACF,GAAE,CACF,GAAE,CACF,GAAE,CACnB;AAED,yDAEC;AAFD,QAAI,CAAAC,cAAU,AAAd,CAAeC,QAAS,CAEvB,AAFkC,EAAA;AAAR,MAAAC,UAAO;AACM,WAAU,CAAA;AAA/C,MAAK,aAAC,CAAA,AAAND,QAAI,CAAG,EAAC,KAAI,EAAC;AAAK,QAAK,aAAC,CAAA,AAANA,QAAI,CAAG,IAAG,KAAI,EAAC;AAAA,MAAAC,UAAA;AAAA;AAAI,aAAU,AAAL,cAAC,CAAA,AAAND,QAAI,CAAG,IAAG,EAAA;AAAV,MAAAC,UAAA,EAAe,AAAf,MAAU,IAAI,EAAC;AAAA;AAAA;AAAC,IAAAA,UAAA;AAAA;AACvD,QAAA,AAF0B,CAAAA,UAAA;AAE1B;AAiBD,sFAmBC;AAnBD,QAAI,CAAAC,OAAG,AAAP,CAAQC,WAAe,CAAE,CAAAC,OAAQ,CAmBhC,AAnB0C,EAAA;AAAP,MAAAH,UAAM;AAMlB,WAA4B,CAAA;AALlD,OAAI,CAAAI,WAAO,EAAO,gBAAQ,CAAA,AAAZD,OAAG,CAAU,GAAE,CAAC;AACN,WAAkB,EAAA,AAAV,qBAAU,CAAA,AAAlBC,WAAO,CAAW,CAAA;AAAvC,KAAC,CAAAC,qBAAiB,EAAG,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CAAE,EAAC,CAAE,EAAC,CAAE,EAAC,CAAE,EAAC,CAAE,EAAC,CAAE,EAAC,CACnC" }
1
+ { "version": 3, "file": "js/std/temporal.js", "sourceRoot": "std/", "sources": [ "temporal/temporal.temper.md", "json/json.temper.md" ], "sourcesContent": [ "# Temporal\n\nWe're creating an initial Date type to help with developing\nTemper's machinery to connect to existing Date types in\ntarget languages.\n\nSome facts about the Gregorian calendar.\n\n /** Indexed by the month number: 1 = January */\n let daysInMonth = [\n 0,\n /* January */ 31,\n /* February */ 28, // Special case leap days\n /* March */ 31,\n /* April */ 30,\n /* May */ 31,\n /* June */ 30,\n /* July */ 31,\n /* August */ 31,\n /* September */ 30,\n /* October */ 31,\n /* November */ 30,\n /* December */ 31,\n ];\n\n let isLeapYear(year: Int): Boolean {\n year % 4 == 0 \u0026\u0026 (year % 100 != 0 || year % 400 == 0)\n }\n\n /**\n * If the decimal representation of \\|num\\| is longer than [minWidth],\n * then appends that representation.\n * Otherwise any sign for [num] followed by enough zeroes to bring the\n * whole length up to [minWidth].\n *\n * ```temper\n * // When the width is greater than the decimal's length,\n * // we pad to that width.\n * \u00220123\u0022 == do {\n * let sb = new StringBuilder();\n * padTo(4, 123, sb);\n * sb.toString()\n * }\n *\n * // When the width is the same or lesser, we just use the string form.\n * \u0022123\u0022 == do {\n * let sb = new StringBuilder();\n * padTo(2, 123, sb);\n * sb.toString()\n * }\n *\n * // The sign is always on the left.\n * \u0022-01\u0022 == do {\n * let sb = new StringBuilder();\n * padTo(3, -1, sb);\n * sb.toString()\n * }\n * ```\n */\n let padTo(minWidth: Int, num: Int, sb: StringBuilder): Void {\n let decimal = num.toString(10);\n var decimalIndex = String.begin;\n let decimalEnd = decimal.end;\n if (decimalIndex \u003c decimalEnd \u0026\u0026 decimal[decimalIndex] == char'-') {\n sb.append(\u0022-\u0022);\n decimalIndex = decimal.next(decimalIndex);\n }\n var nNeeded = minWidth - decimal.countBetween(decimalIndex, decimalEnd);\n while (nNeeded \u003e 0) {\n sb.append('0');\n nNeeded -= 1;\n }\n sb.appendBetween(decimal, decimalIndex, decimalEnd);\n }\n\n // Relates months (one-indexed) to numbers used in day-of-week\n // computations non-leapy.\n let dayOfWeekLookupTableLeapy: List\u003cInt\u003e = [\n 0, // Not a month\n 0, 3, 4, 0, 2, 5, 0, 3, 6, 1, 4, 6,\n ];\n let dayOfWeekLookupTableNotLeapy: List\u003cInt\u003e = [\n 0, // Not a month\n 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5,\n ];\n\nHere's just enough of a Date type to get us started.\n\n /**\n * A Date identifies a day in the proleptic Gregorian calendar.\n * It is unconnected to a time of day or a timezone.\n */\n @json\n @connected(\u0022Date\u0022)\n export class Date {\n /** The year. 1900 means 1900. */\n @connected(\u0022Date::getYear\u0022)\n public year: Int;\n /** The month of the year in [1, 12]. */\n @connected(\u0022Date::getMonth\u0022)\n public month: Int;\n /**\n * The day of the month in [1, 31]\n * additionally constrained by the length of [month].\n */\n @connected(\u0022Date::getDay\u0022)\n public day: Int;\n\n @connected(\u0022Date::constructor\u0022)\n public constructor(year: Int, month: Int, day: Int): Void | Bubble {\n if (1 \u003c= month \u0026\u0026 month \u003c= 12 \u0026\u0026\n 1 \u003c= day \u0026\u0026 (\n if (month != 2 || day != 29) {\n day \u003c= daysInMonth[month]\n } else {\n isLeapYear(year)\n })) {\n this.year = year;\n this.month = month;\n this.day = day;\n } else {\n bubble();\n }\n }\n\n /** An ISO 8601 Date string with dashes like \u00222000-12-31\u0022. */\n @connected(\u0022Date::toString\u0022)\n public toString(): String {\n let sb = new StringBuilder();\n padTo(4, year, sb);\n sb.append(\u0022-\u0022);\n padTo(2, month, sb);\n sb.append(\u0022-\u0022);\n padTo(2, day, sb);\n return sb.toString();\n }\n\n /** Parses a Date from an ISO 8601 Date string with dashes like \u00222000-12-21\u0022. */\n @connected(\u0022Date::fromIsoString\u0022)\n public static fromIsoString(isoString: String): Date | Bubble {\n let end = isoString.end;\n var strIndex = isoString.prev(isoString.prev(end));\n // strIndex at '^'\n // YYYY-MM-^DD\n let beforeDay = strIndex;\n strIndex = isoString.prev(strIndex);\n // YYYY-MM^-DD\n let afterMonth = strIndex;\n if (!isoString.hasIndex(afterMonth) || isoString[strIndex] != char'-') {\n bubble();\n }\n strIndex = isoString.prev(isoString.prev(strIndex));\n // YYYY-^MM-DD\n let beforeMonth = strIndex;\n strIndex = isoString.prev(strIndex);\n // YYYY^-MM-DD\n if (isoString[strIndex] != char'-' ||\n !isoString.hasAtLeast(String.begin, strIndex, 4)) {\n bubble();\n }\n let day = isoString.slice(beforeDay, end) .toInt(10);\n let month = isoString.slice(beforeMonth, afterMonth).toInt(10);\n let year = isoString.slice(String.begin, strIndex) .toInt(10);\n return new Date(year, month, day);\n }\n\n /**\n * The count of whole years between the two dates.\n *\n * Think of this as floor of the magnitude of a range:\n *\n * ⌊ [start, end] ⌋\n *\n * If you think of it as subtraction, you have to reverse\n * the order of arguments.\n *\n * ⌊ end - start ⌋, NOT ⌊ start - end ⌋\n *\n * \u0022Whole year\u0022 is based on month/day calculations, not\n * day-of-year. This means that there is one full year\n * between 2020-03-01 and 2021-03-01 even though, because\n * February of 2020 has 29 days, 2020-03-01 is the 61st\n * day of 2020 but 2021-03-01 is only the 60th day of\n * that year.\n */\n @connected(\u0022Date::yearsBetween\u0022)\n public static let yearsBetween(start: Date, end: Date): Int {\n let yearDelta = end.year - start.year;\n let monthDelta = end.month - start.month;\n yearDelta - (\n // If the end month/day is before the start's then we\n // don't have a full year.\n if (monthDelta \u003c 0 || monthDelta == 0 \u0026\u0026 end.day \u003c start.day) {\n 1\n } else {\n 0\n })\n }\n\n /** Today's date in UTC */\n // TODO: take a zone\n @connected(\u0022Date::today\u0022)\n public static let today(): Date;\n\n /**\n * ISO 8601 weekday number.\n *\n * | Number | Weekday |\n * | ------ | -------- |\n * | 1 | Monday |\n * | 2 | Tuesday |\n * | 3 | Monday |\n * | 4 | Thursday |\n * | 5 | Friday |\n * | 6 | Saturday |\n * | 7 | Sunday |\n */\n @connected(\u0022Date::getDayOfWeek\u0022)\n public get dayOfWeek(): Int {\n // Gauss's method.\n let y = year;\n let c = if (y \u003e= 0) { y / 100 } else { -(-y / 100) };\n let yy = y - (c * 100);\n // See note below about avoiding negative modulus to see why\n // some of the offsets differ from Wikipedia's rendering of\n // Gauss's formula.\n let janFirst = (8 + 5*((yy + 3) % 4) + 3*(yy - 1) + 5*(c % 4)) % 7;\n let table = if (isLeapYear(y)) {\n dayOfWeekLookupTableLeapy\n } else {\n dayOfWeekLookupTableNotLeapy\n };\n let monthOffset = table[month];\n // Gauss's method produces a number in 0..6 but\n // ISO assigns 1..7 where all values are the same\n // except that Sunday is 7 instead of 0.\n // Below we do (day + 6) since that is equivalent to\n // (day - 1) where we end up % 7 but avoids any chance\n // of a negative left operand to `%`.\n let gaussWeekday = (janFirst + (day + 6) + monthOffset) % 7;\n if (gaussWeekday == 0) { 7 } else { gaussWeekday }\n }\n\n public encodeToJson(p: JsonProducer): Void {\n p.stringValue(toString());\n }\n\n public static decodeFromJson(\n t: JsonSyntaxTree,\n ic: InterchangeContext,\n ): Date | Bubble {\n Date.fromIsoString((t as JsonString).content)\n }\n };\n\nDates marshal to and from JSON via the ISO string form.\n\n let {\n InterchangeContext,\n JsonProducer,\n JsonString,\n JsonSyntaxTree\n } = import(\u0022../json\u0022);\n\nTODO: an auto-balancing Date builder.\nOther temporal values\nDay of week\n", "# JSON support\n\nThe `@json` decorator for Temper classes supports converting values to\nand from the JSON data interchange format.\n\nThis module provides JSON value representations to support\nunmarshalling, converting a JSON text to domain value(s), and it\nprovides a JSON builder to support marshalling domain values to JSON.\n\n## Standard\n\nFor the purposes of this document, \u0022JSON\u0022 is defined by [ECMA-404],\n\u0022*The JSON data interchange syntax*.\u0022\n\n## Context\n\nProducers and consumers may need to engage in [content negotiation].\n\nFor example, a marshaller might benefit from having access to a version\nheader from a Web API request to distinguish clients that can accept the\nlatest version from those that need a deprecated version.\n\n export interface InterchangeContext {\n public getHeader(headerName: String): String?;\n }\n\nAnd for convenience, here's a blank interchange context.\n\n export class NullInterchangeContext extends InterchangeContext {\n public getHeader(headerName: String): String? { null }\n\n public static instance = new NullInterchangeContext();\n }\n\n## Marshalling support\n\n export interface JsonProducer {\n public interchangeContext: InterchangeContext;\n\n // A JSON object value is specified by a start-object\n // event, zero or more property key/value pairs\n // (see below) and an end-object event.\n\n public startObject(): Void;\n public endObject(): Void;\n\n // Within the start and end of an object\n // you may have zero or more pairs of\n // a property key followed by a nested value.\n\n public objectKey(key: String): Void;\n\n // To emit an array, start it, emit\n // zero or more nested values, then end it.\n\n public startArray(): Void;\n public endArray(): Void;\n\n // Emitters for simple values\n\n public nullValue(): Void;\n public booleanValue(x: Boolean): Void;\n\n // Numeric values come in several flavours\n\n public intValue(x: Int): Void;\n public float64Value(x: Float64): Void;\n /**\n * A number that fits the JSON number grammar to allow\n * interchange of numbers that are not easily represntible\n * using numeric types that Temper connects to.\n */\n public numericTokenValue(x: String): Void;\n\n public stringValue(x: String): Void;\n\n public get parseErrorReceiver(): JsonParseErrorReceiver? { null }\n }\n\nThis API does allow for specifying malformed JSON outputs as below.\nImplementations must allow for such specifications until allowing\nfor observation of the produced output.\nA streaming JSON implementation may treat flushing a portion of\noutput to an output channel as an observation and expose an error\nthen.\n\nAn implementation may choose to treat a number of top-level values\nother than one (`[] []`) as well-formed or malformed, for example to\nsupport related interchange formats like [JSON Lines].\n\nAn implementation may use a variety of strategies to represent\ntraditionally unrepresentable values like special floating point\n*NaN* (not a number) and ±infinities.\n\nAn implementation may use a variety of strategies to deal with\na valid JSON string value (whether used as a property key or a value)\nthat is not a [scalar value string], for example, because it contains a\nUTF-16 surrogate that is not part of a well-formed surrogate pair.\n\n```temper inert\n//// Malformed object\nmyJsonProducer1.startObject();\n// no end for object or array\n\n// misisng start for object or array\nmyJsonProducer2.endObject();\n\n// mismatch start and end\nmyJsonProducer3.startArray();\nmyJsonProducer3.endObject();\n\n// malformed properties\nmyJsonProducer4.startObject();\n// missing key\nmyJsonProducer4.nullValue();\nmyJsonProducer4.endObject();\n\nmyJsonProducer5.startObject();\nmyJsonProducer5.objectKey(\u0022k\u0022);\n// missing value\nmyJsonProducer5.endObject();\n\n//// Malformed values\n// questionable numbers\nmyJsonProducer6.float64Value(NaN);\nmyJsonProducer7.float64Value(Infinity);\nmyJsonProducer8.numericTokenValue(\u00221.\u0022);\n// questionable strings\nmyJsonProducer9.stringValue(\u0022\\uD800\u0022);\n\n//// No unique top-level value (see MAY above)\nmyJsonProducer10.nullValue();\nmyJsonProducer11.nullValue();\n```\n\n## Unmarshalling support\n\nUnmarshalling involves turning JSON source texts (which specify state)\ninto domain values (with state and behaviour).\n\nIt is convenient to have a syntax tree for JSON. Often, unmarshalling\ninvolves looking at select object properties to figure out how to interpret\nthe whole, by trying rules like the below:\n\n- if it has keys `x` and `y`, delegate to the *Point2d* unmarshaller,\n- or if it has keys `radius` and `centroid`, delegate to the *Circle* unmarshaller,\n- ...\n\nThere may not be an order of keys that makes it easy to consume a stream of\nevents to implement those rules, and expecting all producers to use the same\nkey order would lead to brittle unmarshalling.\n\n export sealed interface JsonSyntaxTree {\n public produce(p: JsonProducer): Void;\n }\n\n export class JsonObject(\n public properties: Map\u003cString, List\u003cJsonSyntaxTree\u003e\u003e,\n ) extends JsonSyntaxTree {\n\n /**\n * The JSON value tree associated with the given property key or null\n * if there is no such value.\n *\n * The properties map contains a list of sub-trees because JSON\n * allows duplicate properties. ECMA-404 §6 notes (emphasis added):\n *\n * \u003e The JSON syntax does not impose any restrictions on the strings\n * \u003e used as names, **does not require that name strings be unique**,\n * \u003e and does not assign any significance to the ordering of\n * \u003e name/value pairs.\n *\n * When widely used JSON parsers need to relate a property key\n * to a single value, they tend to prefer the last key/value pair\n * from a JSON object. For example:\n *\n * JS:\n *\n * JSON.parse('{\u0022x\u0022:\u0022first\u0022,\u0022x\u0022:\u0022last\u0022}').x === 'last'\n *\n * Python:\n *\n * import json\n * json.loads('{\u0022x\u0022:\u0022first\u0022,\u0022x\u0022:\u0022last\u0022}')['x'] == 'last'\n *\n * C#:\n *\n * using System.Text.Json;\n * \t\tJsonDocument d = JsonDocument.Parse(\n * \t\t\t\u0022\u0022\u0022\n * \t\t\t{\u0022x\u0022:\u0022first\u0022,\u0022x\u0022:\u0022last\u0022}\n * \t\t\t\u0022\u0022\u0022\n * \t\t);\n * \t\td.RootElement.GetProperty(\u0022x\u0022).GetString() == \u0022last\u0022\n */\n public propertyValueOrNull(propertyKey: String): JsonSyntaxTree? {\n let treeList = this.properties.getOr(propertyKey, []);\n\n let lastIndex = treeList.length - 1;\n if (lastIndex \u003e= 0) {\n treeList[lastIndex]\n } else {\n null\n }\n }\n\n public propertyValueOrBubble(propertyKey: String): JsonSyntaxTree | Bubble {\n propertyValueOrNull(propertyKey) as JsonSyntaxTree\n }\n\n public produce(p: JsonProducer): Void {\n p.startObject();\n properties.forEach { (k: String, vs: List\u003cJsonSyntaxTree\u003e);;\n vs.forEach { (v: JsonSyntaxTree);;\n p.objectKey(k);\n v.produce(p);\n }\n }\n p.endObject();\n }\n }\n\n export class JsonArray(\n public elements: List\u003cJsonSyntaxTree\u003e,\n ) extends JsonSyntaxTree {\n\n public produce(p: JsonProducer): Void {\n p.startArray();\n elements.forEach { (v: JsonSyntaxTree);;\n v.produce(p);\n }\n p.endArray();\n }\n }\n\n export class JsonBoolean(\n public content: Boolean,\n ) extends JsonSyntaxTree {\n public produce(p: JsonProducer): Void {\n p.booleanValue(content);\n }\n }\n\n export class JsonNull extends JsonSyntaxTree {\n public produce(p: JsonProducer): Void {\n p.nullValue();\n }\n }\n\n export class JsonString(\n public content: String,\n ) extends JsonSyntaxTree {\n public produce(p: JsonProducer): Void {\n p.stringValue(content);\n }\n }\n\n export sealed interface JsonNumeric extends JsonSyntaxTree {\n public asJsonNumericToken(): String;\n\n public asInt(): Int | Bubble;\n public asFloat64(): Float64 | Bubble;\n }\n\n export class JsonInt(\n public content: Int,\n ) extends JsonNumeric {\n public produce(p: JsonProducer): Void {\n p.intValue(content);\n }\n\n public asJsonNumericToken(): String {\n content.toString()\n }\n\n public asInt(): Int { content }\n\n public asFloat64(): Float64 | Bubble { content.toFloat64() }\n }\n\n export class JsonFloat64(\n public content: Float64,\n ) extends JsonNumeric {\n public produce(p: JsonProducer): Void {\n p.float64Value(content);\n }\n\n public asJsonNumericToken(): String {\n content.toString()\n }\n\n public asInt(): Int | Bubble { content.toInt() }\n\n public asFloat64(): Float64 { content }\n }\n\n export class JsonNumericToken(\n public content: String,\n ) extends JsonNumeric {\n public produce(p: JsonProducer): Void {\n p.numericTokenValue(content);\n }\n\n public asJsonNumericToken(): String {\n content\n }\n\n public asInt(): Int | Bubble {\n content.toInt() orelse content.toFloat64().toInt()\n }\n\n public asFloat64(): Float64 | Bubble { content.toFloat64() }\n }\n\nThe *produce* method allows a JSON syntax tree to describe itself to a\nJSON producer so JSON syntax trees, while useful during unmarshalling\ncan also help with marshalling.\n\n## Producing JSON text\n\nA JSON producer that appends to an internal buffer lets us produce\nJSON source text.\n\n // A state machine lets us figure out when to insert commas.\n let JSON_STATE_OPEN_OBJECT = 0; // Last was \u0022{\u0022\n let JSON_STATE_AFTER_KEY = 1; // Last was property key\n let JSON_STATE_AFTER_PROPERTY = 2; // Last was property value\n let JSON_STATE_OPEN_ARRAY = 3; // Last was \u0022[\u0022\n let JSON_STATE_AFTER_ELEMENT = 4; // Last was array element\n let JSON_STATE_NO_VALUE = 5;\n let JSON_STATE_ONE_VALUE = 6;\n\n export class JsonTextProducer extends JsonProducer {\n public interchangeContext: InterchangeContext;\n private buffer: StringBuilder;\n private stack: ListBuilder\u003cInt\u003e;\n private var wellFormed: Boolean;\n\n public constructor(\n interchangeContext: InterchangeContext = NullInterchangeContext.instance\n ): Void {\n this.interchangeContext = interchangeContext;\n this.buffer = new StringBuilder();\n this.stack = new ListBuilder\u003cInt\u003e();\n this.stack.add(JSON_STATE_NO_VALUE);\n this.wellFormed = true;\n }\n\n private state(): Int {\n stack.getOr(stack.length - 1, -1)\n }\n\n private beforeValue(): Void {\n let currentState = state();\n when (currentState) {\n JSON_STATE_OPEN_ARRAY -\u003e\n stack[stack.length - 1] = JSON_STATE_AFTER_ELEMENT;\n JSON_STATE_AFTER_ELEMENT -\u003e buffer.append(\u0022,\u0022);\n JSON_STATE_AFTER_KEY -\u003e\n stack[stack.length - 1] = JSON_STATE_AFTER_PROPERTY;\n JSON_STATE_NO_VALUE -\u003e\n stack[stack.length - 1] = JSON_STATE_ONE_VALUE;\n JSON_STATE_ONE_VALUE, JSON_STATE_AFTER_PROPERTY -\u003e\n wellFormed = false;\n }\n }\n\n public startObject(): Void {\n beforeValue();\n buffer.append(\u0022{\u0022);\n stack.add(JSON_STATE_OPEN_OBJECT);\n }\n\n public endObject(): Void {\n buffer.append(\u0022}\u0022);\n let currentState = state();\n if (JSON_STATE_OPEN_OBJECT == currentState ||\n JSON_STATE_AFTER_PROPERTY == currentState) {\n stack.removeLast();\n } else {\n wellFormed = false;\n }\n }\n\n public objectKey(key: String): Void {\n let currentState = state();\n when (currentState) {\n JSON_STATE_OPEN_OBJECT -\u003e void;\n JSON_STATE_AFTER_PROPERTY -\u003e buffer.append(\u0022,\u0022);\n else -\u003e wellFormed = false;\n }\n encodeJsonString(key, buffer);\n buffer.append(\u0022:\u0022);\n if (currentState \u003e= 0) {\n stack[stack.length - 1] = JSON_STATE_AFTER_KEY;\n }\n }\n\n public startArray(): Void {\n beforeValue();\n buffer.append(\u0022[\u0022);\n stack.add(JSON_STATE_OPEN_ARRAY);\n }\n\n public endArray(): Void {\n buffer.append(\u0022]\u0022);\n let currentState = state();\n if (JSON_STATE_OPEN_ARRAY == currentState ||\n JSON_STATE_AFTER_ELEMENT == currentState) {\n stack.removeLast();\n } else {\n wellFormed = false;\n }\n }\n\n public nullValue(): Void {\n beforeValue();\n buffer.append(\u0022null\u0022);\n }\n\n public booleanValue(x: Boolean): Void {\n beforeValue();\n buffer.append(if (x) { \u0022true\u0022 } else { \u0022false\u0022 });\n }\n\n public intValue(x: Int): Void {\n beforeValue();\n buffer.append(x.toString());\n }\n\n public float64Value(x: Float64): Void {\n beforeValue();\n buffer.append(x.toString());\n }\n\n public numericTokenValue(x: String): Void {\n // TODO check syntax of x and maybe set malformed\n beforeValue();\n buffer.append(x);\n }\n\n public stringValue(x: String): Void {\n beforeValue();\n encodeJsonString(x, buffer);\n }\n\n public toJsonString(): String | Bubble {\n if (wellFormed \u0026\u0026 stack.length == 1 \u0026\u0026 state() == JSON_STATE_ONE_VALUE) {\n return buffer.toString();\n } else {\n bubble();\n }\n }\n }\n\n let encodeJsonString(x: String, buffer: StringBuilder): Void {\n buffer.append(\u0022\\\u0022\u0022);\n var i = String.begin;\n var emitted = i;\n while (x.hasIndex(i)) {\n // The choice of which code-points to escape and which\n // escape sequences to use is the same as those made in\n // ES262 § 25.5.2.3: QuoteJSONString\n // as long as the string has no orphaned surrogates.\n // This means that the output will work in many parsers\n // while still allowing use of JSON.stringify in JavaScript\n // where keeping code-size low by not shipping a JSON encoder\n // is important.\n\n let cp = x[i];\n let replacement = when (cp) {\n char'\\b' -\u003e \u0022\\\\b\u0022;\n char'\\t' -\u003e \u0022\\\\t\u0022;\n char'\\n' -\u003e \u0022\\\\n\u0022;\n char'\\f' -\u003e \u0022\\\\f\u0022;\n char'\\r' -\u003e \u0022\\\\r\u0022;\n char'\u0022' -\u003e \u0022\\\\\\\u0022\u0022;\n char'\\\\' -\u003e \u0022\\\\\\\\\u0022;\n else -\u003e\n // Control characters and non-USV code-points.\n if (cp \u003c 0x20 || 0xD800 \u003c= cp \u0026\u0026 cp \u003c= 0xDFFF) {\n \u0022\\\\u\u0022\n } else {\n \u0022\u0022\n };\n };\n\n let nextI = x.next(i);\n\n if (replacement != \u0022\u0022) {\n buffer.appendBetween(x, emitted, i);\n buffer.append(replacement);\n if (replacement == \u0022\\\\u\u0022) {\n encodeHex4(cp, buffer);\n }\n emitted = nextI;\n }\n\n i = nextI;\n }\n buffer.appendBetween(x, emitted, i);\n buffer.append(\u0022\\\u0022\u0022);\n }\n\n let hexDigits = [\n '0', '1', '2', '3', '4', '5', '6', '7',\n '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',\n ];\n\n let encodeHex4(cp: Int, buffer: StringBuilder): Void {\n let b0 = (cp / 0x1000) \u0026 0xf;\n let b1 = (cp / 0x100) \u0026 0xf;\n let b2 = (cp / 0x10) \u0026 0xf;\n let b3 = cp \u0026 0xf;\n buffer.append(hexDigits[b0]);\n buffer.append(hexDigits[b1]);\n buffer.append(hexDigits[b2]);\n buffer.append(hexDigits[b3]);\n }\n\n## Parsing JSON\n\nJSON tokens, like `{` and `\u0022foo\u0022` correspond fairly closely to events\nlike *JsonProducer.startObject* and *JsonProducer.stringValue* respectively.\n\n*JsonSyntaxTree* knows how to describe itself to a *JsonProducer*, but we can\nalso craft a *JsonProducer* that constructs a syntax tree.\n\nFirst, we need a way to explain syntax errors, ideally in a way that lets\na *JsonProducer* represent both the valid JSON or the error.\n\n export interface JsonParseErrorReceiver {\n public explainJsonError(explanation: String): Void;\n }\n\nNow, we are ready to build a *JsonProducer* that produces a syntax tree given\nvalid JSON, but if given a string that is not valid JSON, it has a syntax error.\n\n export class JsonSyntaxTreeProducer extends JsonProducer \u0026 JsonParseErrorReceiver {\n private stack: ListBuilder\u003cListBuilder\u003cJsonSyntaxTree\u003e\u003e;\n private var error: String?;\n public get interchangeContext(): InterchangeContext {\n NullInterchangeContext.instance\n }\n\n public constructor() {\n stack = new ListBuilder\u003cListBuilder\u003cJsonSyntaxTree\u003e\u003e();\n stack.add(new ListBuilder\u003cJsonSyntaxTree\u003e());\n error = null;\n }\n\n private storeValue(v: JsonSyntaxTree): Void {\n if (!stack.isEmpty) {\n stack[stack.length - 1].add(v);\n }\n }\n\n public startObject(): Void {\n stack.add(new ListBuilder\u003cJsonSyntaxTree\u003e());\n }\n\n public endObject(): Void {\n if (stack.isEmpty) {\n return;\n }\n let ls = stack.removeLast();\n // In the common case, there are no duplicate keys.\n let m = new MapBuilder\u003cString, List\u003cJsonSyntaxTree\u003e\u003e();\n // But we need a way to accumulate them when there are duplicate keys.\n var multis: MapBuilder\u003cString, ListBuilder\u003cJsonSyntaxTree\u003e\u003e? = null;\n for (var i = 0, n = ls.length \u0026 -2; i \u003c n;) {\n let keyTree = ls[i++];\n if (!(keyTree is JsonString)) { break }\n let key = (keyTree as JsonString orelse panic()).content;\n let value = ls[i++];\n\n if (m.has(key)) {\n if (multis == null) {\n multis = new MapBuilder\u003cString, ListBuilder\u003cJsonSyntaxTree\u003e\u003e();\n }\n let mb = multis as MapBuilder\u003cString, ListBuilder\u003cJsonSyntaxTree\u003e\u003e orelse panic();\n if (!mb.has(key)) {\n mb[key] = (m[key] orelse panic()).toListBuilder();\n }\n (mb[key] orelse panic()).add(value);\n } else {\n m[key] = [value];\n }\n }\n\n let multis = multis; // lock it in down here for inference\n if (multis != null) {\n multis.forEach { (k: String, vs: ListBuilder\u003cJsonSyntaxTree\u003e);;\n m[k] = vs.toList();\n }\n }\n\n storeValue(new JsonObject(m.toMap()));\n }\n\n public objectKey(key: String): Void {\n storeValue(new JsonString(key));\n }\n\n public startArray(): Void {\n stack.add(new ListBuilder\u003cJsonSyntaxTree\u003e());\n }\n\n public endArray(): Void {\n if (stack.isEmpty) {\n return;\n }\n let ls = stack.removeLast();\n storeValue(new JsonArray(ls.toList()));\n }\n\n public nullValue(): Void {\n storeValue(new JsonNull());\n }\n\n public booleanValue(x: Boolean): Void {\n storeValue(new JsonBoolean(x));\n }\n\n public intValue(x: Int): Void {\n storeValue(new JsonInt(x));\n }\n\n public float64Value(x: Float64): Void {\n storeValue(new JsonFloat64(x));\n }\n\n public numericTokenValue(x: String): Void {\n storeValue(new JsonNumericToken(x));\n }\n\n public stringValue(x: String): Void {\n storeValue(new JsonString(x));\n }\n\n public toJsonSyntaxTree(): JsonSyntaxTree | Bubble {\n if (stack.length != 1 || error != null) { bubble() }\n let ls = stack[0];\n if (ls.length != 1) { bubble() }\n ls[0]\n }\n\n public get jsonError(): String? { error }\n\n public get parseErrorReceiver(): JsonParseErrorReceiver { this }\n\n public explainJsonError(error: String): Void {\n this.error = error;\n }\n }\n\nSome helpers let us route errors:\n\n let expectedTokenError(\n sourceText: String,\n i: StringIndex,\n out: JsonProducer,\n shortExplanation: String,\n ): Void {\n let gotten = if (sourceText.hasIndex(i)) {\n \u0022`\u0024{ sourceText.slice(i, sourceText.end) }`\u0022\n } else {\n \u0022end-of-file\u0022\n };\n storeJsonError(out, \u0022Expected \u0024{shortExplanation}, but got \u0024{gotten}\u0022);\n }\n\n let storeJsonError(out: JsonProducer, explanation: String): Void {\n out.parseErrorReceiver?.explainJsonError(explanation);\n }\n\nNext, a JSON string parser that drives a *JsonProducer*.\n\n export let parseJsonToProducer(sourceText: String, out: JsonProducer): Void {\n var i = String.begin;\n let afterValue = parseJsonValue(sourceText, i, out);\n if (afterValue is StringIndex) { // else parseJsonValue must have stored an error\n i = skipJsonSpaces(sourceText, afterValue);\n if (sourceText.hasIndex(i) \u0026\u0026 out.parseErrorReceiver != null) {\n storeJsonError(out, \u0022Extraneous JSON `\u0024{sourceText.slice(i, sourceText.end)}`\u0022);\n }\n }\n }\n\nA recursive descent parser without backtracking works just fine for JSON because the\nnext non-space character perfectly predicts the next production.\nAll `// \u003e ` comments are followed by quotes from ECMA-404 2nd edition.\nEach parsing helper takes the *StringIndex* before parsing and returns\nthe *StringIndex* at the end of the content it parsed, or maybe *null* if parsing\nfailed.\n\n // \u003e Insignificant whitespace is allowed before or after any token.\n // \u003e Whitespace is any sequence of one or more of the following code\n // \u003e points:\n // \u003e character tabulation (U+0009),\n // \u003e line feed (U+000A),\n // \u003e carriage return (U+000D), and\n // \u003e space (U+0020).\n let skipJsonSpaces(sourceText: String, var i: StringIndex): StringIndex {\n while (sourceText.hasIndex(i)) {\n when (sourceText[i]) {\n 0x9, 0xA, 0xD, 0x20 -\u003e void;\n else -\u003e break;\n }\n i = sourceText.next(i);\n }\n return i;\n }\n\n let parseJsonValue(\n sourceText: String, var i: StringIndex, out: JsonProducer\n ): StringIndexOption {\n i = skipJsonSpaces(sourceText, i);\n if (!sourceText.hasIndex(i)) {\n expectedTokenError(sourceText, i, out, \u0022JSON value\u0022);\n return StringIndex.none\n }\n when (sourceText[i]) {\n char'{' -\u003e parseJsonObject(sourceText, i, out);\n char'[' -\u003e parseJsonArray(sourceText, i, out);\n char'\u0022' -\u003e parseJsonString(sourceText, i, out);\n char't', char'f' -\u003e parseJsonBoolean(sourceText, i, out);\n char'n' -\u003e parseJsonNull(sourceText, i, out);\n else -\u003e parseJsonNumber(sourceText, i, out);\n }\n }\n\nFor a JSON object, parsing looks for a '{', then optionally a property.\nAfter a property, if there is a ',' parsing looks for another property.\nAfter the last property or lone '{', there must be a '}'.\n\n let parseJsonObject(\n sourceText: String, var i: StringIndex, out: JsonProducer\n ): StringIndexOption { do {\n if (!sourceText.hasIndex(i) || sourceText[i] != char'{') {\n expectedTokenError(sourceText, i, out, \u0022'{'\u0022);\n return StringIndex.none;\n }\n out.startObject();\n i = skipJsonSpaces(sourceText, sourceText.next(i));\n if (sourceText.hasIndex(i) \u0026\u0026 sourceText[i] != char'}') {\n while (true) {\n let keyBuffer = new StringBuilder();\n let afterKey = parseJsonStringTo(sourceText, i, keyBuffer, out);\n if (!(afterKey is StringIndex)) { return StringIndex.none; }\n out.objectKey(keyBuffer.toString());\n i = skipJsonSpaces(sourceText, afterKey as StringIndex orelse panic());\n if (sourceText.hasIndex(i) \u0026\u0026 sourceText[i] == char':') {\n i = sourceText.next(i);\n let afterPropertyValue = parseJsonValue(sourceText, i, out);\n if (!(afterPropertyValue is StringIndex)) {\n return StringIndex.none;\n }\n i = afterPropertyValue as StringIndex;\n } else {\n expectedTokenError(sourceText, i, out, \u0022':'\u0022);\n return StringIndex.none;\n }\n\n i = skipJsonSpaces(sourceText, i);\n if (sourceText.hasIndex(i) \u0026\u0026 sourceText[i] == char',') {\n i = skipJsonSpaces(sourceText, sourceText.next(i));\n continue;\n } else {\n break;\n }\n }\n }\n\n if (sourceText.hasIndex(i) \u0026\u0026 sourceText[i] == char'}') {\n out.endObject();\n return sourceText.next(i);\n } else {\n expectedTokenError(sourceText, i, out, \u0022'}'\u0022);\n return StringIndex.none;\n }\n } orelse panic() } // See https://github.com/temperlang/temper/issues/203\n\nFor a JSON array, parsing looks for a '\\[', and an optional element value.\nAfter each element value, if there is a ',', parsing looks for another element\nvalue. After the last element value or lone '\\[', there must be a '\\]'.\n\n let parseJsonArray(\n sourceText: String, var i: StringIndex, out: JsonProducer\n ): StringIndexOption { do {\n if (!sourceText.hasIndex(i) || sourceText[i] != char'[') {\n expectedTokenError(sourceText, i, out, \u0022'['\u0022);\n return StringIndex.none;\n }\n out.startArray();\n i = skipJsonSpaces(sourceText, sourceText.next(i));\n if (sourceText.hasIndex(i) \u0026\u0026 sourceText[i] != char']') {\n while (true) {\n let afterElementValue = parseJsonValue(sourceText, i, out);\n if (!(afterElementValue is StringIndex)) {\n return StringIndex.none;\n }\n i = afterElementValue as StringIndex;\n\n i = skipJsonSpaces(sourceText, i);\n if (sourceText.hasIndex(i) \u0026\u0026 sourceText[i] == char',') {\n i = skipJsonSpaces(sourceText, sourceText.next(i));\n continue;\n } else {\n break;\n }\n }\n }\n\n if (sourceText.hasIndex(i) \u0026\u0026 sourceText[i] == char']') {\n out.endArray();\n return sourceText.next(i);\n } else {\n expectedTokenError(sourceText, i, out, \u0022']'\u0022);\n return StringIndex.none;\n }\n } orelse panic() } // See https://github.com/temperlang/temper/issues/203\n\nA string consists of double-quotes with a select group of C-style escape sequences.\nThe characters that are allowed unescaped inside the quotes are any except ASCII\ncontrol characters.\n\n\u003e To escape a code point that is not in the Basic Multilingual Plane,\n\u003e the character may be represented as a twelve-character sequence,\n\u003e encoding the UTF-16 surrogate pair corresponding to the code point.\n\nThis suggests that when only one of a surrogate pair is escaped, that it is\ntreated as multiple code points. This implementation collapses them into\na single code-point for consistency with backends with native UTF-16 strings\nwhere such a distinction is not possible to represent.\n\n let parseJsonString(\n sourceText: String, var i: StringIndex, out: JsonProducer\n ): StringIndexOption {\n let sb = new StringBuilder();\n let after = parseJsonStringTo(sourceText, i, sb, out);\n if (after is StringIndex) {\n out.stringValue(sb.toString());\n }\n return after;\n }\n\n let parseJsonStringTo(\n sourceText: String, var i: StringIndex, sb: StringBuilder,\n errOut: JsonProducer\n ): StringIndexOption {\n if (!sourceText.hasIndex(i) || sourceText[i] != char'\u0022') {\n expectedTokenError(sourceText, i, errOut, '\u0022');\n return StringIndex.none;\n }\n i = sourceText.next(i);\n\n // Hold onto lead surrogates until we find out whether there's a trailing\n // surrogate or not.\n var leadSurrogate: Int = -1;\n\n var consumed = i;\n while (sourceText.hasIndex(i)) {\n let cp = sourceText[i];\n if (cp == char'\u0022') { break }\n var iNext = sourceText.next(i);\n let end = sourceText.end;\n\n // Emit anything between consumed and i if there\n // is a pending surrogate or escaped characters.\n var needToFlush = false;\n\n // Decode one code-point or UTF-16 surrogate\n var decodedCp = if (cp != char'\\\\') {\n cp\n } else {\n needToFlush = true;\n if (!sourceText.hasIndex(iNext)) {\n expectedTokenError(sourceText, iNext, errOut, \u0022escape sequence\u0022);\n return StringIndex.none;\n }\n let esc0 = sourceText[iNext];\n iNext = sourceText.next(iNext);\n when (esc0) {\n char'\u0022', char'\\\\', char'/' -\u003e esc0;\n char'b' -\u003e char'\\b';\n char'f' -\u003e char'\\f';\n char'n' -\u003e char'\\n';\n char'r' -\u003e char'\\r';\n char't' -\u003e char'\\t';\n char'u' -\u003e do {\n let hex: Int = if (sourceText.hasAtLeast(iNext, end, 4)) {\n let startHex = iNext;\n iNext = sourceText.next(iNext);\n iNext = sourceText.next(iNext);\n iNext = sourceText.next(iNext);\n iNext = sourceText.next(iNext);\n decodeHexUnsigned(sourceText, startHex, iNext)\n } else {\n -1\n };\n if (hex \u003c 0) {\n expectedTokenError(sourceText, iNext, errOut, \u0022four hex digits\u0022);\n return StringIndex.none;\n }\n hex\n }\n else -\u003e do {\n expectedTokenError(sourceText, iNext, errOut, \u0022escape sequence\u0022);\n return StringIndex.none;\n }\n }\n };\n\n // If we have two surrogates, combine them into one code-point.\n // If we have a lead surrogate, make sure we can wait.\n if (leadSurrogate \u003e= 0) {\n needToFlush = true;\n let lead = leadSurrogate;\n if (0xDC00 \u003c= decodedCp \u0026\u0026 decodedCp \u003c= 0xDFFF) {\n leadSurrogate = -1;\n decodedCp = (\n 0x10000 +\n (((lead - 0xD800) * 0x400) | (decodedCp - 0xDC00))\n );\n }\n } else if (0xD800 \u003c= decodedCp \u0026\u0026 decodedCp \u003c= 0xDBFF) {\n needToFlush = true;\n }\n\n // Consume characters from sourceText onto sb if it's timely\n // to do so.\n if (needToFlush) {\n sb.appendBetween(sourceText, consumed, i);\n if (leadSurrogate \u003e= 0) {\n // Not combined with a trailing surrogate.\n sb.appendCodePoint(leadSurrogate) orelse panic();\n }\n if (0xD800 \u003c= decodedCp \u0026\u0026 decodedCp \u003c= 0xDBFF) {\n leadSurrogate = decodedCp;\n } else {\n leadSurrogate = -1;\n sb.appendCodePoint(decodedCp) orelse panic();\n }\n consumed = iNext;\n }\n\n i = iNext;\n }\n\n if (!sourceText.hasIndex(i) || sourceText[i] != char'\u0022') {\n expectedTokenError(sourceText, i, errOut, '\u0022');\n StringIndex.none\n } else {\n if (leadSurrogate \u003e= 0) {\n sb.appendCodePoint(leadSurrogate) orelse panic();\n } else {\n sb.appendBetween(sourceText, consumed, i);\n }\n i = sourceText.next(i); // Consume closing quote\n i\n }\n }\n\n let decodeHexUnsigned(\n sourceText: String, start: StringIndex, limit: StringIndex\n ): Int {\n var n = 0;\n var i = start;\n while (i.compareTo(limit) \u003c 0) {\n let cp = sourceText[i];\n let digit = if (char'0' \u003c= cp \u0026\u0026 cp \u003c= char'0') {\n cp - char'0'\n } else if (char'A' \u003c= cp \u0026\u0026 cp \u003c= char'F') {\n cp - char'A' + 10\n } else if (char'a' \u003c= cp \u0026\u0026 cp \u003c= char'f') {\n cp - char'a' + 10\n } else {\n return -1;\n }\n n = (n * 16) + digit;\n i = sourceText.next(i);\n }\n n\n }\n\n let parseJsonBoolean(\n sourceText: String, var i: StringIndex, out: JsonProducer\n ): StringIndexOption {\n let ch0 = if (sourceText.hasIndex(i)) {\n sourceText[i]\n } else {\n 0\n };\n let end = sourceText.end;\n\n let keyword: String?;\n let n: Int;\n when (ch0) {\n char'f' -\u003e do { keyword = \u0022false\u0022; n = 5 };\n char't' -\u003e do { keyword = \u0022true\u0022; n = 4 };\n else -\u003e do { keyword = null; n = 0 };\n }\n\n if (keyword != null) {\n if (sourceText.hasAtLeast(i, end, n)) {\n let after = afterSubstring(sourceText, i, keyword);\n if (after is StringIndex) {\n out.booleanValue(n == 4);\n return after;\n }\n }\n }\n\n expectedTokenError(sourceText, i, out, \u0022`false` or `true`\u0022);\n return StringIndex.none;\n }\n\n let parseJsonNull(\n sourceText: String, i: StringIndex, out: JsonProducer\n ): StringIndexOption {\n let after = afterSubstring(sourceText, i, \u0022null\u0022);\n\n if (after is StringIndex) {\n out.nullValue();\n return after;\n }\n\n expectedTokenError(sourceText, i, out, \u0022`null`\u0022);\n return StringIndex.none;\n }\n\n let afterSubstring(\n string: String,\n inString: StringIndex,\n substring: String\n ): StringIndexOption {\n var i = inString;\n var j = String.begin;\n while (substring.hasIndex(j)) {\n if (!string.hasIndex(i)) {\n return StringIndex.none;\n }\n if (string[i] != substring[j]) {\n return StringIndex.none;\n }\n i = string.next(i);\n j = substring.next(j);\n }\n i\n }\n\nAs usual, the number grammar is the single largest sub-grammar.\nWe accumulate an integer portion separately from a decimal portion.\nIf either of those is past the common representability limits for *Int*\nor *Float64*, then we use the lossless numeric syntax tree variant.\n\n let parseJsonNumber(\n sourceText: String, var i: StringIndex, out: JsonProducer\n ): StringIndexOption { do {\n var isNegative = false;\n let startOfNumber = i;\n if (sourceText.hasIndex(i) \u0026\u0026 sourceText[i] == char'-') {\n isNegative = true;\n i = sourceText.next(i);\n }\n\n // Find the whole portion, the portion before any fraction\n // or exponent.\n // 0 | [1-9][0-9]*\n let digit0 = if (sourceText.hasIndex(i)) { sourceText[i] } else { -1 };\n if (digit0 \u003c char'0' || char'9' \u003c digit0) {\n // parseJsonValue comes here for any unrecognized code-points\n let error = if (!isNegative \u0026\u0026 digit0 != char'.') {\n \u0022JSON value\u0022\n } else {\n \u0022digit\u0022\n };\n expectedTokenError(sourceText, i, out, error);\n return StringIndex.none;\n }\n i = sourceText.next(i);\n var nDigits = 1;\n var tentativeValue = (digit0 - char'0').toFloat64() orelse panic();\n if (char'0' != digit0) {\n while (sourceText.hasIndex(i)) {\n let possibleDigit = sourceText[i];\n if (char'0' \u003c= possibleDigit \u0026\u0026 possibleDigit \u003c= char'9') {\n i = sourceText.next(i);\n nDigits += 1;\n tentativeValue = tentativeValue * 10.0 +\n (possibleDigit - char'0').toFloat64();\n } else {\n break;\n }\n }\n }\n\n // optional fraction component\n // '.' [0-9]+\n var nDigitsAfterPoint = 0;\n if (sourceText.hasIndex(i) \u0026\u0026 char'.' == sourceText[i]) {\n i = sourceText.next(i);\n let afterPoint = i;\n while (sourceText.hasIndex(i)) {\n let possibleDigit = sourceText[i];\n if (char'0' \u003c= possibleDigit \u0026\u0026 possibleDigit \u003c= char'9') {\n i = sourceText.next(i);\n nDigits += 1;\n nDigitsAfterPoint += 1;\n tentativeValue = tentativeValue * 10.0 +\n (possibleDigit - char'0').toFloat64();\n } else {\n break;\n }\n }\n if (i == afterPoint) {\n // ECMA-404 does not allow \u00220.\u0022 with no digit after the point.\n expectedTokenError(sourceText, i, out, \u0022digit\u0022);\n return StringIndex.none;\n }\n }\n\n // optional exponent\n // [eE] [+\\-]? [0-9]+\n var nExponentDigits = 0;\n if (sourceText.hasIndex(i) \u0026\u0026 char'e' == (sourceText[i] | 32)) {\n i = sourceText.next(i);\n if (!sourceText.hasIndex(i)) {\n expectedTokenError(sourceText, i, out, \u0022sign or digit\u0022);\n return StringIndex.none;\n }\n let afterE = sourceText[i];\n if (afterE == char'+' || afterE == char'-') {\n i = sourceText.next(i);\n }\n while (sourceText.hasIndex(i)) {\n let possibleDigit = sourceText[i];\n if (char'0' \u003c= possibleDigit \u0026\u0026 possibleDigit \u003c= char'9') {\n i = sourceText.next(i);\n nExponentDigits += 1;\n } else {\n break;\n }\n }\n if (nExponentDigits == 0) {\n expectedTokenError(sourceText, i, out, \u0022exponent digit\u0022);\n return StringIndex.none;\n }\n }\n let afterExponent = i;\n\n if (nExponentDigits == 0 \u0026\u0026 nDigitsAfterPoint == 0) {\n // An integer literal.\n let value = if (isNegative) { -tentativeValue } else { tentativeValue };\n if (nDigits \u003c= 10 \u0026\u0026 -2147483648.0 \u003c= value \u0026\u0026 value \u003c= 2147483647.0) {\n // Guaranteed representible int value.\n out.intValue(value.toInt() orelse panic());\n return i;\n }\n }\n\n let numericTokenString = sourceText.slice(startOfNumber, i);\n var doubleValue = NaN;\n if (nExponentDigits != 0 || nDigitsAfterPoint != 0) {\n do {\n doubleValue = numericTokenString.toFloat64();\n } orelse do {\n // Fall back to numeric token below\n ;\n }\n }\n\n if (doubleValue != -Infinity \u0026\u0026 doubleValue != Infinity \u0026\u0026\n doubleValue != NaN) {\n out.float64Value(doubleValue);\n } else {\n out.numericTokenValue(numericTokenString);\n }\n return i;\n } orelse panic() } // See https://github.com/temperlang/temper/issues/203\n\nAs a convenience, the *parseJson* helper just creates a tree producer,\ncalls the parser and gets the tree.\n\n export let parseJson(sourceText: String): JsonSyntaxTree | Bubble {\n let p = new JsonSyntaxTreeProducer();\n parseJsonToProducer(sourceText, p);\n // TODO: if there is a syntax error, produce it.\n p.toJsonSyntaxTree()\n }\n\n## Type adapters\n\nType adapters allow converting values of a type to and from JSON.\nSee the `@json` type decorator for details which makes sure that\nthe decorated type has a static method that gets an adapter for the\ntype.\n\n export interface JsonAdapter\u003cT\u003e {\n public encodeToJson(x: T, p: JsonProducer): Void;\n public decodeFromJson(t: JsonSyntaxTree, ic: InterchangeContext): T | Bubble;\n }\n\nOur intrinsic types, like *Boolean* need json adapters. Static extensions\nlet us make *Boolean.jsonAdapter()* work as if it were built in.\n\n class BooleanJsonAdapter extends JsonAdapter\u003cBoolean\u003e {\n public encodeToJson(x: Boolean, p: JsonProducer): Void {\n p.booleanValue(x);\n }\n public decodeFromJson(t: JsonSyntaxTree, ic: InterchangeContext): Boolean | Bubble {\n (t as JsonBoolean).content\n }\n }\n\n @staticExtension(Boolean, \u0022jsonAdapter\u0022)\n export let booleanJsonAdapter(): JsonAdapter\u003cBoolean\u003e {\n new BooleanJsonAdapter()\n }\n\n class Float64JsonAdapter extends JsonAdapter\u003cFloat64\u003e {\n public encodeToJson(x: Float64, p: JsonProducer): Void {\n p.float64Value(x);\n }\n public decodeFromJson(t: JsonSyntaxTree, ic: InterchangeContext): Float64 | Bubble {\n (t as JsonNumeric).asFloat64()\n }\n }\n\n @staticExtension(Float64, \u0022jsonAdapter\u0022)\n export let float64JsonAdapter(): JsonAdapter\u003cFloat64\u003e {\n new Float64JsonAdapter()\n }\n\n class IntJsonAdapter extends JsonAdapter\u003cInt\u003e {\n public encodeToJson(x: Int, p: JsonProducer): Void {\n p.intValue(x);\n }\n public decodeFromJson(t: JsonSyntaxTree, ic: InterchangeContext): Int | Bubble {\n (t as JsonNumeric).asInt()\n }\n }\n\n @staticExtension(Int, \u0022jsonAdapter\u0022)\n export let intJsonAdapter(): JsonAdapter\u003cInt\u003e {\n new IntJsonAdapter()\n }\n\n class StringJsonAdapter extends JsonAdapter\u003cString\u003e {\n public encodeToJson(x: String, p: JsonProducer): Void {\n p.stringValue(x);\n }\n public decodeFromJson(t: JsonSyntaxTree, ic: InterchangeContext): String | Bubble {\n (t as JsonString).content\n }\n }\n\n @staticExtension(String, \u0022jsonAdapter\u0022)\n export let stringJsonAdapter(): JsonAdapter\u003cString\u003e {\n new StringJsonAdapter()\n }\n\n class ListJsonAdapter\u003cT\u003e(\n private adapterForT: JsonAdapter\u003cT\u003e,\n ) extends JsonAdapter\u003cList\u003cT\u003e\u003e {\n public encodeToJson(x: List\u003cT\u003e, p: JsonProducer): Void {\n p.startArray();\n for (let el of x) {\n adapterForT.encodeToJson(el, p);\n }\n p.endArray();\n }\n public decodeFromJson(t: JsonSyntaxTree, ic: InterchangeContext): List\u003cT\u003e | Bubble {\n let b = new ListBuilder\u003cT\u003e();\n let elements = (t as JsonArray).elements;\n let n = elements.length;\n var i = 0;\n while (i \u003c n) {\n let el = elements[i];\n i += 1;\n b.add(adapterForT.decodeFromJson(el, ic));\n }\n b.toList()\n }\n }\n\n @staticExtension(List, \u0022jsonAdapter\u0022)\n export let listJsonAdapter\u003cT\u003e(adapterForT: JsonAdapter\u003cT\u003e): JsonAdapter\u003cList\u003cT\u003e\u003e {\n new ListJsonAdapter\u003cT\u003e(adapterForT)\n }\n\n export class OrNullJsonAdapter\u003cT\u003e(\n private adapterForT: JsonAdapter\u003cT\u003e,\n ) extends JsonAdapter\u003cT?\u003e {\n public encodeToJson(x: T?, p: JsonProducer): Void {\n if (x == null) {\n p.nullValue();\n } else {\n adapterForT.encodeToJson(x, p);\n }\n }\n public decodeFromJson(t: JsonSyntaxTree, ic: InterchangeContext): T? | Bubble {\n if (t is JsonNull) {\n null\n } else {\n adapterForT.decodeFromJson(t, ic)\n }\n }\n }\n\n[ECMA-404]: https://ecma-international.org/publications-and-standards/standards/ecma-404/\n[content negotiation]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation\n[JSON Lines]: https://jsonlines.org/\n[scalar value string]: https://infra.spec.whatwg.org/#scalar-value-string\n" ], "names": [ "JsonProducer", "JsonSyntaxTree", "InterchangeContext", "JsonAdapter", "JsonString", "DateJsonAdapter", "x", "p", "encodeToJson", "t", "ic", "decodeFromJson", "this", "jsonAdapter", "daysInMonth", "isLeapYear", "year", "return", "padTo", "minWidth", "num", "sb", "decimal", "decimalIndex", "decimalEnd", "nNeeded", "dayOfWeekLookupTableLeapy", "dayOfWeekLookupTableNotLeapy" ], "mappings": "AD4FS;ADAA,EDAAA,YDAA,uBDAAC,cDAA,yBDAAC,kBDAA,4BDAA,A,C,W,q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