--- a/Parser.st Sat Jun 26 16:31:42 1999 +0200
+++ b/Parser.st Sat Jun 26 18:28:35 1999 +0200
@@ -21,7 +21,8 @@
warnedUndefVars warnSTXHereExtensionUsed correctedSource
foldConstants lineNumberInfo currentNamespace
currentUsedNamespaces warnUndeclared methodNode
- alreadyWarnedClassInstVarRefs'
+ alreadyWarnedClassInstVarRefs localBlockVarDefPosition
+ endOfSelectorPosition startOfBlockPosition'
classVariableNames:'PrevClass PrevInstVarNames PrevClassVarNames
PrevClassInstVarNames LazyCompilation ArraysAreImmutable
ImplicitSelfSends WarnST80Directives FoldConstants LineNumberInfo
@@ -1245,10 +1246,10 @@
aString isNil ifTrue:[^ nil].
parser := self for:(ReadStream on:aString) in:aClass.
noErrors ifTrue:[
- parser ignoreErrors
+ parser ignoreErrors
].
noWarnings ifTrue:[
- parser ignoreWarnings
+ parser ignoreWarnings
].
"/ parser nextToken.
(parser parseMethodSpec == #Error) ifTrue:[^ nil].
@@ -1257,9 +1258,9 @@
"/ - now, alternatively parse body for resource & primitive specs ..
"/
body ifTrue:[
- (parser parseMethodBodyOrEmpty == #Error) ifTrue:[^ nil].
+ parser parseMethodBodyOrEmpty
] ifFalse:[
- (parser parseMethodBodyVarSpec == #Error) ifTrue:[^ nil].
+ parser parseMethodBodyVarSpec
].
parser errorFlag ifTrue:[^ nil].
^ parser
@@ -1991,29 +1992,37 @@
l := #().
how := #().
+ "/ BlockVar, InstVar and classInstVar not yet implemented
varNameIsLowercase ifTrue:[
- currentBlock notNil ifTrue:[
- l := l , #( 'Block local' ).
- how := how , #( BlockVariable ).
- ].
+"/ currentBlock notNil ifTrue:[
+"/ l := l , #( 'Block local' ).
+"/ how := how , #( BlockVariable ).
+"/ ].
selector notNil ifTrue:[
l := l , #( 'Method local' ).
how := how , #( MethodVariable ).
].
- (classToCompileFor notNil
- and:[classToCompileFor isMeta not
- and:[classToCompileFor isBuiltInClass not]]) ifTrue:[
- l := l , (Array with:( 'Instance variable of ' , classToCompileFor name )).
- how := how , #( InstanceVariable ).
- ].
+"/ (classToCompileFor notNil
+"/ and:[classToCompileFor isMeta not
+"/ and:[classToCompileFor isBuiltInClass not]]) ifTrue:[
+"/ l := l , (Array with:( 'Instance variable of ' , classToCompileFor name )).
+"/ how := how , #( InstanceVariable ).
+"/ ].
] ifFalse:[
- l := l , #(
- 'Global'
- 'Class Variable'
- ).
- how := how , #( GlobalVariable Classvariable ).
+ l := l , #( 'Global' ).
+ how := how , #( GlobalVariable ).
+
+ (classToCompileFor notNil
+ and:[classToCompileFor isBuiltInClass not
+ and:[selector notNil and:[selector ~~ #doIt]]]) ifTrue:[
+ l := l , (Array
+ with:'Class Variable in ' , classToCompileFor name
+"/ with:'Class Instance Variable in ' , classToCompileFor name
+ ).
+ how := how , #( ClassVariable ClassInstVariable).
+ ]
].
- (requestor notNil and:[requestor isStream not]) ifTrue:[
+ (selector isNil or:[selector == #doIt]) ifTrue:[
l size > 0 ifTrue:[
l := l , #( '-' ).
how := how , #( nil ).
@@ -2032,8 +2041,58 @@
holder := Workspace addWorkspaceVariable:varName.
^ VariableNode type:#WorkspaceVariable holder:holder name:varName
].
+ choice == #GlobalVariable ifTrue:[
+ Smalltalk at:varName asSymbol put:nil.
+ ^ VariableNode type:#GlobalVariable name:varName asSymbol
+ ].
+ choice == #ClassVariable ifTrue:[
+ classToCompileFor addClassVarName:varName.
+ ^ VariableNode type:#ClassVariable class:classToCompileFor name:varName
+ ].
+ choice == #MethodVariable ifTrue:[
+ |varIndex var endLocalsPos posToInsert ins|
+
+ localVarDefPosition size == 2 ifTrue:[
+ endLocalsPos := posToInsert := localVarDefPosition at:2.
+ ins := ' ' , varName.
+ ] ifFalse:[
+ endOfSelectorPosition notNil ifTrue:[
+ posToInsert := endOfSelectorPosition.
+ ins := '|' , varName , '|' , Character cr asString , Character cr asString.
+ ins := ins , (String new:(requestor colOfCharacterPosition:posToInsert)-1).
+ ]
+ ].
+ posToInsert notNil ifTrue:[
+ requestor
+ insertString:ins
+ atCharacterPosition:posToInsert.
+
+ endLocalsPos notNil ifTrue:[
+ localVarDefPosition at:2 put:(endLocalsPos + varName size + 1).
+
+ methodVarNames := methodVarNames copyWith:varName.
+ methodVars := methodVars copyWith:(var := Variable new name:varName).
+ ] ifFalse:[
+ localVarDefPosition := Array with:posToInsert with:posToInsert+varName size+1.
+
+ methodVarNames := Array with:varName.
+ methodVars := Array with:(var := Variable new name:varName).
+ ].
+ correctedSource := requestor currentSourceCode.
+ source := (ReadStream on:correctedSource)
+ position:(source position + ins size).
+
+ varIndex := methodVarNames size.
+ var used:true.
+ ^ VariableNode type:#MethodVariable
+ name:varName
+ token:var
+ index:varIndex
+ ].
+ ].
+ self warning:'Sorry - unimplemented (adding ' , choice , ')'.
].
-self halt.
+ ^ #Error
]
].
@@ -2852,6 +2911,7 @@
self syntaxError:msg position:tokenPosition to:source position-1.
^ #Error
].
+ localVarDefPosition := Array with:localVarDefPosition with:tokenPosition.
self nextToken
].
^ nil
@@ -2899,12 +2959,14 @@
self nextToken
].
selector := selector asSymbol.
+ endOfSelectorPosition := tokenPosition.
^ self
].
(tokenType == #Identifier) ifTrue:[
self markMethodSelectorFrom:tokenPosition to:(tokenPosition+tokenName size-1).
selector := tokenName asSymbol.
self nextToken.
+ endOfSelectorPosition := tokenPosition.
^ self
].
@@ -2930,6 +2992,7 @@
"/ methodArgNames := methodArgNames copyWith:tokenName
"/ ].
self nextToken.
+ endOfSelectorPosition := tokenPosition.
^ self
].
@@ -3195,6 +3258,13 @@
^ firstStatement
"Modified: 14.4.1997 / 20:46:46 / cg"
+!
+
+xxx
+ |lno tokenFooFeed|
+
+ lno := tokenFooFeed.
+ self nextToken.
! !
!Parser methodsFor:'parsing-expressions'!
@@ -4834,6 +4904,6 @@
!Parser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.203 1999-06-26 14:31:42 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.204 1999-06-26 16:28:35 cg Exp $'
! !
Parser initialize!