pax_global_header00006660000000000000000000000064145433272450014523gustar00rootroot0000000000000052 comment=1a6bec3348eafa216bf13d44a12ef02da6be7fec json-1.0.2/000077500000000000000000000000001454332724500124745ustar00rootroot00000000000000json-1.0.2/.gitignore000066400000000000000000000000521454332724500144610ustar00rootroot00000000000000/node_modules/ /src/parser.* /dist .cache json-1.0.2/.npmignore000066400000000000000000000000331454332724500144670ustar00rootroot00000000000000/node_modules /docs .cache json-1.0.2/CHANGELOG.md000066400000000000000000000021471454332724500143110ustar00rootroot00000000000000## 1.0.2 (2023-12-28) ### Bug fixes Tag strings as isolating for the purpose of bidirectional text. ## 1.0.1 (2023-07-03) ### Bug fixes Make the package work with new TS resolution styles. ## 1.0.0 (2022-06-06) ### New features First stable version. ## 0.16.0 (2022-04-20) ### Breaking changes Move to 0.16 serialized parser format. ### New features The parser now includes syntax highlighting information in its node types. ## 0.15.0 (2021-08-11) ### Breaking changes The module's name changed from `lezer-json` to `@lezer/json`. Upgrade to the 0.15.0 lezer interfaces. ## 0.13.2 (2021-06-14) ### Bug fixes Include nodes for brackets and braces in the tree. ## 0.13.1 (2020-12-04) ### Bug fixes Fix versions of lezer packages depended on. ## 0.13.0 (2020-12-04) ## 0.12.0 (2020-10-23) ### Breaking changes Adjust to changed serialized parser format. ## 0.11.1 (2020-09-26) ### Bug fixes Fix lezer depencency versions ## 0.11.0 (2020-09-26) ### Breaking changes Follow change in serialized parser format. ## 0.10.0 (2020-09-23) ### Breaking changes Upgrade to current parser package format. json-1.0.2/LICENSE000066400000000000000000000021761454332724500135070ustar00rootroot00000000000000MIT License Copyright (C) 2020 by Marijn Haverbeke , Arun Srinivasan , and others Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.json-1.0.2/README.md000066400000000000000000000003621454332724500137540ustar00rootroot00000000000000# @lezer/json This is a JSON grammar for the [lezer](https://lezer.codemirror.net/) parser system. Reference: - https://www.json.org/json-en.html - https://tools.ietf.org/html/rfc8259 (The latest IETF RFC – contains the latest full spec) json-1.0.2/dist/000077500000000000000000000000001454332724500134375ustar00rootroot00000000000000json-1.0.2/dist/index.d.cts000066400000000000000000000001021454332724500154740ustar00rootroot00000000000000import {LRParser} from "@lezer/lr" export const parser: LRParser json-1.0.2/dist/index.d.ts000066400000000000000000000001021454332724500153310ustar00rootroot00000000000000import {LRParser} from "@lezer/lr" export const parser: LRParser json-1.0.2/package.json000066400000000000000000000017501454332724500147650ustar00rootroot00000000000000{ "name": "@lezer/json", "version": "1.0.2", "description": "lezer-based JSON grammar", "main": "dist/index.cjs", "type": "module", "exports": { "import": "./dist/index.js", "require": "./dist/index.cjs" }, "module": "dist/index.js", "types": "dist/index.d.ts", "author": "Arun Srinivasan ", "license": "MIT", "devDependencies": { "@lezer/generator": "^1.0.0", "mocha": "^10.2.0", "rollup": "^2.52.2", "@rollup/plugin-node-resolve": "^9.0.0" }, "dependencies": { "@lezer/common": "^1.2.0", "@lezer/highlight": "^1.0.0", "@lezer/lr": "^1.0.0" }, "repository": { "type": "git", "url": "https://github.com/lezer-parser/json.git" }, "scripts": { "build": "lezer-generator src/json.grammar -o src/parser && rollup -c", "build-debug": "lezer-generator src/json.grammar --names -o src/parser && rollup -c", "prepare": "npm run build", "test": "npm run build && mocha test/test-json.js" } } json-1.0.2/rollup.config.js000066400000000000000000000004601454332724500156130ustar00rootroot00000000000000import {nodeResolve} from "@rollup/plugin-node-resolve" export default { input: "./src/parser.js", output: [ { format: "cjs", file: "./dist/index.cjs" }, { format: "es", file: "./dist/index.js" } ], external(id) { return !/^[\.\/]/.test(id) }, plugins: [ nodeResolve() ] } json-1.0.2/src/000077500000000000000000000000001454332724500132635ustar00rootroot00000000000000json-1.0.2/src/highlight.js000066400000000000000000000004251454332724500155710ustar00rootroot00000000000000import {styleTags, tags as t} from "@lezer/highlight" export const jsonHighlighting = styleTags({ String: t.string, Number: t.number, "True False": t.bool, PropertyName: t.propertyName, Null: t.null, ",": t.separator, "[ ]": t.squareBracket, "{ }": t.brace }) json-1.0.2/src/json.grammar000066400000000000000000000014271454332724500156100ustar00rootroot00000000000000@top JsonText { value } value { True | False | Null | Number | String | Object | Array } String[isolate] { string } Object { "{" list? "}" } Array { "[" list? "]" } Property { PropertyName ":" value } PropertyName[isolate] { string } @tokens { True { "true" } False { "false" } Null { "null" } Number { '-'? int frac? exp? } int { '0' | $[1-9] @digit* } frac { '.' @digit+ } exp { $[eE] $[+\-]? @digit+ } string { '"' char* '"' } char { $[\u{20}\u{21}\u{23}-\u{5b}\u{5d}-\u{10ffff}] | "\\" esc } esc { $["\\\/bfnrt] | "u" hex hex hex hex } hex { $[0-9a-fA-F] } whitespace { $[ \n\r\t] } "{" "}" "[" "]" } @skip { whitespace } list { item ("," item)* } @external propSource jsonHighlighting from "./highlight" @detectDelim json-1.0.2/test/000077500000000000000000000000001454332724500134535ustar00rootroot00000000000000json-1.0.2/test/arrays.txt000066400000000000000000000004741454332724500155220ustar00rootroot00000000000000# Empty Array [ ] ==> JsonText(Array) # Array With One Value ["One is the loneliest number"] ==> JsonText(Array(String)) # Array With Multiple Values [ "The more the merrier", 1e5, true, { }, ["I'm", "nested"] ] ==> JsonText(Array( String, Number, True, Object, Array(String,String))) json-1.0.2/test/literals.txt000066400000000000000000000001531454332724500160320ustar00rootroot00000000000000# True true ==> JsonText(True) # False false ==> JsonText(False) # Null null ==> JsonText(Null) json-1.0.2/test/numbers.txt000066400000000000000000000011751454332724500156730ustar00rootroot00000000000000# Simple Integer 42 ==> JsonText(Number) # Zero By Itself Is Ok 0 ==> JsonText(Number) # Leading Zeros Aren't Ok [0123] ==> JsonText(Array(Number, ⚠(Number))) # Optional Minus Sign -53 ==> JsonText(Number) # Decimal Digits 123.4 ==> JsonText(Number) # Must Have Digits After Decimal 123. ==> JsonText(Number, ⚠) # Exponent: Lowercase e 1e5 ==> JsonText(Number) # Exponent: Uppercase E 1E5 ==> JsonText(Number) # Exponent: Optional Plus Sign 1e+5 ==> JsonText(Number) # Exponent: Optional Minus Sign 1E-5 ==> JsonText(Number) # Exponent Without Digit Is Not Ok 42e ==> JsonText(Number, ⚠) json-1.0.2/test/objects.txt000066400000000000000000000006251454332724500156500ustar00rootroot00000000000000# Empty Object { } ==> JsonText(Object) # One Property { "foo": 123 } ==> JsonText(Object(Property(PropertyName,Number))) # Multiple Properties { "foo": 123, "bar": "I'm a bar!", "obj": {}, "arr": [1, 2, 3] } ==> JsonText(Object( Property(PropertyName,Number), Property(PropertyName,String), Property(PropertyName,Object), Property(PropertyName,Array(Number,Number,Number)))) json-1.0.2/test/strings.txt000066400000000000000000000003721454332724500157070ustar00rootroot00000000000000# Empty String "" ==> JsonText(String) # Non-empty String "This is a boring old string" ==> JsonText(String) # All The Valid One-Character Escapes "\"\\\/\b\f\n\rt\t" ==> JsonText(String) # Unicode Escape "\u005C" ==> JsonText(String) json-1.0.2/test/test-json.js000066400000000000000000000010061454332724500157340ustar00rootroot00000000000000import {parser} from '../dist/index.js' import {fileTests} from '@lezer/generator/dist/test' import fs from 'fs' import path from 'path' import {fileURLToPath} from "url" let caseDir = path.dirname(fileURLToPath(import.meta.url)) for (let file of fs.readdirSync(caseDir)) { if (file === 'test-json.js') continue let name = /^[^\.]*/.exec(file)[0] describe(name, () => { for (let { name, run } of fileTests(fs.readFileSync(path.join(caseDir, file), "utf8"), file)) it(name, () => run(parser)) }) }