dabeaz / sly

Sly Lex Yacc
Other
816 stars 107 forks source link

what does "@_" mean #77

Closed wqh17101 closed 2 years ago

wqh17101 commented 3 years ago

such as @_('expr') i don`t know which decorator it used

hadware commented 3 years ago

It's a "contextual" decorator whose variable name is just _. It's defined here : https://github.com/dabeaz/sly/blob/f8fcbb080c4bc4ff14bd30876386edd63d8362cb/sly/yacc.py#L1815

wqh17101 commented 3 years ago

Yeah @hadware image I found a red underscore there in pycharm. Although the program works well, i wonder is there anything to remove the red underscore,such as some settings or other alias instead of _

jpsnyder commented 2 years ago

@wqh17101 In PyCharm you can add the following to the top of the Lexer and Parser classes to have it ignore those warnings.

# noinspection PyUnresolvedReferences
class MyLexer(sly.Lexer):
wqh17101 commented 2 years ago

@jpsnyder right