1
0

Implement find syntax

This commit is contained in:
Jeff 2023-10-18 18:18:41 -04:00
parent 810c7bb6f6
commit b9f47dc77f
5 changed files with 5586 additions and 5092 deletions

View 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)))))))))))))

View File

@ -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',

View File

@ -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": [

View File

@ -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