Implement transform loop

This commit is contained in:
Jeff 2023-10-17 16:39:54 -04:00
parent 9fb89fcd8b
commit 6aab8e8f65
5 changed files with 4136 additions and 3683 deletions

73
corpus/transform.txt Normal file
View File

@ -0,0 +1,73 @@
==================
Transform Loop
==================
transform i in [1, 2, 3] {
(output i)
}
---
(root
(item
(statement
(transform
(identifier)
(expression
(value
(list
(expression
(value
(integer)))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(item
(statement
(expression
(function_call
(tool)
(expression
(identifier))))))))))
==================
Transform Loop Assignment
==================
list = transform i in ["one", "two", "three"] {
(output i)
}
---
(root
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(transform
(identifier)
(expression
(value
(list
(expression
(value
(string)))
(expression
(value
(string)))
(expression
(value
(string))))))
(item
(statement
(expression
(function_call
(tool)
(expression
(identifier))))))))))))

View File

@ -18,6 +18,7 @@ module.exports = grammar({
$.while,
$.async,
$.for,
$.transform,
),
comment: $ => seq(/[#]+.*/),
@ -184,6 +185,16 @@ module.exports = grammar({
'}',
),
transform: $ => seq(
'transform',
$.identifier,
'in',
$.expression,
'{',
$.item,
'}',
),
tool: $ => choice(
'assert',
'assert_equal',

View File

@ -58,6 +58,10 @@
{
"type": "SYMBOL",
"name": "for"
},
{
"type": "SYMBOL",
"name": "transform"
}
]
},
@ -755,6 +759,39 @@
}
]
},
"transform": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "transform"
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "STRING",
"value": "in"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "item"
},
{
"type": "STRING",
"value": "}"
}
]
},
"tool": {
"type": "CHOICE",
"members": [

View File

@ -418,6 +418,10 @@
"type": "select",
"named": true
},
{
"type": "transform",
"named": true
},
{
"type": "while",
"named": true
@ -449,6 +453,29 @@
"named": true,
"fields": {}
},
{
"type": "transform",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "expression",
"named": true
},
{
"type": "identifier",
"named": true
},
{
"type": "item",
"named": true
}
]
}
},
{
"type": "value",
"named": true,

File diff suppressed because it is too large Load Diff