Binding syntax changes

This commit is contained in:
Rezmason
2022-04-30 14:40:07 -07:00
parent 33497270a8
commit dfef272246
9 changed files with 80 additions and 79 deletions

View File

@@ -116,7 +116,7 @@ const getTypeData = (type, attributes, otherStructLayouts) => {
const parseAttributes = (str) => {
const attributes = {};
for (const attr of str.split(",").filter((attr) => attr.length > 0)) {
const match = attr.match(/(\w+)(\((.*)\))?/); // foo(bar)
const match = attr.match(/@(\w+)(\((.*)\))?/); // @foo(bar)
const [_, identifier, __, value] = match;
attributes[identifier] = value;
}
@@ -131,7 +131,8 @@ const parseStructLayout = (identifier, body, structLayouts) => {
.split(";")
.filter((s) => s.length > 0);
for (const line of lines) {
const fieldMatch = line.match(/(\[\[(.*?)\]\])? ?(\w+) ?: ?(\[\[(.*?)\]\])? ?(.*)/); // [[...]] foo : [[...]] bar;
console.log(line);
const fieldMatch = line.match(/(\[\[(.*?)\]\])? ?(\w+) ?: ?(\[\[(.*?)\]\])? ?(.*)/); // @a(...) @b(...) foo : @c(...) @d(...) bar;
const [_, __, leftAttributes, identifier, ___, rightAttributes, type] = fieldMatch;
const typeData = getTypeData(type, parseAttributes(rightAttributes ?? ""), structLayouts);