2023-08-26 19:46:39 +01:00
|
|
|
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)))
|
2023-08-26 19:46:39 +01:00
|
|
|
self.widget_token = Suppress("||")
|
2023-08-22 02:04:00 +01:00
|
|
|
self.identifier = Group(OneOrMore(Word(alphanums)))
|
2023-08-22 02:52:03 +01:00
|
|
|
self.event = Group(OneOrMore(Word(alphanums)))
|
2023-08-26 19:46:39 +01:00
|
|
|
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
|
|
|
|
)
|