weixin_39831001
weixin_39831001
2020-12-30 04:34

Multi statement line interpreted as label

 
DoEvents: blah

"Line label 'Doevents' is not used"

该提问来源于开源项目:rubberduck-vba/Rubberduck

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

8条回答

  • weixin_39629093 weixin_39629093 4月前

    Are you sure the VBE itself isn't parsing it as a line label? Try indenting it...

    点赞 评论 复制链接分享
  • weixin_39629093 weixin_39629093 4月前

    Ok, I admittedly replied before testing it myself - apparently the VBE parses reserved keywords as such, regardless. The grammar alone can't determine if a line label is a line label, we need to hard-code the illegal identifiers there.

    点赞 评论 复制链接分享
  • weixin_39831001 weixin_39831001 4月前

    Or,

    
    12345   DoEvents: blah
    

    If that isn't too distasteful :-)

    点赞 评论 复制链接分享
  • weixin_40007016 weixin_40007016 4月前

    Hey it would be really nice if you could format the code you put into comments and issues as code by enclosing it with a "code fence" (```). That tremendously helps readability when quickly skimming the post. Thanks!

    点赞 评论 复制链接分享
  • weixin_39629093 weixin_39629093 4月前

    The grammar already defines a KEYWORD token; we "just" need to get the grammar rule for statementLabelDefinition to refuse to match a KEYWORD token.

    This MsgBox doesn't pop up:

    vb
    Sub Test()
        End: MsgBox "Nope"
    End Sub
    

    So, if our KEYWORD list is accurate, updating statementLabelDefinition should do the trick.

    点赞 评论 复制链接分享
  • weixin_39629093 weixin_39629093 4月前

    linking #3175

    点赞 评论 复制链接分享
  • weixin_39831001 weixin_39831001 4月前

    Thanks for the reminder Vogel, it's been a while since I posted here. 12345 DoEvents: blah Yes, it works. On my keyboard I have to press backquote twice (because it's a dead key for grave accents) and then I get two of them but it works with two.

    点赞 评论 复制链接分享
  • weixin_39629093 weixin_39629093 4月前

    allow me to thank you back for the invaluable quick post-release feedback! The fix for this specific issue is under way & looking good, turns out a good dozen of keywords were being parsed as line labels. You've just contributed to make Rubberduck's parser one step closer to perfection!

    点赞 评论 复制链接分享

相关推荐