1
0

Refine implementation

This commit is contained in:
Jeff 2024-01-23 15:46:20 -05:00
parent bdef5db051
commit 42ec57bf82
6 changed files with 13428 additions and 13848 deletions

View File

@ -19,7 +19,7 @@ pub enum ValueNode {
Option(Option<Box<Expression>>),
Map(BTreeMap<String, (Statement, Option<Type>)>),
BuiltInValue(BuiltInValue),
StructureDefinition(BTreeMap<String, (Option<Statement>, Type)>),
Structure(BTreeMap<String, (Option<Statement>, Type)>),
}
impl AbstractTree for ValueNode {
@ -160,7 +160,7 @@ impl AbstractTree for ValueNode {
}
}
ValueNode::StructureDefinition(btree_map)
ValueNode::Structure(btree_map)
}
_ => {
return Err(Error::UnexpectedSyntaxNode {
@ -230,7 +230,7 @@ impl AbstractTree for ValueNode {
Value::Map(map)
}
ValueNode::BuiltInValue(built_in_value) => built_in_value.run(source, context)?,
ValueNode::StructureDefinition(node_map) => {
ValueNode::Structure(node_map) => {
let mut value_map = BTreeMap::new();
for (key, (statement_option, r#type)) in node_map {
@ -287,7 +287,7 @@ impl AbstractTree for ValueNode {
}
ValueNode::Map(_) => Type::Map(None),
ValueNode::BuiltInValue(built_in_value) => built_in_value.expected_type(context)?,
ValueNode::StructureDefinition(node_map) => {
ValueNode::Structure(node_map) => {
let mut value_map = BTreeMap::new();
for (key, (_statement_option, r#type)) in node_map {
@ -357,7 +357,7 @@ impl Format for ValueNode {
output.push('}');
}
ValueNode::BuiltInValue(built_in_value) => built_in_value.format(output, indent_level),
ValueNode::StructureDefinition(nodes) => {
ValueNode::Structure(nodes) => {
output.push('{');
for (key, (value_option, r#type)) in nodes {

View File

@ -13,14 +13,13 @@ struct {
(statement
(expression
(value
(type_definition
(structure
(identifier)
(type_specification
(type))
(identifier)
(type_specification
(type))))))))
(type)))))))
================================================================================
Complex Structure
@ -45,7 +44,6 @@ Foo = struct {
(statement
(expression
(value
(type_definition
(structure
(identifier)
(type_specification
@ -69,4 +67,4 @@ Foo = struct {
(statement
(expression
(value
(integer)))))))))))))))
(integer))))))))))))))

View File

@ -85,11 +85,6 @@ module.exports = grammar({
$.map,
$.option,
$.built_in_value,
$.type_definition,
),
type_definition: $ =>
choice(
$.structure,
),

View File

@ -249,15 +249,6 @@
"type": "SYMBOL",
"name": "built_in_value"
},
{
"type": "SYMBOL",
"name": "type_definition"
}
]
},
"type_definition": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "structure"

View File

@ -602,21 +602,6 @@
]
}
},
{
"type": "type_definition",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "structure",
"named": true
}
]
}
},
{
"type": "type_specification",
"named": true,
@ -677,7 +662,7 @@
"named": true
},
{
"type": "type_definition",
"type": "structure",
"named": true
}
]

File diff suppressed because it is too large Load Diff