Skip to content

Commit 0f3f0f6

Browse files
committed
Merge branch 'main' into fix-mixed-args
2 parents d6219fa + 68211f5 commit 0f3f0f6

File tree

11 files changed

+530978
-524196
lines changed

11 files changed

+530978
-524196
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,18 @@ jobs:
2525
diff=`git diff HEAD -- src`
2626
echo "$diff"
2727
test -z "$diff"
28-
- name: Output parser size
29-
run: du -sh src/* | sort -h
28+
- name: Check the parser size
29+
run: |
30+
size_kib="$(du -sk src/parser.c | cut -f1)"
31+
size_mib="$((size_kib / 1024))"
32+
max_size_mib=35
33+
34+
echo "The parser is now at $size_mib MiB"
35+
if [ "$size_mib" -gt "$max_size_mib" ]; then
36+
echo "This is greater than the maximum size of $max_size_mib MiB!"
37+
exit 1
38+
fi
39+
shell: bash
3040
- name: Run tests
3141
run: npm test
3242
- name: Set up Rust

grammar.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ module.exports = grammar({
760760
$.bin_literal,
761761
$.character_literal,
762762
$.real_literal,
763-
"null",
763+
$.null_literal,
764764
$.long_literal,
765765
$.unsigned_literal
766766
),
@@ -830,16 +830,16 @@ module.exports = grammar({
830830

831831
if_expression: $ => prec.right(seq(
832832
"if",
833-
"(", $._expression, ")",
833+
"(", field('condition', $._expression), ")",
834834
choice(
835-
$.control_structure_body,
836-
";",
835+
field('consequence', $.control_structure_body),
837836
seq(
838-
optional($.control_structure_body),
837+
optional(field('consequence', $.control_structure_body)),
839838
optional(";"),
840-
"else",
841-
choice($.control_structure_body, ";")
842-
)
839+
"else",
840+
choice(field('alternative', $.control_structure_body), ";")
841+
),
842+
";"
843843
)
844844
)),
845845

@@ -1208,6 +1208,8 @@ module.exports = grammar({
12081208
$._escaped_identifier
12091209
),
12101210

1211+
null_literal: $ => "null",
1212+
12111213
// ==========
12121214
// Identifiers
12131215
// ==========

queries/highlights.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
] @number
206206

207207
[
208-
"null" ; should be highlighted the same as booleans
208+
(null_literal) ; should be highlighted the same as booleans
209209
(boolean_literal)
210210
] @boolean
211211

src/grammar.json

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3806,8 +3806,8 @@
38063806
"name": "real_literal"
38073807
},
38083808
{
3809-
"type": "STRING",
3810-
"value": "null"
3809+
"type": "SYMBOL",
3810+
"name": "null_literal"
38113811
},
38123812
{
38133813
"type": "SYMBOL",
@@ -4249,8 +4249,12 @@
42494249
"value": "("
42504250
},
42514251
{
4252-
"type": "SYMBOL",
4253-
"name": "_expression"
4252+
"type": "FIELD",
4253+
"name": "condition",
4254+
"content": {
4255+
"type": "SYMBOL",
4256+
"name": "_expression"
4257+
}
42544258
},
42554259
{
42564260
"type": "STRING",
@@ -4260,12 +4264,12 @@
42604264
"type": "CHOICE",
42614265
"members": [
42624266
{
4263-
"type": "SYMBOL",
4264-
"name": "control_structure_body"
4265-
},
4266-
{
4267-
"type": "STRING",
4268-
"value": ";"
4267+
"type": "FIELD",
4268+
"name": "consequence",
4269+
"content": {
4270+
"type": "SYMBOL",
4271+
"name": "control_structure_body"
4272+
}
42694273
},
42704274
{
42714275
"type": "SEQ",
@@ -4274,8 +4278,12 @@
42744278
"type": "CHOICE",
42754279
"members": [
42764280
{
4277-
"type": "SYMBOL",
4278-
"name": "control_structure_body"
4281+
"type": "FIELD",
4282+
"name": "consequence",
4283+
"content": {
4284+
"type": "SYMBOL",
4285+
"name": "control_structure_body"
4286+
}
42794287
},
42804288
{
42814289
"type": "BLANK"
@@ -4302,8 +4310,12 @@
43024310
"type": "CHOICE",
43034311
"members": [
43044312
{
4305-
"type": "SYMBOL",
4306-
"name": "control_structure_body"
4313+
"type": "FIELD",
4314+
"name": "alternative",
4315+
"content": {
4316+
"type": "SYMBOL",
4317+
"name": "control_structure_body"
4318+
}
43074319
},
43084320
{
43094321
"type": "STRING",
@@ -4312,6 +4324,10 @@
43124324
]
43134325
}
43144326
]
4327+
},
4328+
{
4329+
"type": "STRING",
4330+
"value": ";"
43154331
}
43164332
]
43174333
}
@@ -6177,6 +6193,10 @@
61776193
}
61786194
]
61796195
},
6196+
"null_literal": {
6197+
"type": "STRING",
6198+
"value": "null"
6199+
},
61806200
"_lexical_identifier": {
61816201
"type": "CHOICE",
61826202
"members": [

0 commit comments

Comments
 (0)