Skip to content

Feature: Support hierarchical grammar definitions #2300

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

Open
lmapii opened this issue Jun 2, 2025 · 0 comments
Open

Feature: Support hierarchical grammar definitions #2300

lmapii opened this issue Jun 2, 2025 · 0 comments

Comments

@lmapii
Copy link

lmapii commented Jun 2, 2025

This is definitely just a nice-to-have issue, but it would make declaring strict grammars less redundant.

Description

I'd like to have a base grammar defining the fundamental structure of my elements, e.g., which fields are required for all "Requirements", all "Specifications", etc ... This is useful in complex projects that have several levels of requirement and specification documents, e.g., product requirements, system requirements, software requirements, etc.

Let's say req_base.sgra defines the minimal language elements for all requirements documents, then each requirements document grammar type, e.g., req_sw.sgra for software requirements, includes req_base.sgra and can extend the elements in req_sw.sgra, e.g., for the required trace types in software requirement documents.

With this, I don't have to redefine "Requirement" types, e.g., that a UUID is required for each such element, in each and every document grammar.

Problem

Currently (strictdoc 0.8.0), using IMPORT_FROM_FILE doesn't seem to work in grammar files even though no error is generated. If I try the above, then I get the Semantic error: Invalid node type: REQUIREMENT. in the document including req_base.sgra since no such element type is defined (at the moment all I'm doing in my req_sw.sgra is including req_base.sgra).

Without this feature, I have to re-declare my elements in each and every document's grammar, which is repetitive, error prone, and might become inconsistent.

Solution

I'm not sure about the underlying implementation - but subsequent inclusion could be used to extend grammars defined in other files. Conflicting definitions could be forbidden to simplify things in the implementation.

Additional Information

N/A.

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