lexical_envs/add_env_post: transition to lkt compile

This commit is contained in:
Pierre-Marie de Rodat
2024-10-14 13:17:13 +00:00
parent 9ac515cd82
commit cf4dfdfffa
4 changed files with 26 additions and 28 deletions

View File

@@ -0,0 +1,18 @@
# Check that add_env is forbidden in post-node PLE
import lexer_example
@with_lexer(foo_lexer)
grammar foo_grammar {
@main_rule main_rule <- Example("example")
}
class FooNode implements Node[FooNode] {
}
class Example: FooNode implements TokenNode {
env_spec {
handle_children()
add_env()
}
}

View File

@@ -1,2 +1,7 @@
test.py:XXX: error: add_env() must occur before processing children
Done
== test.lkt ==
test.lkt:16:9: error: add_env() must occur before processing children
16 | add_env()
| ^^^^^^^^^
lkt_compile: Done

View File

@@ -1,25 +0,0 @@
"""
Check that add_env is forbidden in post-node PLE.
"""
from langkit.diagnostics import DiagnosticError
from langkit.dsl import ASTNode
from langkit.envs import EnvSpec, add_env, handle_children
class FooNode(ASTNode):
pass
try:
class Example(FooNode):
token_node = True
env_spec = EnvSpec(
handle_children(),
add_env(),
)
except DiagnosticError:
pass
print('Done')

View File

@@ -1 +1 @@
driver: python
driver: lkt_compile