]> ocean-lang.org Git - ocean-D/commitdiff
updates
authorNeilBrown <neil@brown.name>
Tue, 23 Feb 2021 21:35:40 +0000 (08:35 +1100)
committerNeilBrown <neil@brown.name>
Tue, 23 Feb 2021 21:35:40 +0000 (08:35 +1100)
twod

diff --git a/twod b/twod
index a8b23cd9b59427eaad13d93847c7047960cf6993..4c9a44ec077b31265f5e7aef4df1ad204cae9ddc 100644 (file)
--- a/twod
+++ b/twod
@@ -3468,3 +3468,112 @@ ifstatement -> ifhead iftail
   I need to get indents_on_line right.
   Previously I tracked them before this frame. I don't know why...
   I want 0 when starts_line
   I need to get indents_on_line right.
   Previously I tracked them before this frame. I don't know why...
   I want 0 when starts_line
+
+19feb2021
+  OK, new approach is looking really good.  Need to make sure it isn't too hard
+  to use.
+  Tricky area is multi-line statements that don't *have* to be multi-line.
+
+  We cannot reduce "SOL IfHead EOL" to a statement as we cannot tell if it
+  is complete until we shift the SOL and look for an "else".
+  One option is "statement -> SOL IfHead EOL statement | SOL IfHead EOL IfTail"
+  So "statement" is really a sublit of statements.
+  Easy in indent_test, what about in ocean?
+
+  There are lots of parts that can be on a line:
+    if, else, for, then, while, do, switch, case
+
+  if and while can be "expr block" or "block" and the thenpart/dopart
+  else can be "block" or "statement"
+  then is optional in for, request if some if
+
+  ifpart -> if expr block | if block then block | if block EOL SOL then block
+
+  OR??
+
+  ifpart -> if expr block EOL SOL | if block then block EOL SOL...
+
+  What if I support backtracking over terminals? So if I cannot shift
+  and cannot reduce, I back up until I can reduce, then do so?
+
+  Then I can shift the SOL and if there is an else, I'm good.  If not I back up
+  and reduce the statement
+  So
+   statement -> SOL simple EOL
+       | SOL ifhead EOL
+       | SOL ifhead EOL SOL elsepart EOL
+       | SOL ifhead elsepart EOL
+  would work.
+  But do I need it?
+
+   statement -> simple EOL
+       | ifhead EOL
+       | ifhead EOL SOL statement
+       | ifhead EOL SOL iftail
+       | whilepart
+       | forhead whilepart
+       | switchead casepart
+
+
+   ifhead -> if block then block | if expr block | if block EOL SOL then block
+   iftail -> else block | else statement
+
+   whilehead -> while expr block | while block EOL SOL do block | while block do block
+   whilepart -> whilehead EOL
+       | whilehead EOL SOL statement
+       | whilehead casepart
+       | whilehead EOL SOL casepart
+
+   casepart -> casehead casepart
+       | casehead EOL SOL casepart
+       | casehead EOL SOL statement
+       | iftail
+   casehead -> case expr block
+
+22feb2021
+ I've had a new idea - let's drop SOL!  Now that I have IN, it isn't really needed.
+ We can assume SOL follows EOL or IN .... maybe.
+ Problem is if we want to require IN/OUT around something that is not line-oriented.
+ Might that ever matter?
+ No, I don't think so.
+
+23feb2021
+ Maybe this make it really really easy.
+ We don't mark different sorts of states, and we only track which indents were
+ 'ignored'.
+
+ Then:
+   IN never causes a reduction, it is either shifted or ignored.
+   An EOL is ignored if the most recent IN was ignored, otherwise it is a normal
+     token.
+   An OUT is similarly ignored if the matching indent was ignored.  It also
+     cancels that indent.
+
+   Is thats too easy?
+
+   .... no, it seems to work.
+   
+   So: back to the ocean grammar
+
+   statement -> simple EOL
+       | ifhead EOL
+       | ifhead EOL iftail
+       | whilepart
+       | forhead whilepart
+       | switchead casepart
+
+
+   ifhead -> if block then block | if expr block | if block EOL then block
+   iftail -> else block EOL | else statement
+
+   whilehead -> while expr block | while block EOL do block | while block do block
+   whilepart -> whilehead EOL
+       | whilehead casepart
+       | whilehead EOL casepart
+
+   casepart -> casehead casepart
+       | casehead EOL casepart
+       | casehead EOL
+       | iftail
+   casehead -> case expr block
+