1
0

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( foobar(
"hi" "hi"
42 42
{ Baz:new()
x = 1
y = 2
}
) )
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -172,18 +169,13 @@ foobar(
(value (value
(integer))) (integer)))
(expression (expression
(value (function_call
(map (function_expression
(identifier) (index
(statement (index_expression
(expression (identifier))
(value (index_expression
(integer)))) (identifier))))))))))
(identifier)
(statement
(expression
(value
(integer)))))))))))
================================================================================ ================================================================================
Callback Function Call 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 (statement
(expression (expression
(value (value
(map (structure
(identifier) (identifier)
(statement (statement
(expression (expression
@ -18,10 +18,10 @@ Simple Map
(integer))))))))) (integer)))))))))
================================================================================ ================================================================================
Map with Types Structure with Types
================================================================================ ================================================================================
{ struct {
answer <num> = 42 answer <num> = 42
stuff <[str]> = [ "some" "stuff" ] stuff <[str]> = [ "some" "stuff" ]
} }
@ -32,7 +32,7 @@ Map with Types
(statement (statement
(expression (expression
(value (value
(map (structure
(identifier) (identifier)
(type_definition (type_definition
(type)) (type))
@ -56,52 +56,26 @@ Map with Types
(string)))))))))))) (string))))))))))))
================================================================================ ================================================================================
Nested Maps Nested Structures
================================================================================ ================================================================================
x = { struct {
y = { bar <Bar>
foo = 'bar' baz <Baz>
z = {
message = 'hiya'
}
}
f = 12
} }
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
(root (root
(statement (statement
(assignment (expression
(identifier) (value
(assignment_operator) (structure
(statement (identifier)
(expression (type_definition
(value (type
(map (identifier)))
(identifier) (identifier)
(statement (type_definition
(expression (type
(value (identifier))))))))
(map
(identifier)
(statement
(expression
(value
(string))))
(identifier)
(statement
(expression
(value
(map
(identifier)
(statement
(expression
(value
(string))))))))))))
(identifier)
(statement
(expression
(value
(integer)))))))))))

View File

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

View File

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

View File

@ -375,29 +375,6 @@
"named": true, "named": true,
"fields": {} "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", "type": "match",
"named": true, "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", "type": "type",
"named": true, "named": true,
@ -603,10 +603,6 @@
"type": "list", "type": "list",
"named": true "named": true
}, },
{
"type": "map",
"named": true
},
{ {
"type": "option", "type": "option",
"named": true "named": true
@ -614,6 +610,10 @@
{ {
"type": "string", "type": "string",
"named": true "named": true
},
{
"type": "structure",
"named": true
} }
] ]
} }
@ -802,11 +802,11 @@
}, },
{ {
"type": "float", "type": "float",
"named": true "named": false
}, },
{ {
"type": "float", "type": "float",
"named": false "named": true
}, },
{ {
"type": "for", "type": "for",
@ -844,10 +844,6 @@
"type": "length", "type": "length",
"named": false "named": false
}, },
{
"type": "map",
"named": false
},
{ {
"type": "match", "type": "match",
"named": false "named": false
@ -892,6 +888,10 @@
"type": "string", "type": "string",
"named": false "named": false
}, },
{
"type": "struct",
"named": false
},
{ {
"type": "true", "type": "true",
"named": false "named": false

File diff suppressed because it is too large Load Diff