Skip to content

Commit

Permalink
Injection parsing working
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Jan 5, 2024
1 parent 34be3f0 commit ac72cf3
Show file tree
Hide file tree
Showing 12 changed files with 3,611 additions and 3,554 deletions.
30 changes: 16 additions & 14 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ module.exports = grammar({
$._indent,
$._dedent,
$._newline,
$.string_start,
$.string_end,
$.string_body,
$.raw_string_start,
$.raw_string_end,
$.command_start,
$.command_end,
$._string_start,
$._string_end,
$._string_body,
$._raw_string_start,
$._raw_string_end,
$._command_start,
$._command_end,
],
inline: (
$,
Expand Down Expand Up @@ -310,21 +310,23 @@ module.exports = grammar({

string_literal: ($) =>
seq(
$.string_start,
repeat(choice($.string_body, $.escape_sequence)),
$.string_end,
$._string_start,
repeat(choice($._string_body, $.escape_sequence)),
$._string_end,
),

raw_string_literal: ($) =>
seq($.raw_string_start, optional($.string_body), $.raw_string_end),
seq($._raw_string_start, optional($._string_body), $._raw_string_end),

external_command: ($) =>
seq(
$.command_start,
repeat(choice($.string_body, $.interpolation)),
$.command_end,
$._command_start,
repeat(choice(prec(1, $.interpolation), $.command_body)),
$._command_end,
),

command_body: ($) => $._string_body,

escape_sequence: (_) => ESCAPE_SEQUENCE,

text: (_) => /.+/, //recipe TEXT, only matches in a recipe body
Expand Down
2 changes: 1 addition & 1 deletion queries-src/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@

["," ":"] @punctuation.delimiter

"`" @punctuation.special
; "`" @punctuation.special

(ERROR) @error
3 changes: 2 additions & 1 deletion queries-src/indents.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
; Better documentation is in https://docs.helix-editor.com/guides/indent.html

(recipe) @indent @extend
(string) @indent @extend
(string_literal) @indent @extend
(raw_string_literal) @indent @extend
(external_command) @indent @extend
2 changes: 1 addition & 1 deletion queries/just/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@

["," ":"] @punctuation.delimiter

"`" @punctuation.special
; "`" @punctuation.special

(ERROR) @error
3 changes: 2 additions & 1 deletion queries/just/indents.scm
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
; Better documentation is in https://docs.helix-editor.com/guides/indent.html

(recipe) @indent @extend
(string) @indent @extend
(string_literal) @indent @extend
(raw_string_literal) @indent @extend
(external_command) @indent @extend
44 changes: 26 additions & 18 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@
"members": [
{
"type": "SYMBOL",
"name": "string_start"
"name": "_string_start"
},
{
"type": "REPEAT",
Expand All @@ -1308,7 +1308,7 @@
"members": [
{
"type": "SYMBOL",
"name": "string_body"
"name": "_string_body"
},
{
"type": "SYMBOL",
Expand All @@ -1319,7 +1319,7 @@
},
{
"type": "SYMBOL",
"name": "string_end"
"name": "_string_end"
}
]
},
Expand All @@ -1328,14 +1328,14 @@
"members": [
{
"type": "SYMBOL",
"name": "raw_string_start"
"name": "_raw_string_start"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "string_body"
"name": "_string_body"
},
{
"type": "BLANK"
Expand All @@ -1344,7 +1344,7 @@
},
{
"type": "SYMBOL",
"name": "raw_string_end"
"name": "_raw_string_end"
}
]
},
Expand All @@ -1353,30 +1353,38 @@
"members": [
{
"type": "SYMBOL",
"name": "command_start"
"name": "_command_start"
},
{
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "string_body"
"type": "PREC",
"value": 1,
"content": {
"type": "SYMBOL",
"name": "interpolation"
}
},
{
"type": "SYMBOL",
"name": "interpolation"
"name": "command_body"
}
]
}
},
{
"type": "SYMBOL",
"name": "command_end"
"name": "_command_end"
}
]
},
"command_body": {
"type": "SYMBOL",
"name": "_string_body"
},
"escape_sequence": {
"type": "TOKEN",
"content": {
Expand Down Expand Up @@ -1412,31 +1420,31 @@
},
{
"type": "SYMBOL",
"name": "string_start"
"name": "_string_start"
},
{
"type": "SYMBOL",
"name": "string_end"
"name": "_string_end"
},
{
"type": "SYMBOL",
"name": "string_body"
"name": "_string_body"
},
{
"type": "SYMBOL",
"name": "raw_string_start"
"name": "_raw_string_start"
},
{
"type": "SYMBOL",
"name": "raw_string_end"
"name": "_raw_string_end"
},
{
"type": "SYMBOL",
"name": "command_start"
"name": "_command_start"
},
{
"type": "SYMBOL",
"name": "command_end"
"name": "_command_end"
}
],
"inline": [
Expand Down
79 changes: 9 additions & 70 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@
"named": true,
"fields": {}
},
{
"type": "command_body",
"named": true,
"fields": {}
},
{
"type": "comment",
"named": true,
Expand Down Expand Up @@ -252,23 +257,15 @@
"fields": {},
"children": {
"multiple": true,
"required": true,
"required": false,
"types": [
{
"type": "command_end",
"named": true
},
{
"type": "command_start",
"type": "command_body",
"named": true
},
{
"type": "interpolation",
"named": true
},
{
"type": "string_body",
"named": true
}
]
}
Expand Down Expand Up @@ -480,25 +477,7 @@
{
"type": "raw_string_literal",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "raw_string_end",
"named": true
},
{
"type": "raw_string_start",
"named": true
},
{
"type": "string_body",
"named": true
}
]
}
"fields": {}
},
{
"type": "recipe",
Expand Down Expand Up @@ -748,23 +727,11 @@
"fields": {},
"children": {
"multiple": true,
"required": true,
"required": false,
"types": [
{
"type": "escape_sequence",
"named": true
},
{
"type": "string_body",
"named": true
},
{
"type": "string_end",
"named": true
},
{
"type": "string_start",
"named": true
}
]
}
Expand Down Expand Up @@ -922,14 +889,6 @@
"type": "alias",
"named": false
},
{
"type": "command_end",
"named": true
},
{
"type": "command_start",
"named": true
},
{
"type": "else",
"named": false
Expand Down Expand Up @@ -962,14 +921,6 @@
"type": "mod",
"named": false
},
{
"type": "raw_string_end",
"named": true
},
{
"type": "raw_string_start",
"named": true
},
{
"type": "set",
"named": false
Expand All @@ -978,18 +929,6 @@
"type": "shell",
"named": false
},
{
"type": "string_body",
"named": true
},
{
"type": "string_end",
"named": true
},
{
"type": "string_start",
"named": true
},
{
"type": "text",
"named": true
Expand Down
Loading

0 comments on commit ac72cf3

Please sign in to comment.