Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
Révision | dd3f259f732d4425b68cd43f1a987d51bb6f7e60 (tree) |
---|---|
l'heure | 2021-12-23 08:21:18 |
Auteur | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
Added ID (rule_name & rule_crossref) to AST/vistor
@@ -0,0 +1,23 @@ | ||
1 | +import pytest | |
2 | + | |
3 | +import grammar | |
4 | + | |
5 | +import sys; sys.path.append("./../AST/") ; sys.path.append("./../../AST/") | |
6 | +from castle import peg # has the AST clases | |
7 | + | |
8 | +from . import parse | |
9 | + | |
10 | +def test_rule_name(): | |
11 | + """The name of a rule is an ID""" | |
12 | + txt="aName" | |
13 | + ast = parse(txt, grammar.rule_name) | |
14 | + assert isinstance(ast, peg.ID), "It should be an ID" | |
15 | + assert ast.name == txt | |
16 | + | |
17 | +def test_rule_crossref(): | |
18 | + """The rule's expressions can also refer an ID""" | |
19 | + txt="aName" | |
20 | + ast = parse(txt, grammar.rule_crossref) | |
21 | + assert isinstance(ast, peg.ID), "It should be an ID" | |
22 | + assert ast.name == txt | |
23 | + |