Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
Révision | bf6d9d5f94387fb7fc785941e03f36c03b97c913 (tree) |
---|---|
l'heure | 2022-01-15 07:52:02 |
Auteur | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
Added a SKIPED test to parse the grammer-file into an AST
@@ -4,10 +4,12 @@ | ||
4 | 4 | import sys; sys.path.append("./../AST/") ; sys.path.append("./../../AST/") |
5 | 5 | from castle import peg # has the AST clases |
6 | 6 | |
7 | +import grammar | |
8 | + | |
7 | 9 | def parse(txt, rule, |
8 | 10 | print_tree_debug=False, |
9 | 11 | visitor_debug=False): |
10 | - parser = arpeggio.ParserPython(rule) | |
12 | + parser = arpeggio.ParserPython(rule, grammar.comment) | |
11 | 13 | pt = parser.parse(txt) |
12 | 14 | if print_tree_debug: |
13 | 15 | print('\n'+pt.tree_str()) |
@@ -0,0 +1,22 @@ | ||
1 | +import pytest | |
2 | +import logging; logger = logging.getLogger(__name__) | |
3 | +from pathlib import Path | |
4 | +import os | |
5 | +import grammar | |
6 | +from castle import peg # has the AST classes | |
7 | + | |
8 | +from . import parse, assert_ID | |
9 | + | |
10 | +def parse_file(filename, dir=Path('..')): | |
11 | + path_to_current_test = Path(os.path.realpath(__file__)) | |
12 | + path_to_current_dir = path_to_current_test.parent | |
13 | + with (path_to_current_dir / dir / filename).open() as f: | |
14 | + txt = f.read() | |
15 | + ast = parse(txt, grammar.peg_grammar, print_tree_debug=False) | |
16 | + | |
17 | + return tree | |
18 | + | |
19 | +@pytest.mark.skip(reason="NOT all visitors are done, like ``peg_grammar``") | |
20 | +def test_grammar(): | |
21 | + parse_file("grammar.peg") | |
22 | + ... # XXX |