--- a/Parser.st Sun Feb 10 16:24:30 2019 +0100
+++ b/Parser.st Sun Feb 10 22:39:34 2019 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
@@ -1421,6 +1423,7 @@
].
tree := compiler parseMethodBody.
+ compiler checkForEndOfInput.
].
(compiler errorFlag
@@ -1471,8 +1474,9 @@
].
^ innerBlock.
- "Created: 11.1.1997 / 23:29:13 / cg"
- "Modified: 14.2.1997 / 16:51:25 / cg"
+ "Created: / 11-01-1997 / 23:29:13 / cg"
+ "Modified: / 14-02-1997 / 16:51:25 / cg"
+ "Modified: / 10-02-2019 / 16:40:47 / Claus Gittinger"
!
checkMethod:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings
@@ -2301,12 +2305,15 @@
self nextToken.
parseTree := self parseMethodBody.
(errorFlag or:[tree == #Error]) ifTrue:[^ #Error].
+ self checkForEndOfInput.
parseTree notNil ifTrue:[
self evalExitBlock:[:value | ^ failBlock value].
value := parseTree evaluate
].
self release.
^ value
+
+ "Modified: / 10-02-2019 / 16:40:11 / Claus Gittinger"
!
parse:methodSource in:aClass notifying:aRequestor
@@ -5515,7 +5522,6 @@
selector := aParser selector.
! !
-
!Parser methodsFor:'obsolete'!
correctByDeleting
@@ -5907,13 +5913,14 @@
(self parseMethodSpec == #Error) ifTrue:[^ #Error].
parseTree := self parseMethodBody.
(parseTree == #Error) ifFalse:[
+ self checkForEndOfInput.
self tree:parseTree
].
- self checkForEndOfInput.
^ parseTree
"Modified: / 20-04-1996 / 20:09:26 / cg"
"Modified: / 12-07-2010 / 10:08:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-02-2019 / 16:40:23 / Claus Gittinger"
!
parseMethod:aString in:aClass
@@ -5958,8 +5965,7 @@
!
parseMethodBody
- "parse a methods body (locals & statements).
- No more tokens may follow.
+ "parse a method's body (locals & statements).
Return a node-tree, or #Error
methodBody ::= '<' st80Primitive '>' #EOF
@@ -5976,9 +5982,7 @@
self emptyStatement.
].
stats := self parseMethodBodyOrEmpty.
- (stats == #Error) ifFalse:[
- self checkForEndOfInput.
- ].
+
(requestor notNil and:[ignoreWarnings not]) ifTrue:[
parserFlags warnings ifTrue:[
self hasPrimitiveCode ifFalse:[
@@ -5994,11 +5998,12 @@
"Modified: / 16-07-2017 / 13:38:37 / cg"
"Modified: / 25-07-2017 / 17:09:54 / stefan"
+ "Modified (format): / 10-02-2019 / 16:42:37 / Claus Gittinger"
!
parseMethodBodyOrEmpty
- "parse a methods body (locals & statements);
- return a node-tree, nil or #Error.
+ "parse a method's body (locals & statements);
+ return a node-tree, nil or #Error.
empty (or comment only) input is accepted and returns nil.
methodBodyOrNil ::= '<' st80Primitive '>'
@@ -6039,6 +6044,7 @@
"Modified: / 24-09-2010 / 18:03:59 / cg"
"Modified: / 23-09-2018 / 00:33:44 / Claus Gittinger"
+ "Modified (comment): / 10-02-2019 / 16:42:13 / Claus Gittinger"
!
parseMethodBodyVarSpec
@@ -6052,27 +6058,30 @@
| <empty>
"
- |var pos pos2 msg classHint whatIsHidden|
+ |var pos pos2 msg classHint whatIsHidden firstVar|
((tokenType == #BinaryOperator) and:[tokenName = '<']) ifTrue:[
self parsePrimitiveOrResourceSpecOrEmpty.
].
+ methodVars := methodVarNames := nil.
(tokenType == $|) ifTrue:[
"memorize position for declaration in correction"
localVarDefPosition := Array with:tokenPosition with:nil.
self nextToken.
pos := tokenPosition.
+ firstVar := true.
[tokenType == #Identifier] whileTrue:[
pos2 := tokenPosition + tokenName size - 1.
self markLocalVariableDeclaration: tokenName from: tokenPosition to:pos2.
self checkMethodVariableNameConventionsFor:tokenName.
var := Variable name:tokenName.
- methodVars isNil ifTrue:[
+ firstVar ifTrue:[
methodVars := OrderedCollection with:var.
- methodVarNames := OrderedCollection with:tokenName
+ methodVarNames := OrderedCollection with:tokenName.
+ firstVar := false.
] ifFalse:[
(methodVarNames includes:tokenName) ifTrue:[
"/ redefinition
@@ -6195,6 +6204,7 @@
"Modified: / 25-02-2014 / 20:20:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 10-10-2017 / 16:58:13 / cg"
+ "Modified: / 10-02-2019 / 22:38:24 / Claus Gittinger"
!
parseMethodSpec
@@ -6207,7 +6217,7 @@
| IDENTIFIER
"
- |arg pos1 pos2 argPos1 argPos2 rawSelector|
+ |arg pos1 pos2 argPos1 argPos2 rawSelector firstArg|
tokenType isNil ifTrue:[
self nextToken.
@@ -6218,6 +6228,7 @@
"/ selectorPositions := OrderedCollection new.
(tokenType == #Keyword) ifTrue:[
+ firstArg := true.
rawSelector := ''.
[tokenType == #Keyword] whileTrue:[
"/ selectorPositions add:(tokenPosition to:(tokenPosition+tokenName size - 1)).
@@ -6235,9 +6246,10 @@
self markMethodArgumentIdentifierFrom:argPos1 to:argPos2.
self checkMethodArgumentNameConventionsFor:tokenName.
arg := Variable name:tokenName.
- methodArgs isNil ifTrue:[
+ firstArg ifTrue:[
methodArgs := Array with:arg.
- methodArgNames := Array with:tokenName
+ methodArgNames := Array with:tokenName.
+ firstArg := false.
] ifFalse:[
(methodArgNames includes:tokenName) ifTrue:[
self methodArgRedefined:tokenName from:argPos1 to:argPos2
@@ -6333,6 +6345,7 @@
"Modified: / 12-07-2010 / 09:57:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 21-08-2011 / 08:12:20 / cg"
+ "Modified: / 10-02-2019 / 18:16:09 / Claus Gittinger"
!
returnStatement