-
Notifications
You must be signed in to change notification settings - Fork 41
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
Parse automatic tags. #22
Conversation
During the parse phase when the grammar is generated, if the AUTOMATIC TAGS keyword is declared, a callback is added to parse of constructed types. This callback adds sequential tags to the elements of the constructed type (unless a tag exists, as per the spec). The callback is not added when the module tag default is IMPLICIT or EXPLICIT. During creation of the semantic model, if the default tag type is AUTOMATIC, the tagged element is tagged IMPLICIT unless it is a CHOICE type or resolves to one. Minor bugfix: if default tag mode is IMPLICIT, CHOICEs must still be tagged EXPLICIT. Resolves #20
# If there are tags then auto-tagging does not apply | ||
components = t.asList()[0].elements[1] | ||
for component in components: | ||
if component.ty == "ComponentType": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use single quotes for strings here and throughout? Thanks!
This is really cool, thanks! So the enumeration of automatic tags is always local to a constructed type? That makes the problem much easier -- I thought it was something that spanned the entire module. It makes more sense to me to solve this in sema -- from my cursory review it looks like the explicit building of a tagged-type parse tree in |
Hey Kim, I agree that the current approach seems a little fragile and hackish, Auto tags restart from 0 in the current constructed type, they are not James On 09/21/2015 01:46 AM, Kim Gräsman wrote:
|
I'm not as close to this problem as you are, so I could be overlooking something, but it seems to me the tag count is simple -- a constructed type already knows its components, and it should be trivial to assign an index to each of them. The challenge, however, is to find the tag implicity (I think I've made this word up, so I hope it carries the right connotations :-)) from within a stand-alone SemaNode. I think this could be made to work by making _create_sema_node part of SemaNode itself, and then feeding the default implicity from the module through to all other nodes, and then implement a variant of resolve_tag_implicity on SemaNode instead of on module. I haven't thought this all the way through, but it might be a way forward. |
The only thing to bear in mind is that the effect of the automatic tag is dependent on the other components of a constructed type - if any other components are tagged then the automatic tag has no effect on any components in that type. I'll have a go at doing something in SemaNode. |
I think I see what you're saying...
Also, if you can, please commit other cleanups separately from the SemaNode experiment, because if it gets too messy, I think we can fall back to handling it in the parser. Thanks for working on this! |
This should be closed in favor of the |
Abandoning, this was solved in Sema in PR #29 |
During the parse phase when the grammar is generated, if the
AUTOMATIC TAGS keyword is declared, a callback is added to parse
of constructed types. This callback adds sequential tags to the
elements of the constructed type (unless a tag exists, as per the
spec). The callback is not added when the module tag default is
IMPLICIT or EXPLICIT.
During creation of the semantic model, if the default tag type is
AUTOMATIC, the tagged element is tagged IMPLICIT unless it is a
CHOICE type or resolves to one.
Minor bugfix: if default tag mode is IMPLICIT, CHOICEs must still
be tagged EXPLICIT.
Resolves #20