mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Change the way values work
Change the parsing for values to make them more reusable, in particular for when I implement extensions.
This commit is contained in:
parent
6938267952
commit
1df46b5a06
30 changed files with 707 additions and 291 deletions
|
@ -567,6 +567,19 @@ class UseLiteral(ParseNode):
|
|||
return True
|
||||
|
||||
|
||||
class UseExact(ParseNode):
|
||||
"""Matches the given identifier and sets it as a named token."""
|
||||
|
||||
def __init__(self, key: str, string: str):
|
||||
self.key = key
|
||||
self.string = string
|
||||
|
||||
def _parse(self, ctx: ParseContext):
|
||||
token = ctx.next_token()
|
||||
ctx.set_group_val(self.key, self.string, token)
|
||||
return str(token) == self.string
|
||||
|
||||
|
||||
class Keyword(ParseNode):
|
||||
"""Matches the given identifier and sets it as a named token, with the name
|
||||
being the identifier itself."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue