--- a/Parser.st Tue Mar 31 13:57:44 1998 +0200
+++ b/Parser.st Tue Mar 31 14:00:31 1998 +0200
@@ -1703,6 +1703,19 @@
tree := aTree
! !
+!Parser methodsFor:'dummy - syntax detection'!
+
+markArgumentIdentifierFrom:pos1 to:pos2
+
+ "Created: / 31.3.1998 / 13:22:15 / cg"
+!
+
+markSelectorFrom:pos1 to:pos2
+
+ "Created: / 31.3.1998 / 13:22:15 / cg"
+ "Modified: / 31.3.1998 / 13:30:09 / cg"
+! !
+
!Parser methodsFor:'error correction'!
askForCorrection:aString fromList:aList
@@ -3148,71 +3161,77 @@
Return the receiver or #Error.
methodSpec ::= { KEYWORD IDENTIFIER }
- | binaryOperator IDENTIFIER
- | IDENTIFIER
+ | binaryOperator IDENTIFIER
+ | IDENTIFIER
"
|var|
tokenType isNil ifTrue:[
- self nextToken.
+ self nextToken.
].
(tokenType == #Keyword) ifTrue:[
- selector := ''.
- [tokenType == #Keyword] whileTrue:[
- selector := selector , tokenName.
- self nextToken.
- (tokenType ~~ #Identifier) ifTrue:[^ #Error].
- var := Variable name:tokenName.
- methodArgs isNil ifTrue:[
- methodArgs := Array with:var.
- methodArgNames := Array with:tokenName
- ] ifFalse:[
- (methodArgNames includes:tokenName) ifTrue:[
- self syntaxError:'redefinition of ''' , tokenName , ''' in argument list.'
- position:tokenPosition
- to:(tokenPosition + tokenName size - 1)
- ].
- methodArgs := methodArgs copyWith:var.
- methodArgNames := methodArgNames copyWith:tokenName
- ].
- self nextToken
- ].
- selector := selector asSymbol.
- ^ self
+ selector := ''.
+ [tokenType == #Keyword] whileTrue:[
+ self markSelectorFrom:tokenPosition to:(tokenPosition+tokenName size).
+ selector := selector , tokenName.
+ self nextToken.
+ (tokenType ~~ #Identifier) ifTrue:[^ #Error].
+ self markArgumentIdentifierFrom:tokenPosition to:(tokenPosition+tokenName size).
+ var := Variable name:tokenName.
+ methodArgs isNil ifTrue:[
+ methodArgs := Array with:var.
+ methodArgNames := Array with:tokenName
+ ] ifFalse:[
+ (methodArgNames includes:tokenName) ifTrue:[
+ self syntaxError:'redefinition of ''' , tokenName , ''' in argument list.'
+ position:tokenPosition
+ to:(tokenPosition + tokenName size - 1)
+ ].
+ methodArgs := methodArgs copyWith:var.
+ methodArgNames := methodArgNames copyWith:tokenName
+ ].
+ self nextToken
+ ].
+ selector := selector asSymbol.
+ ^ self
].
(tokenType == #Identifier) ifTrue:[
- selector := tokenName asSymbol.
- self nextToken.
- ^ self
+ self markSelectorFrom:tokenPosition to:(tokenPosition+tokenName size).
+ selector := tokenName asSymbol.
+ self nextToken.
+ ^ self
].
"/ special handling for |, which is also a lexical token
tokenType == $| ifTrue:[
- tokenType := #BinaryOperator.
- tokenName := '|'
+ tokenType := #BinaryOperator.
+ tokenName := '|'
].
(tokenType == #BinaryOperator) ifTrue:[
- selector := tokenName asSymbol.
- self nextToken.
- (tokenType ~~ #Identifier) ifTrue:[^ #Error].
- var := Variable name:tokenName.
+ self markSelectorFrom:tokenPosition to:(tokenPosition+tokenName size).
+ selector := tokenName asSymbol.
+ self nextToken.
+ (tokenType ~~ #Identifier) ifTrue:[^ #Error].
+ self markArgumentIdentifierFrom:tokenPosition to:(tokenPosition+tokenName size).
+ var := Variable name:tokenName.
+
"/ methodArgs isNil ifTrue:[
- methodArgs := Array with:var.
- methodArgNames := Array with:tokenName.
+ methodArgs := Array with:var.
+ methodArgNames := Array with:tokenName.
"/ ] ifFalse:[
"/ methodArgs := methodArgs copyWith:var.
"/ methodArgNames := methodArgNames copyWith:tokenName
"/ ].
- self nextToken.
- ^ self
+ self nextToken.
+ ^ self
].
^ #Error
- "Modified: 3.1.1997 / 16:18:04 / cg"
+ "Modified: / 31.3.1998 / 13:29:01 / cg"
!
parsePrimitiveOrResourceSpecOrEmpty
@@ -4487,6 +4506,6 @@
!Parser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.155 1998-02-16 14:03:50 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.156 1998-03-31 12:00:31 cg Exp $'
! !
Parser initialize!