-
Notifications
You must be signed in to change notification settings - Fork 5
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
Regarding ARCHETYPE_HRID #22
Comments
I suggest this solution : archetypeHRID: archetypeHRIDRoot '.v' releaseVersion ; referenceModelEntity: rmPublisher '-' rmPackage '-' rmClass ; conceptId: IDENTIFIER ; releaseVersion: majorVersion '.' minorVersion '.' patchVersion '-' versionStatus ; namespace : LABEL ('.' LABEL)+ ; NB: This is because these three Lexer rules are fragments. Fragments should not be referenced from a parser rule. So these must become full Lexer rules and then the warnings disappear. |
I like to explain why I think my solution is better. I have changed my grammar according to this, because, as said, it makes it easier to meet the information requirements of the AOM, which is the most important module that uses the parser. The parser should comfort software, and take care of good performance. These objectives seem at first sight sometimes conflicting, but is that always the case? One can consider that the performance gain from a concise fast parser/lexer-grammar is lost in the AOM, which anyway needs to split up the items to satisfy the information-requirements. As another result, there will be less code-complexity in the AOM and more clarity in the generated parser/grammar. So my solution does not really sacrifice performance, but avoids complicated code (bugs?) |
I reset it to the original and found another solution by creating a ArchtypeHRID object which holds all properties |
It is better to have items which are needed in AOM parsing in the Parser-section instead of the Lexer. This makes the AOM more safe to write and easier to maintain. The difference between the Parser and the Lexer I am referring to is that the Parser creates classes to define the grammar, these classes are easier to query.
Take a look at chapter 5.6 in the Antlr book, there is a list on page 81/82, and I refer to the last item. On page 83 is an example which explains (kind of) this issue also.
So instead of
ARCHETYPE_HRID : ARCHETYPE_HRID_ROOT '.v' VERSION_ID ;
ARCHETYPE_REF : ARCHETYPE_HRID_ROOT '.v' INTEGER ( '.' DIGIT+ )* ;
fragment ARCHETYPE_HRID_ROOT : (NAMESPACE '::')? IDENTIFIER '-' IDENTIFIER '-' IDENTIFIER '.' LABEL ; ..................
It should become something like:
archetype_hrid: archetype_hrid_root '.v' VERSION_ID ;
archetype_hrid_root: (namespace '::')? IDENTIFIER '-' IDENTIFIER '-' IDENTIFIER '.' LABEL ;
namespace : LABEL ('.' LABEL)+ ;
(needs to be worked out further)
The text was updated successfully, but these errors were encountered: