Parser.st
branchjv
changeset 4384 aee25576d864
parent 4282 5a4d9c8445c7
child 4386 c9a7a8b055a3
--- a/Parser.st	Tue Jul 10 15:59:31 2018 +0100
+++ b/Parser.st	Sun Jul 15 18:18:34 2018 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
  COPYRIGHT (c) 2015-2017 Jan Vrany
@@ -2399,6 +2397,20 @@
     "Created: / 23-10-1996 / 15:39:43 / cg"
 !
 
+methodNode
+    "Return the parse tree (as instance `MethodNode`).
+     Note, that #tree return the parse tree as `StatementNode`"
+
+    ^ (MethodNode new
+            selector:selector
+            arguments:methodArgs
+            locals:methodVars
+            statements:(tree isNil ifTrue:[#()] ifFalse:[tree asCollectionOfStatements]))
+        encoder:self
+
+    "Created: / 15-07-2018 / 14:48:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 moreSharedPools
     ^ moreSharedPools
 !
@@ -3099,6 +3111,22 @@
     "intentionally left empty"
 ! !
 
+!Parser methodsFor:'enumeration'!
+
+blockNodesDo:aBlock recursively: aBoolean
+    "
+    Evaluate `aBlock` for each `BlockNode` in receicer's subtree. 
+
+    If, `aBoolean` is true, then recurse into block nodes themselves, 
+    evaluating `aBlock` for (all) nested blocks.
+    If `aBoolean` is false, stop at any block node.
+    " 
+    ^ tree blockNodesDo:aBlock recursively: aBoolean
+
+    "Created: / 15-07-2018 / 10:35:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 15-07-2018 / 14:33:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !Parser methodsFor:'error correction'!
 
 addDoItTemporary:varName
@@ -5433,6 +5461,7 @@
     selector := aParser selector.
 ! !
 
+
 !Parser methodsFor:'obsolete'!
 
 correctByDeleting