Added support for @componentHeader
This commit is contained in:
parent
59b19062ff
commit
e2e0506041
|
@ -63,11 +63,11 @@ std::set<std::string> createImports(Schema *schema);
|
|||
|
||||
std::map<string, string> generateWires(Schema *schema, ostream &ostream);
|
||||
|
||||
void generateSubComponents(Schema *schema, map <string, string> &wires, ostream &buffer);
|
||||
void generateSubComponents(Schema *schema, map <string, string> &wires, ostream &buffer);
|
||||
|
||||
void generateDisplay(Schema *schema, ostream &buffer);
|
||||
void generateDisplay(Schema *schema, ostream &buffer);
|
||||
|
||||
void generateComdelFile(Schema *schema, Library &library, std::ostream &buffer) {
|
||||
void generateComdelFile(Schema *schema, Library &library, std::ostream &buffer) {
|
||||
buffer << library.getHeader() << std::endl;
|
||||
|
||||
std::set<std::string> imports = createImports(schema);
|
||||
|
@ -80,6 +80,10 @@ std::map<string, string> generateWires(Schema *schema, ostream &ostream);
|
|||
|
||||
buffer << "component System" << std::endl << "{" << std::endl;
|
||||
|
||||
if(library.getComponentHeader().has_value()) {
|
||||
buffer << library.getComponentHeader().value() << endl;
|
||||
}
|
||||
|
||||
auto wires = generateWires(schema, buffer);
|
||||
|
||||
generateSubComponents(schema, wires, buffer);
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace domain {
|
||||
|
||||
Library::Library(string name, string libraryInfo, string header, string componentDirectory,
|
||||
Library::Library(string name, string libraryInfo, string header, string componentDirectory, std::optional<std::string> componentHeader,
|
||||
vector<AddressSpace> addressSpaces, vector<Component> components, vector<Bus> buses, vector<Connection> connections, map<string, string> messages)
|
||||
: name(name), libraryInfo(libraryInfo), header(header), componentDirectory(componentDirectory), addressSpaces(addressSpaces),
|
||||
: name(name), libraryInfo(libraryInfo), header(header), componentDirectory(componentDirectory), componentHeader(componentHeader), addressSpaces(addressSpaces),
|
||||
components(components), buses(buses), connections(connections), messages(messages)
|
||||
{}
|
||||
|
||||
|
@ -20,6 +20,9 @@ std::string Library::getHeader() {
|
|||
std::string Library::getComponentDirectory() {
|
||||
return componentDirectory;
|
||||
}
|
||||
std::optional<std::string> Library::getComponentHeader() {
|
||||
return componentHeader;
|
||||
}
|
||||
|
||||
std::vector<AddressSpace> Library::getAddressSpaces() {
|
||||
return addressSpaces;
|
||||
|
|
|
@ -21,6 +21,7 @@ class Library
|
|||
std::string libraryInfo;
|
||||
std::string header;
|
||||
std::string componentDirectory;
|
||||
std::optional<std::string> componentHeader;
|
||||
|
||||
std::vector<AddressSpace> addressSpaces;
|
||||
std::vector<Component> components;
|
||||
|
@ -30,13 +31,14 @@ class Library
|
|||
std::map<std::string, std::string> messages;
|
||||
|
||||
public:
|
||||
Library(string name, string libraryInfo, string header, string componentDirectory,
|
||||
Library(string name, string libraryInfo, string header, string componentDirectory, std::optional<string> componentHeader,
|
||||
vector<AddressSpace> addressSpaces, vector<Component> components, vector<Bus> buses, vector<Connection> connection, map<string, string> messages);
|
||||
|
||||
std::string getName();
|
||||
std::string getLibraryInfo();
|
||||
std::string getHeader();
|
||||
std::string getComponentDirectory();
|
||||
std::optional<std::string> getComponentHeader();
|
||||
|
||||
std::vector<AddressSpace> getAddressSpaces();
|
||||
std::vector<Component> getComponents();
|
||||
|
|
|
@ -128,6 +128,10 @@ std::optional<Library> SchemaCreator::loadLibrary(LibraryNode node)
|
|||
name = node.name->asString();
|
||||
}
|
||||
|
||||
if(node.componentHeader.has_value()) {
|
||||
componentHeader = node.componentHeader->asString();
|
||||
}
|
||||
|
||||
if(!node.componentDirectory) {
|
||||
errors.emplace_back(node.span, "missing @componentDirectory");
|
||||
return nullopt;
|
||||
|
@ -173,7 +177,7 @@ std::optional<Library> SchemaCreator::loadLibrary(LibraryNode node)
|
|||
}
|
||||
}
|
||||
|
||||
return Library(name, libraryInfo, header, componentDirectory, addressSpaces, components, buses, connections, messages);
|
||||
return Library(name, libraryInfo, header, componentDirectory, componentHeader, addressSpaces, components, buses, connections, messages);
|
||||
}
|
||||
|
||||
std::optional<Bus> SchemaCreator::loadBus(BusNode node)
|
||||
|
|
|
@ -53,6 +53,7 @@ class SchemaCreator
|
|||
std::string libraryInfo;
|
||||
std::string header;
|
||||
std::string componentDirectory;
|
||||
std::optional<std::string> componentHeader = nullopt;
|
||||
std::vector<AddressSpace> addressSpaces;
|
||||
std::vector<Component> components;
|
||||
std::vector<Bus> buses;
|
||||
|
|
|
@ -294,6 +294,7 @@ struct LibraryNode: public AstNode
|
|||
std::optional<StringNode> libraryInfo;
|
||||
std::optional<StringNode> header;
|
||||
std::optional<StringNode> componentDirectory;
|
||||
std::optional<StringNode> componentHeader;
|
||||
|
||||
std::vector<AddressSpaceNode> addressSpaces;
|
||||
|
||||
|
|
|
@ -243,6 +243,9 @@ std::optional<LibraryNode> ComdelParser::parse()
|
|||
} else if(check(TokenType::KW_HEADER)) {
|
||||
bump();
|
||||
ASSIGN_OR_SET_ERR(library.header, parseString());
|
||||
} else if(check(TokenType::KW_COMPONENT_HEADER)) {
|
||||
bump();
|
||||
ASSIGN_OR_SET_ERR(library.componentHeader, parseString());
|
||||
} else if(check(TokenType::KW_DIRECTORY)) {
|
||||
bump();
|
||||
ASSIGN_OR_SET_ERR(library.componentDirectory, parseString());
|
||||
|
|
|
@ -72,6 +72,7 @@ enum class TokenType {
|
|||
KW_NAME,
|
||||
KW_INFO,
|
||||
KW_HEADER,
|
||||
KW_COMPONENT_HEADER,
|
||||
KW_DIRECTORY,
|
||||
KW_LIBRARY,
|
||||
KW_ADDRESS,
|
||||
|
|
|
@ -83,6 +83,7 @@ TokenTables::TokenTables() {
|
|||
add( TokenType::KW_NAME, "@name", TOKENIZABLE | KEYWORD_NAME),
|
||||
add( TokenType::KW_INFO, "@info", TOKENIZABLE | KEYWORD_NAME),
|
||||
add( TokenType::KW_HEADER, "@header", TOKENIZABLE | KEYWORD_NAME),
|
||||
add( TokenType::KW_COMPONENT_HEADER, "@componentHeader", TOKENIZABLE | KEYWORD_NAME),
|
||||
add( TokenType::KW_DIRECTORY, "@directory", TOKENIZABLE | KEYWORD_NAME),
|
||||
add( TokenType::KW_LIBRARY, "@library", TOKENIZABLE | KEYWORD_NAME),
|
||||
add( TokenType::KW_ADDRESS, "@address", TOKENIZABLE | KEYWORD_NAME),
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
@name "Jednostavni FRISC"
|
||||
@info "Ova biblioteka omogućuje kreiranje sustava s procesorom FRISC s pojednostavljenim načinom spajanja bez potrebe da se spajaju pojedine linije sabirnice."
|
||||
@directory "libraries\frisc\vjezba1"
|
||||
@header "// Version 0.0.1"
|
||||
@componentHeader " clock 100MHz;"
|
||||
|
||||
@address glavniAS(0,0xFFFFFFFF)
|
||||
@address pomocniAS(0xFFFF0000,0xFFFFFFFF)
|
||||
|
|
Loading…
Reference in New Issue