Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
Revision | 9d8882fe02d41d135048ea7fda74ae663512296f (tree) |
---|---|
Time | 2022-01-22 23:32:41 |
Author | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
Stored Ideas/TypeHintedPEG/
@@ -0,0 +1,40 @@ | ||
1 | +.. (C) ALbert Mietus, 2022, Part of CCastel(2). | |
2 | + | |
3 | +Type-Hinted PEGs (or other grammar) | |
4 | +=================================== | |
5 | + | |
6 | +The transitional (PEG-)syntax is like: | |
7 | + | |
8 | +.. code-block:: peg | |
9 | + | |
10 | + single_expr <- ( rule_crossref | |
11 | + | term | |
12 | + | group | |
13 | + | predicate | |
14 | + ) ( '?' | '*' | '+' | '#' )? ; | |
15 | + | |
16 | +The question is: *“Can we use *TypeHits* (similar as in python)”*? | |
17 | + | |
18 | +Surely, that is possible. Then we get something like below, where (only) the result//lhs has a type hint | |
19 | + | |
20 | +.. code-block:: peg | |
21 | + | |
22 | + single_expr:SingleExpr <- ( rule_crossref | |
23 | + | term | |
24 | + | group | |
25 | + | predicate | |
26 | + ) ( '?' | '*' | '+' | '#' )? ; | |
27 | + | |
28 | +Or even | |
29 | +.. code-block:: peg | |
30 | + | |
31 | + single_expr <- ( rule_crossref : ID | |
32 | + | term:Term | |
33 | + | group: Sequence | |
34 | + | predicate:Predicate | |
35 | + ) ( '?' | '*' | '+' | '#' )? ; | |
36 | + | |
37 | +The idea is to make it more readable, but also *TypeHints* may be useful for | |
38 | +* ?*Vistors*? | |
39 | +* Type Checking | |
40 | +* to be discovered |