Skip to content

Commit

Permalink
Rename string to string_literal as part of the un-revert
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Jan 23, 2024
1 parent 5fc446a commit 4f5d53b
Show file tree
Hide file tree
Showing 11 changed files with 219 additions and 210 deletions.
15 changes: 9 additions & 6 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ module.exports = grammar({
export: ($) => seq("export", $.assignment),

// import : 'import' '?'? string?
import: ($) => seq("import", optional("?"), $.string),
import: ($) => seq("import", optional("?"), $.string_literal),

// module : 'mod' '?'? string?
module: ($) =>
seq(
"mod",
optional("?"),
field("mod_name", $.identifier),
optional($.string),
optional($.string_literal),
),

// setting : 'set' 'dotenv-load' boolean?
Expand All @@ -108,7 +108,10 @@ module.exports = grammar({
field(
"right",
optional(
seq(":=", choice($.boolean, $.string, array($.string))),
seq(
":=",
choice($.boolean, $.string_literal, array($.string_literal)),
),
),
),
$.eol,
Expand All @@ -119,7 +122,7 @@ module.exports = grammar({
":=",
field(
"right",
array($.string),
array($.string_literal),
),
$.eol,
),
Expand Down Expand Up @@ -181,7 +184,7 @@ module.exports = grammar({
$.function_call,
$.external_command,
$.identifier,
$.string,
$.string_literal,
seq("(", $.expression, ")"),
),
),
Expand Down Expand Up @@ -300,7 +303,7 @@ module.exports = grammar({
// | INDENTED_STRING
// | RAW_STRING
// | INDENTED_RAW_STRING
string: ($) =>
string_literal: ($) =>
choice(
$._string_indented,
$._raw_string_indented,
Expand Down
10 changes: 8 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ alias fmt := format
format:
deno fmt

# Generate the parser
gen:
npm run gen

alias t := test-ts

# Run tests that are built into tree-sitter
test-ts:
npm test
test-ts *ts-test-args: gen
npm test -- {{ ts-test-args }}

# Verify that tree-sitter can parse and highlight all files in the repo. Requires a tree-sitter configuration.
test-parse-highlight:
Expand Down
4 changes: 2 additions & 2 deletions queries-src/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
(dependency_expression recipe: (identifier) @function)

; handle escape sequences
(string (string_escape) @constant.character.escape)
(string) @string
(string_literal (string_escape) @constant.character.escape)
(string_literal) @string

(comment) @comment.line

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

(recipe) @indent @extend
(string) @indent @extend
(string_literal) @indent @extend
(external_command) @indent @extend
4 changes: 2 additions & 2 deletions queries/just/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
(dependency_expression recipe: (identifier) @function)

; handle escape sequences
(string (string_escape) @string.escape)
(string) @string
(string_literal (string_escape) @string.escape)
(string_literal) @string

(comment) @comment

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

(recipe) @indent @extend
(string) @indent @extend
(string_literal) @indent @extend
(external_command) @indent @extend
22 changes: 11 additions & 11 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
},
{
"type": "SYMBOL",
"name": "string"
"name": "string_literal"
}
]
},
Expand Down Expand Up @@ -204,7 +204,7 @@
"members": [
{
"type": "SYMBOL",
"name": "string"
"name": "string_literal"
},
{
"type": "BLANK"
Expand Down Expand Up @@ -253,7 +253,7 @@
},
{
"type": "SYMBOL",
"name": "string"
"name": "string_literal"
},
{
"type": "FIELD",
Expand Down Expand Up @@ -282,7 +282,7 @@
"name": "array_item",
"content": {
"type": "SYMBOL",
"name": "string"
"name": "string_literal"
}
},
{
Expand All @@ -299,7 +299,7 @@
"name": "array_item",
"content": {
"type": "SYMBOL",
"name": "string"
"name": "string_literal"
}
}
]
Expand All @@ -315,7 +315,7 @@
"name": "array_item",
"content": {
"type": "SYMBOL",
"name": "string"
"name": "string_literal"
}
},
{
Expand Down Expand Up @@ -399,7 +399,7 @@
"name": "array_item",
"content": {
"type": "SYMBOL",
"name": "string"
"name": "string_literal"
}
},
{
Expand All @@ -416,7 +416,7 @@
"name": "array_item",
"content": {
"type": "SYMBOL",
"name": "string"
"name": "string_literal"
}
}
]
Expand All @@ -432,7 +432,7 @@
"name": "array_item",
"content": {
"type": "SYMBOL",
"name": "string"
"name": "string_literal"
}
},
{
Expand Down Expand Up @@ -725,7 +725,7 @@
},
{
"type": "SYMBOL",
"name": "string"
"name": "string_literal"
},
{
"type": "SEQ",
Expand Down Expand Up @@ -1308,7 +1308,7 @@
"type": "PATTERN",
"value": "[a-zA-Z_][a-zA-Z0-9_-]*"
},
"string": {
"string_literal": {
"type": "CHOICE",
"members": [
{
Expand Down
14 changes: 7 additions & 7 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
"required": true,
"types": [
{
"type": "string",
"type": "string_literal",
"named": true
}
]
Expand Down Expand Up @@ -396,7 +396,7 @@
"required": false,
"types": [
{
"type": "string",
"type": "string_literal",
"named": true
}
]
Expand Down Expand Up @@ -586,7 +586,7 @@
"required": false,
"types": [
{
"type": "string",
"type": "string_literal",
"named": true
}
]
Expand All @@ -600,7 +600,7 @@
"named": false
},
{
"type": "string",
"type": "string_literal",
"named": true
}
]
Expand Down Expand Up @@ -636,7 +636,7 @@
"named": true
},
{
"type": "string",
"type": "string_literal",
"named": true
}
]
Expand Down Expand Up @@ -678,7 +678,7 @@
}
},
{
"type": "string",
"type": "string_literal",
"named": true,
"fields": {},
"children": {
Expand Down Expand Up @@ -717,7 +717,7 @@
"named": true
},
{
"type": "string",
"type": "string_literal",
"named": true
}
]
Expand Down
Loading

0 comments on commit 4f5d53b

Please sign in to comment.