Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
Révision | f751c988d68b0f3d5bda13cb4e08c76b3564613a (tree) |
---|---|
l'heure | 2021-12-11 04:39:26 |
Auteur | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
Rewriten grammar.py ::test_4_rule works again
@@ -1,19 +1,19 @@ | ||
1 | 1 | import pytest |
2 | -from grammar import * | |
2 | +import grammar | |
3 | 3 | |
4 | 4 | import arpeggio |
5 | 5 | RE, S = arpeggio.RegExMatch, arpeggio.StrMatch # shortcut |
6 | 6 | |
7 | 7 | def parse_rule(txt, pattern=None): |
8 | - parser = ParserPython(rule, comment) | |
8 | + parser = arpeggio.ParserPython(grammar.rule) | |
9 | 9 | tree = parser.parse(txt) |
10 | - #print(f'\nTREE\n{tree.tree_str()}') | |
10 | + print(f'\nTREE\n{tree.tree_str()}') | |
11 | 11 | |
12 | 12 | assert tree.position_end == len(txt) , f"Not parsed whole input; Only: >>{txt[tree.position: tree.position_end]}<<; Not: >>{txt[tree.position_end:]}<<." |
13 | 13 | assert len(tree) == 4, "A rule should have length=4; ..." |
14 | 14 | assert tree[0].rule_name == "rule_name", " at [0], the name of the rule" |
15 | 15 | assert str(tree[1]) == '<-', " then a arrow" |
16 | - assert tree[2].rule_name == "ordered_choice", " at [2] an ordered_choice" | |
16 | + assert tree[2].rule_name == "expressions", " at [2] an ordered_choice" | |
17 | 17 | assert str(tree[3]) == ';', " and the the closing ':'" |
18 | 18 | |
19 | 19 | return tree |