Skip to content

Commit

Permalink
feat: add full grammar
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Jan 9, 2024
1 parent 17fb6e1 commit c20a68e
Show file tree
Hide file tree
Showing 9 changed files with 13,356 additions and 13,240 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [macos-latest, ubuntu-latest]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
14 changes: 5 additions & 9 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ module.exports = grammar({
),

_simple_statement: $ => choice(
$.expression_statement,
$.expression,
$.assignment,
$.augmented_assignment,
$.unification,
$.import_statement,
$.assert_statement,
$.type_alias_statement,
Expand Down Expand Up @@ -229,13 +232,6 @@ module.exports = grammar({
optional(seq(',', $.expression))
),

expression_statement: $ => choice(
$.expression,
$.assignment,
$.augmented_assignment,
$.unification,
),

// Compound statements

_compound_statement: $ => choice(
Expand Down Expand Up @@ -705,7 +701,7 @@ module.exports = grammar({
),
seq(
repeat1(/[0-9]+_?/),
//optional($.multiplier),
field('multiplier', optional(choice('n', 'u', 'm', 'k', 'K', 'M', 'G', 'T', 'P', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi'))),
),
)),

Expand Down
108 changes: 86 additions & 22 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,19 @@
"members": [
{
"type": "SYMBOL",
"name": "expression_statement"
"name": "expression"
},
{
"type": "SYMBOL",
"name": "assignment"
},
{
"type": "SYMBOL",
"name": "augmented_assignment"
},
{
"type": "SYMBOL",
"name": "unification"
},
{
"type": "SYMBOL",
Expand Down Expand Up @@ -190,27 +202,6 @@
}
]
},
"expression_statement": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "SYMBOL",
"name": "assignment"
},
{
"type": "SYMBOL",
"name": "augmented_assignment"
},
{
"type": "SYMBOL",
"name": "unification"
}
]
},
"_compound_statement": {
"type": "CHOICE",
"members": [
Expand Down Expand Up @@ -2892,6 +2883,79 @@
"type": "PATTERN",
"value": "[0-9]+_?"
}
},
{
"type": "FIELD",
"name": "multiplier",
"content": {
"type": "CHOICE",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "n"
},
{
"type": "STRING",
"value": "u"
},
{
"type": "STRING",
"value": "m"
},
{
"type": "STRING",
"value": "k"
},
{
"type": "STRING",
"value": "K"
},
{
"type": "STRING",
"value": "M"
},
{
"type": "STRING",
"value": "G"
},
{
"type": "STRING",
"value": "T"
},
{
"type": "STRING",
"value": "P"
},
{
"type": "STRING",
"value": "Ki"
},
{
"type": "STRING",
"value": "Mi"
},
{
"type": "STRING",
"value": "Gi"
},
{
"type": "STRING",
"value": "Ti"
},
{
"type": "STRING",
"value": "Pi"
}
]
},
{
"type": "BLANK"
}
]
}
}
]
}
Expand Down
41 changes: 13 additions & 28 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@
"named": true
},
{
"type": "expression_statement",
"type": "assignment",
"named": true
},
{
"type": "augmented_assignment",
"named": true
},
{
"type": "expression",
"named": true
},
{
Expand All @@ -40,6 +48,10 @@
{
"type": "type_alias_statement",
"named": true
},
{
"type": "unification",
"named": true
}
]
},
Expand Down Expand Up @@ -863,33 +875,6 @@
}
}
},
{
"type": "expression_statement",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "assignment",
"named": true
},
{
"type": "augmented_assignment",
"named": true
},
{
"type": "expression",
"named": true
},
{
"type": "unification",
"named": true
}
]
}
},
{
"type": "for_in_clause",
"named": true,
Expand Down
Loading

0 comments on commit c20a68e

Please sign in to comment.