Skip to content

Commit

Permalink
Fix scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Jan 24, 2024
1 parent ce1b349 commit b0f92eb
Show file tree
Hide file tree
Showing 6 changed files with 3,782 additions and 3,509 deletions.
7 changes: 2 additions & 5 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ module.exports = grammar({
export: ($) => seq("export", $.assignment),

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

// module : 'mod' '?'? string?
module: ($) =>
Expand Down Expand Up @@ -191,7 +191,7 @@ module.exports = grammar({
$.function_call,
$.external_command,
$.identifier,
$.string_literal,
$._string,
seq("(", $.expression, ")"),
),
),
Expand All @@ -204,9 +204,6 @@ module.exports = grammar({
")",
),

external_command: ($) =>
choice(seq($._backticked), seq($._indented_backticked)),

// sequence : expression ',' sequence
// | expression ','?
sequence: ($) => comma_sep1($.expression),
Expand Down
12 changes: 11 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
debug_env := env("DEBUG", "default")

Check notice on line 1 in justfile

View workflow job for this annotation

GitHub Actions / static-validation

checking Just parsing
debug_arg := if debug_env == "1" {
"--debug-build"
} else if debug_env == "default" {
""
} else {
error("unrecognized DEBUG variable " + debug_env)
}

# List all recipes
default:
just --list
Expand All @@ -14,7 +23,8 @@ format:

# Generate the parser
gen:
npm run gen
tree-sitter generate {{ debug_arg }}
python3 build-flavored-queries.py

alias t := test-ts

Expand Down
114 changes: 57 additions & 57 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
},
{
"type": "SYMBOL",
"name": "string_literal"
"name": "_string"
}
]
},
Expand Down Expand Up @@ -638,7 +638,7 @@
},
{
"type": "SYMBOL",
"name": "string_literal"
"name": "_string"
},
{
"type": "SEQ",
Expand Down Expand Up @@ -697,61 +697,6 @@
}
]
},
"external_command": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "open",
"content": {
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_command_start"
},
"named": false,
"value": "(`|```)"
}
},
{
"type": "FIELD",
"name": "body",
"content": {
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "PREC",
"value": 1,
"content": {
"type": "SYMBOL",
"name": "interpolation"
}
},
{
"type": "SYMBOL",
"name": "command_body"
}
]
}
}
},
{
"type": "FIELD",
"name": "close",
"content": {
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_command_end"
},
"named": false,
"value": "(`|```)"
}
}
]
},
"sequence": {
"type": "SEQ",
"members": [
Expand Down Expand Up @@ -1379,6 +1324,61 @@
}
]
},
"external_command": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "open",
"content": {
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_command_start"
},
"named": false,
"value": "(`|```)"
}
},
{
"type": "FIELD",
"name": "body",
"content": {
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "PREC",
"value": 1,
"content": {
"type": "SYMBOL",
"name": "interpolation"
}
},
{
"type": "SYMBOL",
"name": "command_body"
}
]
}
}
},
{
"type": "FIELD",
"name": "close",
"content": {
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_command_end"
},
"named": false,
"value": "(`|```)"
}
}
]
},
"command_body": {
"type": "SYMBOL",
"name": "_content_component"
Expand Down
8 changes: 8 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@
"multiple": false,
"required": true,
"types": [
{
"type": "raw_string_literal",
"named": true
},
{
"type": "string_literal",
"named": true
Expand Down Expand Up @@ -840,6 +844,10 @@
"type": "identifier",
"named": true
},
{
"type": "raw_string_literal",
"named": true
},
{
"type": "string_literal",
"named": true
Expand Down
Loading

0 comments on commit b0f92eb

Please sign in to comment.