class: Parser
authorClaus Gittinger <cg@exept.de>
Wed, 05 Mar 2014 17:25:03 +0100
changeset 3400 d8fc074a046c
parent 3399 cc86deb41376
child 3401 b9c13d91d6fe
class: Parser comment/format in:5 methods
Parser.st
--- a/Parser.st	Wed Mar 05 14:04:28 2014 +0100
+++ b/Parser.st	Wed Mar 05 17:25:03 2014 +0100
@@ -525,12 +525,8 @@
     LineNumberInfo := false.
 
     ParseErrorSignal isNil ifTrue:[
-	ParseErrorSignal := ParseError.
-	ParseErrorSignal notifierString:'Parse error:'.
-
-"/        ParseErrorSignal := Error newSignalMayProceed:true.
-"/        ParseErrorSignal notifierString:'parse error'.
-"/        ParseErrorSignal nameClass:self message:#parseErrorSignal.
+        ParseErrorSignal := ParseError.
+        ParseErrorSignal notifierString:'Parse error:'.
     ].
 
     Smalltalk addDependent:self.
@@ -1995,26 +1991,34 @@
     "Modified: / 22-10-2006 / 02:25:37 / cg"
 !
 
-make:anObject immutable:what
+make:anObject immutable:whichImmutableClass
+    "helper to optionally make Arrays, ByteArrays and Strings immutable."
+
     |newObject|
 
     newObject := anObject copy.
-    what notNil ifTrue:[
-	newObject changeClassTo:what.
+    whichImmutableClass notNil ifTrue:[
+        newObject changeClassTo:whichImmutableClass.
     ].
     newObject beImmutable.
     ^ newObject
 !
 
 makeImmutableArray:anArray
+    "helper to optionally make an array immutable."
+
     ^ self make:anArray immutable:ImmutableArray
 !
 
 makeImmutableByteArray:aByteArray
+    "helper to optionally make a byte array immutable."
+
     ^ self make:aByteArray immutable:ImmutableByteArray
 !
 
 makeImmutableString:aString
+    "helper to optionally make a string immutable."
+
     ^ self make:aString immutable:ImmutableString
 ! !
 
@@ -6870,7 +6874,7 @@
     "parse a keyword-expression; return a node-tree, nil or #Error.
 
      keywordExpression ::= binaryexpression
-			   | { KEYWORD-PART binaryExpression }
+                           | { KEYWORD-PART binaryExpression }
     "
 
     |receiver expr|
@@ -6882,44 +6886,49 @@
     tokenType == $) ifTrue:[^ receiver].
     expr := self keywordExpressionFor:receiver.
 
+    expr == #Error ifTrue:[ "/ should no longer happen
+self breakPoint:#cg. 
+        ^ #Error
+    ].
+
     "/ expr could be an assignment as well, here
     (ignoreWarnings or:[ignoreErrors]) ifFalse:[
-	"/ for a better error message, in case of a missing period in the previous message,
-	"/    <expr> <missing period> foo := ...
-	"/ would be parsed as unary message foo; detect this here, instead of high up in the calling hierarchy,
-	"/ where it is difficult to provide a reasonable error message
-	tokenType == #':=' ifTrue:[
-	    |positionOfPeriod|
-
-	    expr isMessage ifTrue:[
-		expr isUnaryMessage ifTrue:[
-		    positionOfPeriod := expr receiver positionToInsertPeriodForStatementSeparation
-		] ifFalse:[
-		    |lastArg|
-
-		    (lastArg := expr args last) isUnaryMessage ifTrue:[
-			positionOfPeriod := lastArg receiver positionToInsertPeriodForStatementSeparation
-		    ].
-		].
-	    ].
-	    positionOfPeriod notNil ifTrue:[
-		PossibleCorrectionsQuery answer:{ CorrectByInsertingPeriod new positionOfPeriod:positionOfPeriod} do:[
-		    |fix|
-
-		    fix := self
-			correctableWarning:('":=" unexpected. Probably missing "." in previous expression.')
-			position:tokenPosition to:tokenPosition+token size-1.
-
-		    (fix isBehavior or:[fix isKindOf:Correction]) ifTrue:[
-			self correctWith:fix from:tokenPosition to:tokenPosition+token size-1.
-		    ].
+        "/ for a better error message, in case of a missing period in the previous message,
+        "/    <expr> <missing period> foo := ...
+        "/ would be parsed as unary message foo; detect this here, instead of high up in the calling hierarchy,
+        "/ where it is difficult to provide a reasonable error message
+        tokenType == #':=' ifTrue:[
+            |positionOfPeriod|
+
+            expr isMessage ifTrue:[
+                expr isUnaryMessage ifTrue:[
+                    positionOfPeriod := expr receiver positionToInsertPeriodForStatementSeparation
+                ] ifFalse:[
+                    |lastArg|
+
+                    (lastArg := expr args last) isUnaryMessage ifTrue:[
+                        positionOfPeriod := lastArg receiver positionToInsertPeriodForStatementSeparation
+                    ].
+                ].
+            ].
+            positionOfPeriod notNil ifTrue:[
+                PossibleCorrectionsQuery answer:{ CorrectByInsertingPeriod new positionOfPeriod:positionOfPeriod} do:[
+                    |fix|
+
+                    fix := self
+                        correctableWarning:('":=" unexpected. Probably missing "." in previous expression.')
+                        position:tokenPosition to:tokenPosition+token size-1.
+
+                    (fix isBehavior or:[fix isKindOf:Correction]) ifTrue:[
+                        self correctWith:fix from:tokenPosition to:tokenPosition+token size-1.
+                    ].
 self breakPoint:#cg.
-		    fix == #Error ifTrue:[
-			^ #Error
-		    ]
-		]
-	    ]
-	].
+                    fix == #Error ifTrue:[
+                        ^ #Error
+                    ]
+                ]
+            ]
+        ].
     ].
 
     ^ expr
@@ -11818,11 +11827,11 @@
 !Parser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.812 2014-03-05 13:04:28 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.813 2014-03-05 16:25:03 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.812 2014-03-05 13:04:28 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.813 2014-03-05 16:25:03 cg Exp $'
 !
 
 version_SVN