Make mark verification occur in expression compilation
This commit is contained in:
parent
917af40c60
commit
fbfb4ebf58
|
@ -200,12 +200,19 @@ class Expression:
|
||||||
self.code = code
|
self.code = code
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def compile(self, input: str) -> "Expression":
|
def compile(self, input: str, mark: bool = False) -> "Expression":
|
||||||
"""Compile a match expression.
|
"""Compile a match expression.
|
||||||
|
|
||||||
:param input: The input expression - one line.
|
:param input: The input expression - one line.
|
||||||
"""
|
"""
|
||||||
astexpr = expression(Scanner(input))
|
astexpr = expression(Scanner(input))
|
||||||
|
|
||||||
|
if mark:
|
||||||
|
for node in ast.walk(astexpr):
|
||||||
|
#if the node is an identifier, i.e. a mark name
|
||||||
|
if isinstance(node, ast.Name):
|
||||||
|
MARK_GEN.verify_mark(node.id[len(IDENT_PREFIX):])
|
||||||
|
|
||||||
code: types.CodeType = compile(
|
code: types.CodeType = compile(
|
||||||
astexpr,
|
astexpr,
|
||||||
filename="<pytest match expression>",
|
filename="<pytest match expression>",
|
||||||
|
|
Loading…
Reference in New Issue