Implement transform loop
This commit is contained in:
parent
9fb89fcd8b
commit
6aab8e8f65
73
corpus/transform.txt
Normal file
73
corpus/transform.txt
Normal 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))))))))))))
|
11
grammar.js
11
grammar.js
@ -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',
|
||||
|
@ -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": [
|
||||
|
@ -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,
|
||||
|
7671
src/parser.c
7671
src/parser.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user