Modify struct, enum and match syntax

This commit is contained in:
Jeff 2024-02-18 10:34:59 -05:00
parent ef12d97895
commit 979335f497
8 changed files with 32776 additions and 28711 deletions

View File

@ -90,7 +90,7 @@ impl AbstractTree for ValueNode {
ValueNode::Enum { name, variant , expression }
}
"struct_instance" => {
let name_node = child.child(1).unwrap();
let name_node = child.child(0).unwrap();
let name = Identifier::from_syntax(name_node, source, context)?;
let properties_node = child.child(2).unwrap();

View File

@ -9,7 +9,7 @@ fn simple_struct() {
baz <str>
}
new Foo {
Foo::{
baz = 'hiya'
}
",
@ -37,8 +37,8 @@ fn nested_struct() {
}
struct Bar {}
new Foo {
bar = new Bar {}
Foo::{
bar = Bar::{}
}
",
);

View File

@ -2,12 +2,12 @@
Match Values
================================================================================
match x {
1 => {
match x
1 -> {
true
}
2 => false
}
2 -> false
--------------------------------------------------------------------------------
@ -41,10 +41,10 @@ match x {
Match Enum
================================================================================
match foobar {
FooBar::Foo => true
FooBar::Bar => false
}
match foobar
FooBar::Foo -> true
FooBar::Bar -> false
--------------------------------------------------------------------------------

View File

@ -30,7 +30,7 @@ struct Foo {
x <int>
y <float> = 0.0
bar <Bar> = new Bar {
bar <Bar> = Bar::{
baz = 42
}
}

View File

@ -294,16 +294,14 @@ module.exports = grammar({
seq(
'match',
$.expression,
'{',
repeat1(
seq(
$.match_pattern,
'=>',
'->',
$.statement,
optional(','),
),
),
'}',
),
),
@ -517,6 +515,6 @@ module.exports = grammar({
),
struct_instance: $ =>
seq('new', $.identifier, $.map),
seq($.identifier, '::', $.map),
},
});

View File

@ -872,10 +872,6 @@
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "{"
},
{
"type": "REPEAT1",
"content": {
@ -887,7 +883,7 @@
},
{
"type": "STRING",
"value": "=>"
"value": "->"
},
{
"type": "SYMBOL",
@ -907,10 +903,6 @@
}
]
}
},
{
"type": "STRING",
"value": "}"
}
]
}
@ -1606,14 +1598,14 @@
"struct_instance": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "new"
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "STRING",
"value": "::"
},
{
"type": "SYMBOL",
"name": "map"

View File

@ -922,10 +922,6 @@
"type": "==",
"named": false
},
{
"type": "=>",
"named": false
},
{
"type": ">",
"named": false
@ -1046,10 +1042,6 @@
"type": "nan",
"named": false
},
{
"type": "new",
"named": false
},
{
"type": "none",
"named": false

File diff suppressed because it is too large Load Diff