Beakerboy / grammars-v4

Grammars written for ANTLR v4; expectation that the grammars are free of actions.
MIT License
0 stars 0 forks source link

[BUG]? Class description attribute #45

Open SSlinky opened 3 months ago

SSlinky commented 3 months ago

Not sure if this one is actually a bug because internet information says that it's supposed to add a class description to the object browser, however I've not been able to get that working.

I "fixed" by adding ATTRIBUTE WS? VB_DESCRIPTION WS? EQ WS? STRINGLITERAL to the classAttr rule.

Given that any other attribute isn't "invalid" per se, they are simply ignored, you may wish to add an ignored type of attribute. Mine currently looks like this. Note that I've also peeled off VB_NAME to make it easier to find in code. Not strictly something a parser may be concerned with.

classModuleHeader: (endOfLine+ (classAttr | nameAttr | ignoredAttr))* WS?;

// VBA Library Projects are allowed to have GoobalNamespace and creatable as true.
classAttr
    : ATTRIBUTE WS? VB_DESCRIPTION WS? EQ WS? STRINGLITERAL
    | ATTRIBUTE WS? VB_GLOBALNAMESPACE WS? EQ WS? booleanLiteralIdentifier
    | ATTRIBUTE WS? VB_CREATABLE WS? EQ WS? booleanLiteralIdentifier
    | ATTRIBUTE WS? VB_PREDECLAREDID WS? EQ WS? booleanLiteralIdentifier
    | ATTRIBUTE WS? VB_EXPOSED WS? EQ WS? booleanLiteralIdentifier
    | ATTRIBUTE WS? VB_CUSTOMIZABLE WS? EQ WS? booleanLiteralIdentifier
    ;

ignoredAttr
    : ATTRIBUTE WS? ambiguousIdentifier WS? EQ WS? expression
    ;

nameAttr
    : ATTRIBUTE WS? VB_NAME WS? EQ WS? STRINGLITERAL
    ;
Beakerboy commented 3 months ago

Thanks. I’ll look at this later this week. Feel free to submit pull requests for any of this. Ideally include a test that fails under the previous code but passes with the patch.