flex-json 0.0.4 → 0.0.6
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/FlexJsonClass.d.ts +308 -0
- package/FlexJsonClass.js +1840 -1757
- package/FlexJsonConstants.js +57 -57
- package/FlexJsonMeta.js +25 -25
- package/FlexJsonPosition.js +31 -31
- package/LICENSE.txt +21 -21
- package/README.md +369 -185
- package/extensions/tree-sitter-jfx/README.md +98 -0
- package/extensions/tree-sitter-jfx/grammar.js +153 -0
- package/extensions/tree-sitter-jfx/package.json +42 -0
- package/extensions/tree-sitter-jfx/queries/highlights.scm +34 -0
- package/extensions/vscode-jfx/LICENSE.txt +21 -0
- package/extensions/vscode-jfx/README.md +77 -0
- package/extensions/vscode-jfx/icons/jfx-icon.png +0 -0
- package/extensions/vscode-jfx/language-configuration.json +33 -0
- package/extensions/vscode-jfx/package-lock.json +3884 -0
- package/extensions/vscode-jfx/package.json +58 -0
- package/extensions/vscode-jfx/syntaxes/jfx.tmLanguage.json +185 -0
- package/extensions/vscode-jfx/vscode-jfx-0.1.0.vsix +0 -0
- package/package.json +4 -5
- package/get/index.js +0 -27
- package/set/index.js +0 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree-sitter grammar for FlexJson (.jfx) files
|
|
3
|
+
*
|
|
4
|
+
* FlexJson is JSON with:
|
|
5
|
+
* - Line comments (//)
|
|
6
|
+
* - Block comments (/* */)
|
|
7
|
+
* - Single-quoted strings
|
|
8
|
+
* - Unquoted strings (for simple values)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
module.exports = grammar({
|
|
12
|
+
name: 'jfx',
|
|
13
|
+
|
|
14
|
+
extras: $ => [
|
|
15
|
+
/\s/,
|
|
16
|
+
$.comment,
|
|
17
|
+
],
|
|
18
|
+
|
|
19
|
+
rules: {
|
|
20
|
+
// Entry point
|
|
21
|
+
document: $ => optional($._value),
|
|
22
|
+
|
|
23
|
+
// Values
|
|
24
|
+
_value: $ => choice(
|
|
25
|
+
$.object,
|
|
26
|
+
$.array,
|
|
27
|
+
$.string,
|
|
28
|
+
$.number,
|
|
29
|
+
$.true,
|
|
30
|
+
$.false,
|
|
31
|
+
$.null,
|
|
32
|
+
$.unquoted_string,
|
|
33
|
+
),
|
|
34
|
+
|
|
35
|
+
// Object: { key: value, ... }
|
|
36
|
+
object: $ => seq(
|
|
37
|
+
'{',
|
|
38
|
+
optional($.object_content),
|
|
39
|
+
'}',
|
|
40
|
+
),
|
|
41
|
+
|
|
42
|
+
object_content: $ => seq(
|
|
43
|
+
$.pair,
|
|
44
|
+
repeat(seq(',', $.pair)),
|
|
45
|
+
optional(','), // trailing comma allowed
|
|
46
|
+
),
|
|
47
|
+
|
|
48
|
+
pair: $ => seq(
|
|
49
|
+
field('key', $._key),
|
|
50
|
+
':',
|
|
51
|
+
field('value', $._value),
|
|
52
|
+
),
|
|
53
|
+
|
|
54
|
+
_key: $ => choice(
|
|
55
|
+
$.string,
|
|
56
|
+
$.unquoted_key,
|
|
57
|
+
),
|
|
58
|
+
|
|
59
|
+
unquoted_key: $ => /[a-zA-Z_$][a-zA-Z0-9_$]*/,
|
|
60
|
+
|
|
61
|
+
// Array: [ value, ... ]
|
|
62
|
+
array: $ => seq(
|
|
63
|
+
'[',
|
|
64
|
+
optional($.array_content),
|
|
65
|
+
']',
|
|
66
|
+
),
|
|
67
|
+
|
|
68
|
+
array_content: $ => seq(
|
|
69
|
+
$._value,
|
|
70
|
+
repeat(seq(',', $._value)),
|
|
71
|
+
optional(','), // trailing comma allowed
|
|
72
|
+
),
|
|
73
|
+
|
|
74
|
+
// Strings
|
|
75
|
+
string: $ => choice(
|
|
76
|
+
$.double_quoted_string,
|
|
77
|
+
$.single_quoted_string,
|
|
78
|
+
),
|
|
79
|
+
|
|
80
|
+
double_quoted_string: $ => seq(
|
|
81
|
+
'"',
|
|
82
|
+
repeat(choice(
|
|
83
|
+
$.string_content,
|
|
84
|
+
$.escape_sequence,
|
|
85
|
+
)),
|
|
86
|
+
'"',
|
|
87
|
+
),
|
|
88
|
+
|
|
89
|
+
single_quoted_string: $ => seq(
|
|
90
|
+
"'",
|
|
91
|
+
repeat(choice(
|
|
92
|
+
$.single_string_content,
|
|
93
|
+
$.escape_sequence,
|
|
94
|
+
)),
|
|
95
|
+
"'",
|
|
96
|
+
),
|
|
97
|
+
|
|
98
|
+
string_content: $ => token.immediate(prec(1, /[^"\\\n]+/)),
|
|
99
|
+
|
|
100
|
+
single_string_content: $ => token.immediate(prec(1, /[^'\\\n]+/)),
|
|
101
|
+
|
|
102
|
+
escape_sequence: $ => token.immediate(seq(
|
|
103
|
+
'\\',
|
|
104
|
+
choice(
|
|
105
|
+
/["\\/bfnrt']/,
|
|
106
|
+
/u[0-9a-fA-F]{4}/,
|
|
107
|
+
),
|
|
108
|
+
)),
|
|
109
|
+
|
|
110
|
+
// Unquoted strings (for values only, not containing special chars)
|
|
111
|
+
unquoted_string: $ => /[a-zA-Z_$][a-zA-Z0-9_$.-]*/,
|
|
112
|
+
|
|
113
|
+
// Numbers
|
|
114
|
+
number: $ => {
|
|
115
|
+
const decimal_digits = /\d+/;
|
|
116
|
+
const signed_integer = seq(optional('-'), decimal_digits);
|
|
117
|
+
const decimal_integer = choice(
|
|
118
|
+
'0',
|
|
119
|
+
seq(/[1-9]/, optional(decimal_digits)),
|
|
120
|
+
);
|
|
121
|
+
const exponent_part = seq(
|
|
122
|
+
choice('e', 'E'),
|
|
123
|
+
optional(choice('+', '-')),
|
|
124
|
+
decimal_digits,
|
|
125
|
+
);
|
|
126
|
+
return token(seq(
|
|
127
|
+
optional('-'),
|
|
128
|
+
decimal_integer,
|
|
129
|
+
optional(seq('.', decimal_digits)),
|
|
130
|
+
optional(exponent_part),
|
|
131
|
+
));
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
// Literals
|
|
135
|
+
true: $ => 'true',
|
|
136
|
+
false: $ => 'false',
|
|
137
|
+
null: $ => 'null',
|
|
138
|
+
|
|
139
|
+
// Comments
|
|
140
|
+
comment: $ => choice(
|
|
141
|
+
$.line_comment,
|
|
142
|
+
$.block_comment,
|
|
143
|
+
),
|
|
144
|
+
|
|
145
|
+
line_comment: $ => token(seq('//', /.*/)),
|
|
146
|
+
|
|
147
|
+
block_comment: $ => token(seq(
|
|
148
|
+
'/*',
|
|
149
|
+
/[^*]*\*+([^/*][^*]*\*+)*/,
|
|
150
|
+
'/',
|
|
151
|
+
)),
|
|
152
|
+
},
|
|
153
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tree-sitter-jfx",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Tree-sitter grammar for FlexJson (.jfx) files",
|
|
5
|
+
"main": "bindings/node",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/tedtyree/FlexJson.git"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"tree-sitter",
|
|
12
|
+
"parser",
|
|
13
|
+
"lexer",
|
|
14
|
+
"json",
|
|
15
|
+
"flexjson",
|
|
16
|
+
"jfx"
|
|
17
|
+
],
|
|
18
|
+
"author": "FlexJson Team",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"nan": "^2.18.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"tree-sitter-cli": "^0.20.8"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"generate": "tree-sitter generate",
|
|
28
|
+
"build": "tree-sitter generate && node-gyp rebuild",
|
|
29
|
+
"test": "tree-sitter test",
|
|
30
|
+
"parse": "tree-sitter parse"
|
|
31
|
+
},
|
|
32
|
+
"tree-sitter": [
|
|
33
|
+
{
|
|
34
|
+
"scope": "source.jfx",
|
|
35
|
+
"file-types": [
|
|
36
|
+
"jfx"
|
|
37
|
+
],
|
|
38
|
+
"injection-regex": "^jfx$",
|
|
39
|
+
"highlights": "queries/highlights.scm"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
; Highlights for FlexJson (.jfx) files
|
|
2
|
+
|
|
3
|
+
; Comments
|
|
4
|
+
(comment) @comment
|
|
5
|
+
|
|
6
|
+
; Strings
|
|
7
|
+
(double_quoted_string) @string
|
|
8
|
+
(single_quoted_string) @string
|
|
9
|
+
(unquoted_string) @string
|
|
10
|
+
(escape_sequence) @string.escape
|
|
11
|
+
|
|
12
|
+
; Numbers
|
|
13
|
+
(number) @number
|
|
14
|
+
|
|
15
|
+
; Booleans
|
|
16
|
+
(true) @constant.builtin.boolean
|
|
17
|
+
(false) @constant.builtin.boolean
|
|
18
|
+
|
|
19
|
+
; Null
|
|
20
|
+
(null) @constant.builtin
|
|
21
|
+
|
|
22
|
+
; Object keys (property names)
|
|
23
|
+
(pair
|
|
24
|
+
key: (string) @property)
|
|
25
|
+
(pair
|
|
26
|
+
key: (unquoted_key) @property)
|
|
27
|
+
|
|
28
|
+
; Punctuation
|
|
29
|
+
"{" @punctuation.bracket
|
|
30
|
+
"}" @punctuation.bracket
|
|
31
|
+
"[" @punctuation.bracket
|
|
32
|
+
"]" @punctuation.bracket
|
|
33
|
+
":" @punctuation.delimiter
|
|
34
|
+
"," @punctuation.delimiter
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Ted Tyree, Michael Njuguna
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# JFX - FlexJson Language Support for VS Code
|
|
2
|
+
|
|
3
|
+
Syntax highlighting and language support for FlexJson (`.jfx`) files in Visual Studio Code.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Syntax highlighting** for `.jfx` files
|
|
8
|
+
- **Comment support** - both `//` line comments and `/* */` block comments
|
|
9
|
+
- **Flexible string syntax** - double quotes, single quotes, and unquoted strings
|
|
10
|
+
- **Auto-closing pairs** for brackets and quotes
|
|
11
|
+
- **Code folding** support
|
|
12
|
+
|
|
13
|
+
## What is FlexJson?
|
|
14
|
+
|
|
15
|
+
FlexJson is JSON with comments and flexible syntax. It's designed for configuration files where you want:
|
|
16
|
+
|
|
17
|
+
- Comments to document your config
|
|
18
|
+
- Less strict quoting requirements
|
|
19
|
+
- Full JSON compatibility when needed
|
|
20
|
+
|
|
21
|
+
### Example `.jfx` file
|
|
22
|
+
|
|
23
|
+
```jfx
|
|
24
|
+
/* Application Configuration
|
|
25
|
+
** Version 1.0
|
|
26
|
+
*/
|
|
27
|
+
{
|
|
28
|
+
// Database settings
|
|
29
|
+
database: {
|
|
30
|
+
host: localhost,
|
|
31
|
+
port: 5432,
|
|
32
|
+
name: "my-app-db"
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
// Feature flags
|
|
36
|
+
features: {
|
|
37
|
+
'dark-mode': true,
|
|
38
|
+
beta: false
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
/* Logging configuration
|
|
42
|
+
Levels: debug, info, warn, error */
|
|
43
|
+
logLevel: info
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
### From VSIX file
|
|
50
|
+
|
|
51
|
+
1. Download the `.vsix` file from releases
|
|
52
|
+
2. In VS Code, open Command Palette (`Ctrl+Shift+P`)
|
|
53
|
+
3. Run "Extensions: Install from VSIX..."
|
|
54
|
+
4. Select the downloaded file
|
|
55
|
+
|
|
56
|
+
### From source
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
cd extensions/vscode-jfx
|
|
60
|
+
npm install
|
|
61
|
+
npm run package
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Then install the generated `.vsix` file.
|
|
65
|
+
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
Simply create or open a file with the `.jfx` extension. The syntax highlighting will be applied automatically.
|
|
69
|
+
|
|
70
|
+
## Related
|
|
71
|
+
|
|
72
|
+
- [flex-json](https://www.npmjs.com/package/flex-json) - The FlexJson parsing library for Node.js
|
|
73
|
+
- [FlexJson GitHub](https://github.com/tedtyree/FlexJson) - Source repository
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT
|
|
Binary file
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"comments": {
|
|
3
|
+
"lineComment": "//",
|
|
4
|
+
"blockComment": ["/*", "*/"]
|
|
5
|
+
},
|
|
6
|
+
"brackets": [
|
|
7
|
+
["{", "}"],
|
|
8
|
+
["[", "]"]
|
|
9
|
+
],
|
|
10
|
+
"autoClosingPairs": [
|
|
11
|
+
{ "open": "{", "close": "}" },
|
|
12
|
+
{ "open": "[", "close": "]" },
|
|
13
|
+
{ "open": "\"", "close": "\"", "notIn": ["string"] },
|
|
14
|
+
{ "open": "'", "close": "'", "notIn": ["string"] }
|
|
15
|
+
],
|
|
16
|
+
"surroundingPairs": [
|
|
17
|
+
{ "open": "{", "close": "}" },
|
|
18
|
+
{ "open": "[", "close": "]" },
|
|
19
|
+
{ "open": "\"", "close": "\"" },
|
|
20
|
+
{ "open": "'", "close": "'" }
|
|
21
|
+
],
|
|
22
|
+
"folding": {
|
|
23
|
+
"markers": {
|
|
24
|
+
"start": "^\\s*//\\s*#?region\\b",
|
|
25
|
+
"end": "^\\s*//\\s*#?endregion\\b"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"wordPattern": "[\\w$]+",
|
|
29
|
+
"indentationRules": {
|
|
30
|
+
"increaseIndentPattern": "^.*\\{[^}\"']*$|^.*\\[[^\\]\"']*$",
|
|
31
|
+
"decreaseIndentPattern": "^\\s*[\\}\\]]"
|
|
32
|
+
}
|
|
33
|
+
}
|