diff -r 3b0d380771e9 -r ccc7f9389a8e Parser.st --- a/Parser.st Mon Jul 03 04:38:59 1995 +0200 +++ b/Parser.st Sun Jul 23 04:24:56 1995 +0200 @@ -32,7 +32,8 @@ correctedSource' classVariableNames:'PrevClass PrevInstVarNames PrevClassVarNames PrevClassInstVarNames - LazyCompilation ArraysAreImmutable' + LazyCompilation ArraysAreImmutable + ImplicitSelfSends' poolDictionaries:'' category:'System-Compiler' ! @@ -41,7 +42,7 @@ COPYRIGHT (c) 1989 by Claus Gittinger All Rights Reserved -$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.45 1995-07-03 02:38:44 claus Exp $ +$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.46 1995-07-23 02:23:59 claus Exp $ '! !Parser class methodsFor:'documentation'! @@ -62,7 +63,7 @@ version " -$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.45 1995-07-03 02:38:44 claus Exp $ +$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.46 1995-07-23 02:23:59 claus Exp $ " ! @@ -478,8 +479,9 @@ !Parser class methodsFor:'initialization '! initialize - LazyCompilation := false. "/ usually set to true in your .rc file - ArraysAreImmutable := false "/ usually left true for ST-80 compatibility + LazyCompilation := false. "/ usually set to true in your .rc file + ArraysAreImmutable := false. "/ usually left true for ST-80 compatibility + ImplicitSelfSends := false ! ! !Parser class methodsFor:'instance creation'! @@ -855,6 +857,25 @@ Compiler arraysAreImmutable:true Compiler arraysAreImmutable:false " +! + +implicitSelfSends + "return true if undefined variables with + lowercase first character are to be turned + into implicit self sends" + + ^ ImplicitSelfSends +! + +implicitSelfSends:aBoolean + "turn on/off implicit self sends" + + ImplicitSelfSends := aBoolean + + " + Compiler implicitSelfSends:true + Compiler implicitSelfSends:false + " ! ! !Parser methodsFor:'ST-80 compatibility'! @@ -2227,7 +2248,7 @@ classToCompileFor notNil ifTrue:[ "is it an instance-variable ?" - instIndex := (self instVarNames) indexOf:varName startingAt:1. + instIndex := (self instVarNames) lastIndexOf:varName. instIndex ~~ 0 ifTrue:[ parseForCode ifFalse:[self rememberInstVarUsed:varName]. ^ VariableNode type:#InstanceVariable @@ -2238,7 +2259,7 @@ "is it a class-instance-variable ?" - instIndex := (self classInstVarNames) indexOf:varName startingAt:1. + instIndex := (self classInstVarNames) lastIndexOf:varName. instIndex ~~ 0 ifTrue:[ aClass := self inWhichClassIsClassInstVar:varName. aClass notNil ifTrue:[ @@ -2252,13 +2273,12 @@ "is it a class-variable ?" - instIndex := (self classVarNames) indexOf:varName startingAt:1. + instIndex := (self classVarNames) lastIndexOf:varName. instIndex ~~ 0 ifTrue:[ aClass := self inWhichClassIsClassVar:varName. aClass notNil ifTrue:[ parseForCode ifFalse:[self rememberClassVarUsed:varName]. - ^ VariableNode type:#ClassVariable - name:(aClass name , ':' , varName) asSymbol + ^ VariableNode type:#ClassVariable class:aClass name:varName ] ] ]. @@ -2283,7 +2303,18 @@ (v == #Error) ifFalse:[^ v]. v := self correctVariable. (v == #Error) ifFalse:[^ v]. - parseForCode ifFalse:[self rememberGlobalUsed:tokenName]. + parseForCode ifFalse:[ + self rememberGlobalUsed:tokenName + ] ifTrue:[ + tokenName first isLowercase ifTrue:[ + ImplicitSelfSends ifTrue:[ + selfNode isNil ifTrue:[ + selfNode := SelfNode value:selfValue + ]. + ^ UnaryNode receiver:selfNode selector:('implicit_' , tokenName) asSymbol. + ] + ] + ]. ^ VariableNode type:#GlobalVariable name:tokenName asSymbol ! @@ -2324,6 +2355,17 @@ ^ nil ! +blockExpression + "parse a blockExpression; return a node-tree, nil or #Error. + Not used by ST/X's parser, but added for ST-80 compatibility." + + tokenType ~~ $[ ifTrue:[ + self syntaxError:'[ expected'. + ^ #Error. + ]. + ^ self block +! + block "parse a block; return a node-tree, nil or #Error" @@ -2829,7 +2871,7 @@ (self confirm:('confirm correction to: ' , newName)) ifFalse:[^ #Error] " ] ifFalse:[ - self notify:'no good correction found'. + self information:'no good correction found'. ^ #Error ]. @@ -2923,7 +2965,7 @@ newSelector := self askForCorrection:'correct selector to: ' fromList:suggestedNames. newSelector isNil ifTrue:[^ aSelectorString]. ] ifFalse:[ - self notify:'no good correction found'. + self information:'no good correction found'. ^ aSelectorString ].