Add break expressions

This commit is contained in:
Bruno BELANYI 2022-06-01 20:23:46 +02:00
parent bb6875a11d
commit d32fd4fd6c
5 changed files with 1559 additions and 1391 deletions

View file

@ -51,6 +51,7 @@ module.exports = grammar({
$.if_expression,
$.while_expression,
$.for_expression,
$.break_expression,
),
nil_literal: (_) => "nil",
@ -204,6 +205,8 @@ module.exports = grammar({
"do",
field("body", $._expr),
),
break_expression: (_) => "break",
}
});

View file

@ -69,6 +69,10 @@
{
"type": "SYMBOL",
"name": "for_expression"
},
{
"type": "SYMBOL",
"name": "break_expression"
}
]
},
@ -937,6 +941,10 @@
}
}
]
},
"break_expression": {
"type": "STRING",
"value": "break"
}
},
"extras": [

View file

@ -23,6 +23,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -93,6 +97,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -197,6 +205,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -291,6 +303,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -367,6 +383,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -447,6 +467,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -523,6 +547,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -593,6 +621,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -673,6 +705,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -753,6 +789,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -839,6 +879,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -909,6 +953,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -979,6 +1027,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -1065,6 +1117,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -1185,6 +1241,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -1260,6 +1320,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -1350,6 +1414,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -1436,6 +1504,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -1506,6 +1578,10 @@
"type": "binary_expression",
"named": true
},
{
"type": "break_expression",
"named": true
},
{
"type": "for_expression",
"named": true
@ -1598,6 +1674,10 @@
"type": "]",
"named": false
},
{
"type": "break_expression",
"named": true
},
{
"type": "do",
"named": false

File diff suppressed because it is too large Load diff

View file

@ -111,3 +111,31 @@ for 12 to nil
(identifier)
(identifier))
(nil_literal))
================================================================================
Break
================================================================================
break
--------------------------------------------------------------------------------
(source_file
(break_expression))
================================================================================
Break in loops
================================================================================
for i := break to break do while break do break
--------------------------------------------------------------------------------
(source_file
(for_expression
(identifier)
(break_expression)
(break_expression)
(while_expression
(break_expression)
(break_expression))))