2017-02-23 15:10:58 +01:00
|
|
|
"""
|
|
|
|
|
Test the handling of negative indexes in the Python binding of AST nodes child
|
|
|
|
|
getters.
|
|
|
|
|
"""
|
|
|
|
|
|
2017-04-25 14:19:50 +02:00
|
|
|
from __future__ import absolute_import, division, print_function
|
2017-02-24 10:25:54 +01:00
|
|
|
|
2018-01-26 14:59:51 +01:00
|
|
|
from langkit.dsl import ASTNode
|
2018-01-26 11:30:18 +01:00
|
|
|
from langkit.parsers import Grammar, List
|
2017-02-23 15:10:58 +01:00
|
|
|
|
|
|
|
|
from lexer_example import Token
|
|
|
|
|
from utils import build_and_run
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FooNode(ASTNode):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Name(FooNode):
|
2018-01-26 14:59:51 +01:00
|
|
|
token_node = True
|
2017-02-23 15:10:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
foo_grammar = Grammar('main_rule')
|
|
|
|
|
foo_grammar.add_rules(
|
|
|
|
|
main_rule=List(foo_grammar.name),
|
2018-01-26 11:30:18 +01:00
|
|
|
name=Name(Token.Identifier),
|
2017-02-23 15:10:58 +01:00
|
|
|
)
|
|
|
|
|
build_and_run(foo_grammar, 'main.py')
|
2017-02-24 10:25:54 +01:00
|
|
|
print('Done')
|