Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
Revision | ecebad1e4f0787a4d5dff6b088de54bb282bcc8f (tree) |
---|---|
Zeit | 2022-04-14 05:53:37 |
Autor | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
Improved Design/Peg.puml: Oke but upside-down
@@ -1,81 +1,140 @@ | ||
1 | 1 | @startuml |
2 | + | |
2 | 3 | abstract AST_BASE { |
3 | 4 | _parse_tree |
4 | - start() | |
5 | - end() | |
5 | + position() | |
6 | + position_end() | |
7 | + serialize() | |
6 | 8 | } |
7 | 9 | |
10 | +class ID { | |
11 | + name | |
12 | + validate_or_raise() | |
13 | +} | |
14 | + | |
15 | +ID =|> AST_BASE | |
16 | + | |
8 | 17 | package Peg #0077ff { |
9 | 18 | |
10 | 19 | abstract PEG |
11 | -AST_BASE <|== PEG | |
20 | +PEG ==|> AST_BASE | |
12 | 21 | |
13 | -PEG <|== NonTerminal | |
14 | -PEG <|== Terminal | |
15 | -PEG <|== Setting | |
16 | -PEG <|..... Markers | |
17 | -Markers <|== EOF | |
18 | -annotation Markers | |
19 | -annotation EOF | |
22 | +package MixIns #Gray { | |
20 | 23 | |
24 | + class MixIn_value_attribute<MixIn> { | |
25 | + _value | |
26 | + value() | |
27 | + } | |
28 | + | |
29 | + class MixIn_expr_attribute<MixIn> { | |
30 | + _expr | |
31 | + expr() | |
32 | + } | |
33 | + | |
34 | + class MixIn_children_tuple<MixIn> { | |
35 | + _children :Tuple | |
36 | + __len__() | |
37 | + __getitem__() | |
38 | + __iter__() | |
39 | + } | |
40 | +} | |
21 | 41 | |
22 | 42 | |
23 | 43 | abstract Terminal |
24 | -Terminal <|== StrTerm | |
25 | -Terminal <|== RexExpTerm | |
44 | +Terminal ==|> PEG | |
45 | +Terminal ---|> MixIn_value_attribute | |
46 | +StrTerm ==|> Terminal | |
47 | +RexExpTerm ==|> Terminal | |
48 | +Number ==|> Terminal | |
49 | + | |
50 | +abstract Markers #ORANGE | |
51 | +Markers ==|> PEG | |
52 | +annotation EOF #ORANGE | |
53 | +EOF ==|> Markers | |
26 | 54 | |
27 | 55 | abstract NonTerminal |
28 | -NonTerminal <|== Grammar | |
29 | -NonTerminal <|== Rule | |
30 | -NonTerminal <|== Expression | |
31 | - | |
32 | -class Grammar { | |
33 | - rules | |
34 | - settings | |
35 | -} | |
36 | -Grammar --> "*" Rule : rules | |
37 | -Grammar --> "*" Setting | |
38 | - | |
39 | -class Rule { | |
40 | - name :ID | |
41 | - peg_expression | |
42 | -} | |
43 | -Rule -> "*" Expression | |
56 | +NonTerminal ==|> PEG | |
57 | +abstract Expression | |
58 | +Expression ==|> NonTerminal | |
44 | 59 | |
45 | 60 | class Setting { |
46 | 61 | name : ID |
47 | - value : ... | |
62 | + value | |
48 | 63 | } |
64 | +Setting ==|> PEG | |
65 | +Setting ---> ID | |
49 | 66 | |
50 | -abstract Expression { | |
51 | - subEexpression Or Terminal | |
67 | +class Rule { | |
68 | + name :ID | |
69 | + expr :[] Expression | |
52 | 70 | } |
53 | -Expression --> Terminal | |
54 | -Expression --> Expression | |
71 | +Rule ==|> NonTerminal | |
72 | +Rule ---> ID | |
73 | +Rule ---> Expression | |
74 | + | |
75 | +interface Rules | |
76 | +Rules ==|> PEG | |
77 | +Rules ---|> MixIn_children_tuple | |
78 | + | |
79 | +ParseRules ==|> Rules | |
80 | +Settings ==|> Rules | |
55 | 81 | |
56 | 82 | |
57 | -Expression <|== ManyExpression | |
58 | -Expression <|== Group | |
59 | -Expression <|== Sequence | |
60 | -Expression <|== OrderedChoice | |
61 | -Expression <|== Predicate | |
62 | - | |
63 | -abstract ManyExpression | |
64 | -abstract Predicate | |
83 | +class Grammar { | |
84 | + +all_rules :Rules | |
85 | + -parse_rules :ParseRules | |
86 | + -settings :Settings | |
87 | +} | |
88 | +Grammar ==|> NonTerminal | |
65 | 89 | |
66 | -ManyExpression <== Optional | |
67 | -ManyExpression <== OneOrMore | |
68 | -ManyExpression <== ZeroOrMore | |
69 | 90 | |
70 | -Predicate <== AndPredicate | |
71 | -Predicate <== NotPredicate | |
91 | +abstract Group | |
92 | +Group ==|> Expression | |
93 | +UnorderedGroup ==|> Group | |
94 | +UnorderedGroup ---|> MixIn_expr_attribute | |
95 | +abstract Quantity | |
96 | +Quantity ==|> Group | |
97 | +Quantity ---|> MixIn_expr_attribute | |
72 | 98 | |
99 | +Sequence ==|> Expression | |
100 | +Sequence ---|> MixIn_children_tuple | |
101 | + | |
102 | +OrderedChoice ==|> Expression | |
103 | +OrderedChoice ---|> MixIn_children_tuple | |
104 | + | |
105 | +'======================== | |
106 | +class Optional << (?, #0077ff) >> | |
107 | +Optional ==|> Quantity | |
108 | +class ZeroOrMore << (*, #0077ff) >> | |
109 | +ZeroOrMore ==|> Quantity | |
110 | +class OneOrMore << (+, #0077ff) >> | |
111 | +OneOrMore ==|> Quantity | |
112 | + | |
113 | +abstract Predicate | |
114 | +Predicate ==|> Expression | |
115 | +Predicate ---|> MixIn_expr_attribute | |
73 | 116 | class AndPredicate << (&, #0077ff) notconsuming >> |
117 | +AndPredicate ==|> Predicate | |
74 | 118 | class NotPredicate << (! ,#0077ff) not consuming >> |
119 | +NotPredicate ==|> Predicate | |
75 | 120 | |
76 | -class Optional << (?, #0077ff) >> | |
77 | -class OneOrMore << (+, #0077ff) >> | |
78 | -class ZeroOrMore << (*, #0077ff) >> | |
121 | + | |
122 | + | |
123 | + | |
79 | 124 | |
80 | 125 | } |
81 | 126 | @enduml |
127 | + | |
128 | + | |
129 | + | |
130 | + | |
131 | + | |
132 | + | |
133 | + | |
134 | + | |
135 | + | |
136 | + | |
137 | + | |
138 | + | |
139 | + | |
140 | + |
@@ -1,6 +1,6 @@ | ||
1 | 1 | default: all |
2 | 2 | |
3 | -all: demo test XXX missing | |
3 | +all: demo test pyanalyse XXX missing | |
4 | 4 | |
5 | 5 | missing: missing_visitor missing_serialization |
6 | 6 |
@@ -42,3 +42,18 @@ | ||
42 | 42 | clean_caches: |
43 | 43 | find . -type d -name __pycache__ -print0 | xargs -0 rm -r |
44 | 44 | find . -type d -name .pytest_cache -print0 | xargs -0 rm -r |
45 | + | |
46 | + | |
47 | +PYREVERSE_DIR=pyreversed | |
48 | +PYREVERSE_FORMAT=svg | |
49 | +PYREVERSE_OPTIONS=-kAmy | |
50 | +PYREVERSE_PRJS= castle.readers castle.ast castle.writers castle | |
51 | + | |
52 | +pyanalyse: ${PYREVERSE_DIR} | |
53 | + for P in ${PYREVERSE_PRJS}; do \ | |
54 | + echo "PYANALYSE::" $$P "...";\ | |
55 | + pyreverse -d ${PYREVERSE_DIR} -o ${PYREVERSE_FORMAT} ${PYREVERSE_OPTIONS} -p $$P --colorized --max-color-depth=42 -my $$P ;\ | |
56 | + echo ".. done. Result-files:" ;\ | |
57 | + ls -l ${PYREVERSE_DIR}/*$${P}.${PYREVERSE_FORMAT} ;\ | |
58 | + echo;\ | |
59 | + done |
@@ -126,7 +126,6 @@ | ||
126 | 126 | """An expression with Quantification; like optional, or repetition. The subclasses defines which Quantification""" |
127 | 127 | |
128 | 128 | |
129 | -#class Sequence(MixIn_value_attribute, Expression): | |
130 | 129 | class Sequence(MixIn_children_tuple, Expression): |
131 | 130 | """A sequence of expressions; can be of length=1""" |
132 | 131 | # __init__ (see MixIn) sets self._children; assuming it is a list |