1
0

Update grammar and highlight queries

This commit is contained in:
Jeff 2024-02-19 15:24:44 -05:00
parent ca72fe04f1
commit 69347ad435
7 changed files with 25155 additions and 24879 deletions

View File

@ -9,7 +9,7 @@ secret_number = int:random_range(0..=100);
loop { loop {
output("Please input your guess.") output("Please input your guess.")
input = io::stdin():expect("Failed to read line.") input = io:stdin():expect("Failed to read line.")
guess = int:parse(input); guess = int:parse(input);
output("You guessed: " + guess) output("You guessed: " + guess)
@ -22,7 +22,5 @@ loop {
break; break;
} }
} }
} }

View File

@ -10,7 +10,7 @@ Simple As
(statement (statement
(statement_kind (statement_kind
(expression (expression
(as (as_node
(expression (expression
(value (value
(integer))) (integer)))
@ -28,7 +28,7 @@ foo as (int) -> int
(statement (statement
(statement_kind (statement_kind
(expression (expression
(as (as_node
(expression (expression
(identifier)) (identifier))
(type (type
@ -49,7 +49,7 @@ for i in foobar as [string] {}
(for (for
(identifier) (identifier)
(expression (expression
(as (as_node
(expression (expression
(identifier)) (identifier))
(type (type

View File

@ -31,7 +31,7 @@ module.exports = grammar({
$.for, $.for,
$.if_else, $.if_else,
$.index_assignment, $.index_assignment,
$.break_loop, $.loop_node,
$.match, $.match,
$.pipe, $.pipe,
$.while, $.while,
@ -52,7 +52,7 @@ module.exports = grammar({
_expression_kind: $ => _expression_kind: $ =>
prec.right( prec.right(
choice( choice(
$.as, $.as_node,
$.function_call, $.function_call,
$.identifier, $.identifier,
$.index, $.index,
@ -73,7 +73,7 @@ module.exports = grammar({
), ),
), ),
as: $ => as_node: $ =>
seq($.expression, 'as', $.type), seq($.expression, 'as', $.type),
pipe: $ => pipe: $ =>
@ -328,7 +328,7 @@ module.exports = grammar({
), ),
), ),
break_loop: $ => loop_node: $ =>
seq( seq(
'loop', 'loop',
$.block, $.block,

View File

@ -46,27 +46,26 @@
(logic_operator) @operator.logic (logic_operator) @operator.logic
(math_operator) @operator.math (math_operator) @operator.math
[
"as" "as" @keyword
"async" "async" @keyword
"break" "break" @keyword
"else" "else" @keyword
"else if" "else if" @keyword
"enum" "enum" @keyword
"false" "false" @keyword
"for" "for" @keyword
"if" "if" @keyword
"in" "in" @keyword
"loop" "match" @keyword
"match" "return" @keyword
"return" "struct" @keyword
"struct" "true" @keyword
"true" "while" @keyword
"while" "->" @keyword
"->" ":" @keyword
":" "::" @keyword
"::" "^" @keyword
"^" "loop" @keyword
] @keyword
(function_call) @function.call (function_call) @function.call

View File

@ -93,6 +93,10 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "index_assignment" "name": "index_assignment"
}, },
{
"type": "SYMBOL",
"name": "loop_node"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "match" "name": "match"
@ -146,7 +150,7 @@
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "as" "name": "as_node"
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
@ -207,7 +211,7 @@
} }
} }
}, },
"as": { "as_node": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
@ -978,6 +982,19 @@
] ]
} }
}, },
"loop_node": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "loop"
},
{
"type": "SYMBOL",
"name": "block"
}
]
},
"while": { "while": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [

View File

@ -1,6 +1,6 @@
[ [
{ {
"type": "as", "type": "as_node",
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
@ -190,7 +190,7 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "as", "type": "as_node",
"named": true "named": true
}, },
{ {
@ -471,6 +471,21 @@
"named": true, "named": true,
"fields": {} "fields": {}
}, },
{
"type": "loop_node",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "block",
"named": true
}
]
}
},
{ {
"type": "map", "type": "map",
"named": true, "named": true,
@ -645,6 +660,10 @@
"type": "index_assignment", "type": "index_assignment",
"named": true "named": true
}, },
{
"type": "loop_node",
"named": true
},
{ {
"type": "match", "type": "match",
"named": true "named": true
@ -1049,6 +1068,10 @@
"type": "list", "type": "list",
"named": false "named": false
}, },
{
"type": "loop",
"named": false
},
{ {
"type": "map", "type": "map",
"named": false "named": false

File diff suppressed because it is too large Load Diff