Change language syntax for "map" to "struct"

This commit is contained in:
Jeff 2024-01-04 12:10:31 -05:00
parent 531227ba2d
commit 614bb6f23e
6 changed files with 11936 additions and 12159 deletions

View File

@ -151,10 +151,7 @@ Complex Function Call
foobar(
"hi"
42
{
x = 1
y = 2
}
Baz:new()
)
--------------------------------------------------------------------------------
@ -172,18 +169,13 @@ foobar(
(value
(integer)))
(expression
(value
(map
(identifier)
(statement
(expression
(value
(integer))))
(identifier)
(statement
(expression
(value
(integer)))))))))))
(function_call
(function_expression
(index
(index_expression
(identifier))
(index_expression
(identifier))))))))))
================================================================================
Callback Function Call

View File

@ -1,8 +1,8 @@
================================================================================
Simple Map
Simple Structure
================================================================================
{ answer = 42 }
struct { answer = 42 }
--------------------------------------------------------------------------------
@ -10,7 +10,7 @@ Simple Map
(statement
(expression
(value
(map
(structure
(identifier)
(statement
(expression
@ -18,10 +18,10 @@ Simple Map
(integer)))))))))
================================================================================
Map with Types
Structure with Types
================================================================================
{
struct {
answer <num> = 42
stuff <[str]> = [ "some" "stuff" ]
}
@ -32,7 +32,7 @@ Map with Types
(statement
(expression
(value
(map
(structure
(identifier)
(type_definition
(type))
@ -56,52 +56,26 @@ Map with Types
(string))))))))))))
================================================================================
Nested Maps
Nested Structures
================================================================================
x = {
y = {
foo = 'bar'
z = {
message = 'hiya'
}
}
f = 12
struct {
bar <Bar>
baz <Baz>
}
--------------------------------------------------------------------------------
(root
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(expression
(value
(map
(structure
(identifier)
(statement
(expression
(value
(map
(type_definition
(type
(identifier)))
(identifier)
(statement
(expression
(value
(string))))
(identifier)
(statement
(expression
(value
(map
(identifier)
(statement
(expression
(value
(string))))))))))))
(identifier)
(statement
(expression
(value
(integer)))))))))))
(type_definition
(type
(identifier))))))))

View File

@ -81,7 +81,7 @@ module.exports = grammar({
$.string,
$.boolean,
$.list,
$.map,
$.structure,
$.option,
$.built_in_value,
),
@ -167,15 +167,17 @@ module.exports = grammar({
']',
),
map: $ =>
structure: $ =>
seq(
'struct',
'{',
repeat1(
seq(
$.identifier,
optional($.type_definition),
'=',
$.statement,
optional(
seq('=', $.statement),
),
optional(','),
),
),
@ -347,10 +349,10 @@ module.exports = grammar({
'collection',
'float',
'int',
'map',
'none',
'num',
'str',
$.identifier,
seq('[', $.type, ']'),
seq(
'{',

View File

@ -235,7 +235,7 @@
},
{
"type": "SYMBOL",
"name": "map"
"name": "structure"
},
{
"type": "SYMBOL",
@ -501,9 +501,13 @@
}
]
},
"map": {
"structure": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "struct"
},
{
"type": "STRING",
"value": "{"
@ -529,6 +533,12 @@
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "="
@ -536,6 +546,13 @@
{
"type": "SYMBOL",
"name": "statement"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
@ -1099,10 +1116,6 @@
"type": "STRING",
"value": "int"
},
{
"type": "STRING",
"value": "map"
},
{
"type": "STRING",
"value": "none"
@ -1115,6 +1128,10 @@
"type": "STRING",
"value": "str"
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SEQ",
"members": [

View File

@ -375,29 +375,6 @@
"named": true,
"fields": {}
},
{
"type": "map",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "identifier",
"named": true
},
{
"type": "statement",
"named": true
},
{
"type": "type_definition",
"named": true
}
]
}
},
{
"type": "match",
"named": true,
@ -533,6 +510,29 @@
]
}
},
{
"type": "structure",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "identifier",
"named": true
},
{
"type": "statement",
"named": true
},
{
"type": "type_definition",
"named": true
}
]
}
},
{
"type": "type",
"named": true,
@ -603,10 +603,6 @@
"type": "list",
"named": true
},
{
"type": "map",
"named": true
},
{
"type": "option",
"named": true
@ -614,6 +610,10 @@
{
"type": "string",
"named": true
},
{
"type": "structure",
"named": true
}
]
}
@ -802,11 +802,11 @@
},
{
"type": "float",
"named": true
"named": false
},
{
"type": "float",
"named": false
"named": true
},
{
"type": "for",
@ -844,10 +844,6 @@
"type": "length",
"named": false
},
{
"type": "map",
"named": false
},
{
"type": "match",
"named": false
@ -892,6 +888,10 @@
"type": "string",
"named": false
},
{
"type": "struct",
"named": false
},
{
"type": "true",
"named": false

File diff suppressed because it is too large Load Diff