Implement find syntax
This commit is contained in:
parent
810c7bb6f6
commit
b9f47dc77f
79
tree-sitter-dust/corpus/find.txt
Normal file
79
tree-sitter-dust/corpus/find.txt
Normal file
@ -0,0 +1,79 @@
|
||||
==================
|
||||
Find Loop
|
||||
==================
|
||||
|
||||
find i in [1, 2, 3] {
|
||||
i <= 3
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(root
|
||||
(item
|
||||
(statement
|
||||
(find
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(item
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))
|
||||
|
||||
==================
|
||||
Find Loop Assignment
|
||||
==================
|
||||
|
||||
found = find i in ["one", "two", "three"] {
|
||||
i == "three"
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(root
|
||||
(item
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(find
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(item
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))))
|
@ -20,6 +20,7 @@ module.exports = grammar({
|
||||
$.for,
|
||||
$.transform,
|
||||
$.filter,
|
||||
$.find,
|
||||
),
|
||||
|
||||
comment: $ => seq(/[#]+.*/),
|
||||
@ -206,6 +207,16 @@ module.exports = grammar({
|
||||
'}',
|
||||
),
|
||||
|
||||
find: $ => seq(
|
||||
'find',
|
||||
$.identifier,
|
||||
'in',
|
||||
$.expression,
|
||||
'{',
|
||||
$.item,
|
||||
'}',
|
||||
),
|
||||
|
||||
tool: $ => choice(
|
||||
'assert',
|
||||
'assert_equal',
|
||||
|
@ -66,6 +66,10 @@
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "filter"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "find"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -829,6 +833,39 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"find": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "find"
|
||||
},
|
||||
{
|
||||
"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": [
|
||||
|
@ -140,6 +140,29 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "find",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "expression",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "item",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "for",
|
||||
"named": true,
|
||||
@ -429,6 +452,10 @@
|
||||
"type": "filter",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "find",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "for",
|
||||
"named": true
|
||||
@ -677,6 +704,10 @@
|
||||
"type": "filter",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "find",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "fish",
|
||||
"named": false
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user