Skip to content

Commit

Permalink
Merge branch 'main' into fix-mixed-args
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Aug 31, 2024
2 parents d6219fa + 68211f5 commit 0f3f0f6
Show file tree
Hide file tree
Showing 11 changed files with 530,978 additions and 524,196 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,18 @@ jobs:
diff=`git diff HEAD -- src`
echo "$diff"
test -z "$diff"
- name: Output parser size
run: du -sh src/* | sort -h
- name: Check the parser size
run: |
size_kib="$(du -sk src/parser.c | cut -f1)"
size_mib="$((size_kib / 1024))"
max_size_mib=35
echo "The parser is now at $size_mib MiB"
if [ "$size_mib" -gt "$max_size_mib" ]; then
echo "This is greater than the maximum size of $max_size_mib MiB!"
exit 1
fi
shell: bash
- name: Run tests
run: npm test
- name: Set up Rust
Expand Down
18 changes: 10 additions & 8 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ module.exports = grammar({
$.bin_literal,
$.character_literal,
$.real_literal,
"null",
$.null_literal,
$.long_literal,
$.unsigned_literal
),
Expand Down Expand Up @@ -830,16 +830,16 @@ module.exports = grammar({

if_expression: $ => prec.right(seq(
"if",
"(", $._expression, ")",
"(", field('condition', $._expression), ")",
choice(
$.control_structure_body,
";",
field('consequence', $.control_structure_body),
seq(
optional($.control_structure_body),
optional(field('consequence', $.control_structure_body)),
optional(";"),
"else",
choice($.control_structure_body, ";")
)
"else",
choice(field('alternative', $.control_structure_body), ";")
),
";"
)
)),

Expand Down Expand Up @@ -1208,6 +1208,8 @@ module.exports = grammar({
$._escaped_identifier
),

null_literal: $ => "null",

// ==========
// Identifiers
// ==========
Expand Down
2 changes: 1 addition & 1 deletion queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
] @number

[
"null" ; should be highlighted the same as booleans
(null_literal) ; should be highlighted the same as booleans
(boolean_literal)
] @boolean

Expand Down
48 changes: 34 additions & 14 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -3806,8 +3806,8 @@
"name": "real_literal"
},
{
"type": "STRING",
"value": "null"
"type": "SYMBOL",
"name": "null_literal"
},
{
"type": "SYMBOL",
Expand Down Expand Up @@ -4249,8 +4249,12 @@
"value": "("
},
{
"type": "SYMBOL",
"name": "_expression"
"type": "FIELD",
"name": "condition",
"content": {
"type": "SYMBOL",
"name": "_expression"
}
},
{
"type": "STRING",
Expand All @@ -4260,12 +4264,12 @@
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "control_structure_body"
},
{
"type": "STRING",
"value": ";"
"type": "FIELD",
"name": "consequence",
"content": {
"type": "SYMBOL",
"name": "control_structure_body"
}
},
{
"type": "SEQ",
Expand All @@ -4274,8 +4278,12 @@
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "control_structure_body"
"type": "FIELD",
"name": "consequence",
"content": {
"type": "SYMBOL",
"name": "control_structure_body"
}
},
{
"type": "BLANK"
Expand All @@ -4302,8 +4310,12 @@
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "control_structure_body"
"type": "FIELD",
"name": "alternative",
"content": {
"type": "SYMBOL",
"name": "control_structure_body"
}
},
{
"type": "STRING",
Expand All @@ -4312,6 +4324,10 @@
]
}
]
},
{
"type": "STRING",
"value": ";"
}
]
}
Expand Down Expand Up @@ -6177,6 +6193,10 @@
}
]
},
"null_literal": {
"type": "STRING",
"value": "null"
},
"_lexical_identifier": {
"type": "CHOICE",
"members": [
Expand Down
Loading

0 comments on commit 0f3f0f6

Please sign in to comment.