• R/O
  • SSH

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2


Commit MetaInfo

修订版cad5904cfb4033e2d7eab3a479aea42e5d4296dd (tree)
时间2022-05-19 19:35:08
作者Albert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Log Message

Updated Castle-Examples wiht Parsers: grammer is code! Not text. So one can't load a grammer (txt) into a Parser

更改概述

差异

diff -r 679f746f4bf1 -r cad5904cfb40 examples/My_ExpressionParser.Castle
--- a/examples/My_ExpressionParser.Castle Thu May 19 12:32:39 2022 +0200
+++ b/examples/My_ExpressionParser.Castle Thu May 19 12:35:08 2022 +0200
@@ -1,6 +1,6 @@
11 /* (C) Albert Mietus. Demo and test */
22
3-from My_ExpressionParser import Fixed_ExpressionParser, Init_ExpressionParser, Port_ExpressionParser;
3+from My_ExpressionParser import ExpressionParser;
44
55 from std.data.grammars import Grammer, Rule, ID;
66 from std.algorithms.parser import PEG;
@@ -14,10 +14,10 @@
1414 /*****************************************************************************************************/
1515
1616
17-implement ParserDemo.Fixed_ExpressionParser {
17+implement ParserDemo.ExpressionParser {
1818
1919 - Grammar: my_expression(){
20- // ToDo: logic expression: (&&,etc
20+ // ToDo: logic expression, ect
2121
2222 Rule: expr;
2323 Rule: atom_value, unary, exponentiation, multy_divide, add_minus;
@@ -61,21 +61,24 @@
6161 self.parser = PEG(g);
6262 }
6363
64-} //End Fixed_ExpressionParser
64+} //End ExpressionParser
6565 /*****************************************************************************************************/
6666
6767
68-implement ParserDemo.Init_ExpressionParser {
69-- init(Grammer:g) {
70- self.parser = PEG(g);
71-}
72-} //End Init_ExpressionParser
68+/*GAM: THIS IS NOT POSSIBLE: Grammar's can not be "loaded" (dynamicly)
69+ Each "rule" is basically a very short version of a function -- and as such static */
70+//WRONG implement ParserDemo.Init_ExpressionParser {
71+//WRONG - init(Grammer:g) {
72+//WRONG self.parser = PEG(g);
73+//WRONG }
74+//WRONG } //End Init_ExpressionParser
7375 /*****************************************************************************************************/
7476
75-
76-implement ParserDemo.Port_ExpressionParser {
77-g on expression
78-{
79- self.parser = PEG(g);
80-}
81-} //End Port_ExpressionParser
\ No newline at end of file
77+/*GAM: THIS IS NOT POSSIBLE: Grammar's can not be "loaded" (dynamicly)
78+ Each "rule" is basically a very short version of a function -- and as such static */
79+//WRONG implement ParserDemo.Port_ExpressionParser {
80+//WRONG g on expression
81+//WRONG {
82+//WRONG self.parser = PEG(g);
83+//WRONG }
84+//WRONG } //End Port_ExpressionParser
\ No newline at end of file
diff -r 679f746f4bf1 -r cad5904cfb40 examples/My_ExpressionParser.Moat
--- a/examples/My_ExpressionParser.Moat Thu May 19 12:32:39 2022 +0200
+++ b/examples/My_ExpressionParser.Moat Thu May 19 12:35:08 2022 +0200
@@ -3,21 +3,22 @@
33 from ParserDemo import Abstract_Parser, Base_ChunkParser;
44 from std.data.grammars import Grammer
55
6+/*NOTE: A grammar is always "hardcoded (so "Fixed"-- and as such the Fixed-prefix is useless
7+ Each "rule" is basically a very short version of a function -- and as such static */
8+component ExpressionParser : Abstract_Parser, Base_ChunkParser {
69
7-component Fixed_ExpressionParser : Abstract_Parser, Base_ChunkParser {
8- """The Fixed_ExpressionParser has the grammer build-in; unlike the :ref:`Init_ExpressionParser` and :ref:`Port_ExpressionParser`"""
910 }
1011
1112
1213
13-component Init_ExpressionParser : Base_ExpressionParser {
14- """The Init_ExpressionParser reads the grammer when it is initialized"""
15-- init(Grammer:g)
16-}
14+
15+//WRONG component Init_ExpressionParser : Base_ExpressionParser {
16+//WRONG """The Init_ExpressionParser reads the grammer when it is initialized"""
17+//WRONG - init(Grammer:g)
18+//WRONG }
1719
1820
19-
20-component Port_ExpressionParser : Base_ExpressionParser {
21- """The Port_ExpressionParser reads the grammer via a port (unlike the :ref:`Fixed_ExpressionParser`."""
22- port Grammar<in> expression;
23-}
21+//WRONG component Port_ExpressionParser : Base_ExpressionParser {
22+//WRONG """The Port_ExpressionParser reads the grammer via a port (unlike the :ref:`Fixed_ExpressionParser`."""
23+//WRONG port Grammar<in> expression;
24+//WRONG }