Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
Revisión | 70b8c4ed931b653425b9b872a1e85c201972b694 (tree) |
---|---|
Tiempo | 2022-02-12 03:06:30 |
Autor | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
Merged
@@ -37,3 +37,8 @@ | ||
37 | 37 | done |
38 | 38 | XXX: |
39 | 39 | grep XXX `find . -type f -name \*.py` |
40 | + | |
41 | +clean: clean_caches | |
42 | +clean_caches: | |
43 | + find . -type d -name __pycache__ -print0 | xargs -0 rm -r | |
44 | + find . -type d -name .pytest_cache -print0 | xargs -0 rm -r |
@@ -0,0 +1,21 @@ | ||
1 | +import pytest | |
2 | + | |
3 | +from jinja2 import Template | |
4 | + | |
5 | +from castle.ast import peg # To build the ATS | |
6 | + | |
7 | + | |
8 | + | |
9 | +def __test_simple_rule(): | |
10 | + expected = """def rule_crossref():\treturn ID""" | |
11 | + castle = """rule_crossref <- ID ;""" | |
12 | + | |
13 | + ## Build the AST -- Ignoring the parse_tree | |
14 | + id_rn = peg.ID(name="rule_crossref") | |
15 | + id_xr = peg.ID(name="ID") | |
16 | + | |
17 | + | |
18 | +## expressions = peg.Sequence(value=id_xr | |
19 | +## rule = peg.Rule(name=id_rn, expr=expressions) | |
20 | + | |
21 | +## Template("""def {{rule.name}}()\treturn{rule.expro |