Skip to content

Commit

Permalink
feat: add support for const qualifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Mar 10, 2023
1 parent 741298f commit 58e9655
Show file tree
Hide file tree
Showing 5 changed files with 5,797 additions and 5,594 deletions.
6 changes: 4 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ module.exports = grammar({
),

port: $ => seq(
$.dir, $.identifier, ':', $.type, optional($.info), $._newline,
$.dir, $.identifier, ':', optional($.qualifier), $.type, optional($.info), $._newline
),

dir: _ => choice('input', 'output'),

qualifier: _ => choice('const'),

type: $ => choice(
seq(
choice('UInt', 'SInt', 'Analog'),
Expand Down Expand Up @@ -381,7 +383,7 @@ module.exports = grammar({

_escape_sequence: $ =>
choice(
prec(2, token.immediate(seq('\\', /[^abfnrtvxu'\"\\\?]/))),
prec(2, token.immediate(seq('\\', /[^abfnrtvxu'"\\?]/))),
prec(1, $.escape_sequence)
),
escape_sequence: _ => token.immediate(seq(
Expand Down
6 changes: 5 additions & 1 deletion queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@

; Qualifiers

(qualifier) @type.qualifier

; Storageclasses

[
"input"
"output"
] @type.qualifier ; Could be storageclass tbh..
] @storageclass

; Conditionals

Expand Down
21 changes: 21 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,18 @@
"type": "STRING",
"value": ":"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "qualifier"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "type"
Expand Down Expand Up @@ -261,6 +273,15 @@
}
]
},
"qualifier": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "const"
}
]
},
"type": {
"type": "CHOICE",
"members": [
Expand Down
13 changes: 13 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,10 @@
"type": "info",
"named": true
},
{
"type": "qualifier",
"named": true
},
{
"type": "type",
"named": true
Expand Down Expand Up @@ -643,6 +647,11 @@
]
}
},
{
"type": "qualifier",
"named": true,
"fields": {}
},
{
"type": "raw_string",
"named": true,
Expand Down Expand Up @@ -1187,6 +1196,10 @@
"type": "comment",
"named": true
},
{
"type": "const",
"named": false
},
{
"type": "cover",
"named": false
Expand Down
Loading

0 comments on commit 58e9655

Please sign in to comment.