Removed @wire from schema

This commit is contained in:
Borna Rajković 2022-05-07 18:28:31 +02:00
parent 5ccd9b2fa4
commit 9ff6633777
5 changed files with 8 additions and 87 deletions

View File

@ -798,11 +798,6 @@ Schema* SchemaCreator::loadSchema(SchemaNode node, Library &library)
} }
} }
if(!conn.wire) {
errors.emplace_back(conn.span, "missing @wire");
continue;
}
std::vector<InstanceAttribute> attributes; std::vector<InstanceAttribute> attributes;
for(auto& attr: conn.attributes) { for(auto& attr: conn.attributes) {
if(connection->hasAttribute(attr.name.value)) { if(connection->hasAttribute(attr.name.value)) {

View File

@ -302,13 +302,6 @@ struct LibraryNode: public AstNode
}; };
// SCHEMA models // SCHEMA models
struct WireInstanceNode: public AstNode
{
IdentifierNode name;
std::optional<CountNode> position;
std::optional<DisplayNode> display;
};
struct InstanceAttributeNode: public AstNode struct InstanceAttributeNode: public AstNode
{ {
IdentifierNode name; IdentifierNode name;
@ -338,7 +331,6 @@ struct ConnectionInstanceNode: public AstNode
std::optional<ConnectionComponentInstance> second; std::optional<ConnectionComponentInstance> second;
IdentifierNode bus; IdentifierNode bus;
std::optional<IdentifierNode> wire;
std::vector<InstanceAttributeNode> attributes; std::vector<InstanceAttributeNode> attributes;
}; };
@ -349,7 +341,6 @@ struct SchemaNode: public AstNode
std::optional<StringNode> source; std::optional<StringNode> source;
std::vector<InstanceNode> instances; std::vector<InstanceNode> instances;
std::vector<WireInstanceNode> wires;
std::vector<ConnectionInstanceNode> connections; std::vector<ConnectionInstanceNode> connections;
std::optional<LibraryNode> library; std::optional<LibraryNode> library;

View File

@ -1170,8 +1170,6 @@ std::optional<SchemaNode> ComdelParser::parseSchema() {
PResult<poly<AstNode>> err; PResult<poly<AstNode>> err;
if(check(TokenType::KW_INSTANCE)){ if(check(TokenType::KW_INSTANCE)){
APPEND_OR_SET_ERR(schema.instances, parseInstance()); APPEND_OR_SET_ERR(schema.instances, parseInstance());
} else if(check(TokenType::KW_WIRE)) {
APPEND_OR_SET_ERR(schema.wires, parseWireInstance());
} else if(check(TokenType::KW_CONNECTION)) { } else if(check(TokenType::KW_CONNECTION)) {
APPEND_OR_SET_ERR(schema.connections, parseConnectionInstance()); APPEND_OR_SET_ERR(schema.connections, parseConnectionInstance());
} else { } else {
@ -1181,6 +1179,10 @@ std::optional<SchemaNode> ComdelParser::parseSchema() {
if(!err.has_value()) { if(!err.has_value()) {
errors.push_back(err.error()); errors.push_back(err.error());
skipUntilNextKeyword(); skipUntilNextKeyword();
if(check(TokenType::END_OF_FILE)) {
errors.emplace_back(current().span, "expected `}` reached EOF");
return std::nullopt;
}
} }
} }
if(!check(TokenType::RBRACE)) { if(!check(TokenType::RBRACE)) {
@ -1199,38 +1201,6 @@ std::optional<SchemaNode> ComdelParser::parseSchema() {
return spanner(schema); return spanner(schema);
} }
PResult<WireInstanceNode> ComdelParser::parseWireInstance() {
auto spanner = getSpanner();
WireInstanceNode wireInstance;
RETURN_IF_NOT_TOKEN(TokenType::KW_WIRE);
ASSIGN_OR_RETURN_IF_ERR(wireInstance.name, parseIdentifier());
RETURN_IF_NOT_TOKEN(TokenType::LBRACE);
while(!check(TokenType::RBRACE)) {
PResult<poly<AstNode>> err;
if(check(TokenType::KW_POSITION)) {
ASSIGN_OR_SET_ERR(wireInstance.position, parsePosition());
} else if(check(TokenType::KW_DISPLAY)) {
ASSIGN_OR_SET_ERR(wireInstance.display, parseDisplay());
} else {
err = unexpected();
}
if(!err.has_value()) {
errors.push_back(err.error());
skipUntilNextKeyword();
if(check(TokenType::END_OF_FILE)) {
return PError({Span(spanner.lo), "Reached EOF"});
}
}
}
RETURN_IF_NOT_TOKEN(TokenType::RBRACE);
return spanner(wireInstance);
}
/**************************************************************************** /****************************************************************************
* *
@ -1333,13 +1303,11 @@ PResult<ConnectionInstanceNode> ComdelParser::parseConnectionInstance() {
while(!check(TokenType::RBRACE)) { while(!check(TokenType::RBRACE)) {
PResult<poly<AstNode>> err; PResult<poly<AstNode>> err;
if(check(TokenType::KW_WIRE)) { if(check(TokenType::KW_ATTRIBUTE)) {
bump();
ASSIGN_OR_SET_ERR(connection.wire, parseIdentifier());
} else if(check(TokenType::KW_ATTRIBUTE)) {
APPEND_OR_SET_ERR(connection.attributes, parseInstanceAttribute()); APPEND_OR_SET_ERR(connection.attributes, parseInstanceAttribute());
} else { } else {
err = unexpected(); err = unexpected();
bump();
} }
if(!err.has_value()) { if(!err.has_value()) {
errors.push_back(err.error()); errors.push_back(err.error());

View File

@ -88,7 +88,6 @@ private:
PResult<ValueNode> parseValue(); PResult<ValueNode> parseValue();
PResult<WireInstanceNode> parseWireInstance();
PResult<CountNode> parsePosition(); PResult<CountNode> parsePosition();
PResult<InstanceNode> parseInstance(); PResult<InstanceNode> parseInstance();
PResult<InstanceAttributeNode> parseInstanceAttribute(); PResult<InstanceAttributeNode> parseInstanceAttribute();

View File

@ -17,39 +17,7 @@
@size 100 @size 100
} }
@wire wire_001 { @connection (proc.glavniPin, bus) {}
@position (50, 116)
@display {
/*
line {
color: blue;
points: 100;
}*/
line {
x1: 0; y1: 0; x2: 0; y2: 84;
}
}
}
@wire wire_002 { @connection (mem.glavniPin, bus) {}
@position (50, 220)
@display {
/*
line {
color: blue;
points: 100;
}*/
line {
x1: 0; y1: 0; x2: 0; y2: 14;
}
}
}
@connection (proc.glavniPin, bus) {
@wire wire_001
}
@connection (mem.glavniPin, bus) {
@wire wire_002
}
} }