-
Notifications
You must be signed in to change notification settings - Fork 79
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
Ambiguity in grammar for parsing alignment attributes, string attributes #40
Comments
Three function declarations had to be removed from the original test case as #40 has yet to be resolved. ; Functions -- align ; TODO: re-enable when llir/llvm#40 is resolved. ;declare void @f.align2() align 2 ; CHECK: declare void @f.align2() align 2 ; TODO: re-enable when llir/llvm#40 is resolved. ;declare void @f.align4() align 4 ; CHECK: declare void @f.align4() align 4 ; TODO: re-enable when llir/llvm#40 is resolved. ;declare void @f.align8() align 8 ; CHECK: declare void @f.align8() align 8
Note: this is not a complete fix, but a pragmatic one, as align is more commonly used for function definitions than return attributes. Anyone well versed with LR-1 grammars, feel free to give hints on how we may resolve this in a proper way. ref: llir/grammar@71126f6. Updates #40. Updates #111.
From #111 (comment) Grammar related to Function String Attributetest cases failing likely related to Function String Attribute grammaralign attributealign used in call instruction
align used in return attribute
I don't know how to update the grammar to handle ambiguities related to If anyone knows of a clean approach to handle this. You are warmly invited to share your thoughts. We'd very much appreciate it, seeing as this annoying issue is yet to find a clean solution. Cheers, |
Do we consider ANTLR? I was thinking so many issues you opened just cannot get fixed, maybe we should swap to a more stable parser generator? Anyway, it can't be more painful. |
@dannypsnl, haha, yeah I know, there are some pains with using Textmapper. I do think however this is true for every parser generator. That being said, feel free to do a Proof of concept : ) I think every parser generator has pros and cons. So if ANTLR turns out to solve more issues than it creates, it may be worth it. However, it should be noted that this is a ton of work. So, except to put in at least 2 full time weeks before reaching feature parity. If you still feel like working on it, then definitely, go for it! Cheers, |
The grammar contains an ambiguity when parsing global variable alignment attributes. More specifically, an alignment attribute of a global variable may be interpreted either as a
GlobalAttr
or aFuncAttr
, and since the list of both global attributes and function attributes may be optionally empty, this leads to a shift/reduce ambiguity in the parser.From the ll.tm EBNF grammar:
Specifically, the end of the line is of interest
(',' Align)? Metadata=(',' MetadataAttachment)+? FuncAttrs=(',' FuncAttribute)+?
Given that there are no metadata attachments, the alignment attribute (
align 8
) of the following LLVM IR:may be either reduced to a global attribute (i.e.
Align
beforeMetadataAttachment
), or as a function attribute (i.e.FuncAttribute
afterMetadataAttachment
).The solution employed by the C++ parser is the opposite of maximum much, as it will try to reduce rather than shift when possible.
The text was updated successfully, but these errors were encountered: