nvda-voicemeeter/src/nvda_voicemeeter/parser.py

16 lines
617 B
Python
Raw Normal View History

from pyparsing import Group, OneOrMore, Optional, Suppress, Word, alphanums, restOfLine
2023-08-22 02:04:00 +01:00
class Parser:
def __init__(self):
self.widget = Group(OneOrMore(Word(alphanums)))
self.widget_token = Suppress("||")
2023-08-22 02:04:00 +01:00
self.identifier = Group(OneOrMore(Word(alphanums)))
self.event = Group(OneOrMore(Word(alphanums)))
self.menu_token = Suppress("::")
self.match = (
self.widget + self.widget_token + self.identifier + Optional(self.widget_token) + Optional(self.event)
| self.identifier + self.menu_token + self.event
| restOfLine
)