Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schema: complete validation #9

Open
kristoff-it opened this issue Feb 22, 2024 · 0 comments
Open

schema: complete validation #9

kristoff-it opened this issue Feb 22, 2024 · 0 comments

Comments

@kristoff-it
Copy link
Owner

In the construction of a Schema struct, we currently check for:

  • Duplicate tag literal definitions
  • Usage of unknown tag literals
  • Duplicate struct definitions
  • Duplicate struct field
  • Usage of unknown struct names
  • Duplicate mentions of the same Struct inside of a struct union expression

What's missing:

  • Recognizing types of infinite size (ie self-references outside of a map or array container)
  • Recognizing definitions impossible to reach from the root expression

Note that the presence of any automatically colors everything.

How to get started

Here we perform the aforementioned analysis:

ziggy/src/schema/Schema.zig

Lines 168 to 176 in 4905290

log.debug("beginning analysis", .{});
try schema.analyzeRule(gpa, schema.root, nodes, code, diagnostic);
log.debug("root_rule analized", .{});
for (schema.structs.keys(), schema.structs.values()) |s_name, s| {
for (s.fields.keys(), s.fields.values()) |f_name, f| {
log.debug("analyzeRule '{s}.{s}'", .{ s_name, f_name });
try schema.analyzeRule(gpa, f.rule, nodes, code, diagnostic);
}
}

Below those lines it would make sense to call a new function that performs the remaining checks.
It might make sense to add a field or two to the existing types (eg StructRule, Rule).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant