class: Parser
comment/format in: #parsePrimitive
changed:7 methods
removed (I hope) the last leftovers of the #Error
returning without raising parseError.
There is still #Error returned, but only if parseError
is cought and proceeded.
--- a/Parser.st Sun Feb 23 00:26:30 2014 +0100
+++ b/Parser.st Sun Feb 23 00:28:10 2014 +0100
@@ -5862,7 +5862,10 @@
self markMethodSelectorFrom:pos1 to:(pos1+tokenName size - 1).
rawSelector := tokenName.
self nextToken.
- (tokenType ~~ #Identifier) ifTrue:[^ #Error].
+ (tokenType ~~ #Identifier) ifTrue:[
+ "/ ^ #Error
+ ^ self identifierExpectedIn:'method-arg declaration'.
+ ].
argPos1 := tokenPosition.
pos2 := argPos2 := argPos1+tokenName size - 1.
self markMethodArgumentIdentifierFrom:argPos1 to:argPos2.
@@ -5882,7 +5885,7 @@
"/ ].
^ self
].
-
+ self parseError:'invalid method specification'.
^ #Error
"Modified: / 12-07-2010 / 09:57:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -7095,13 +7098,19 @@
(tokenType == #HashLeftParen) ifTrue:[
self nextToken.
self inArrayLiteral:true.
- ParseError handle:[:ex |
+"/ old
+"/ ParseError handle:[:ex |
+"/ self inArrayLiteral:false.
+"/ ^ #Error
+"/ ] do:[
+"/ val := self array.
+"/ ].
+"/ self inArrayLiteral:false.
+ [
+ val := self array.
+ ] ensure:[
self inArrayLiteral:false.
- ^ #Error
- ] do:[
- val := self array.
- ].
- self inArrayLiteral:false.
+ ].
self nextToken.
(self noAssignmentAllowed:'Assignment to a constant' at:pos) ifFalse:[
^ #Error
@@ -7211,13 +7220,21 @@
].
self nextToken.
self inArrayLiteral:true.
- ParseError handle:[:ex |
+ "/ old
+"/ ParseError handle:[:ex |
+"/ self inArrayLiteral:false.
+"/ ^ #Error
+"/ ] do:[
+"/ val := self array.
+"/ ].
+"/ self inArrayLiteral:false.
+ "/ new
+ [
+ val := self array.
+ ] ensure:[
self inArrayLiteral:false.
- ^ #Error
- ] do:[
- val := self array.
- ].
- self inArrayLiteral:false.
+ ].
+
self nextToken.
(self noAssignmentAllowed:'Assignment to a constant' at:pos) ifFalse:[
^ #Error
@@ -7236,7 +7253,7 @@
((parserFlags allowSqueakExtensions == true)
or:[parserFlags allowSTVExtensions == true]) ifFalse:[
self parseError:'non-Standard Squeak (or ST/V) extension: space between sign and number. Enable in settings.' position:pos to:tokenPosition.
- errorFlag := false.
+ "/ errorFlag := false.
].
node := self primary_simpleLiteral.
@@ -7842,7 +7859,7 @@
self nextToken.
(self noAssignmentAllowed:'Assignment to pseudo variable ''self''' at:pos) ifFalse:[
- ^ ParseError raiseErrorString:'Assignment to self'.
+ ^ #Error
].
self markSelfFrom:pos to:pos+3.
^ self selfNode startPosition: pos endPosition: pos + 3
@@ -8269,8 +8286,10 @@
parserFlags implicitSelfSends ifTrue:[
^ UnaryNode receiver:(self selfNode) selector:('__' , tokenName) asSymbol.
].
+ self parseError:'undeclared variable: ',tokenName.
^ #Error
- ]
+ ].
+ self parseError:'undeclared variable: ',tokenName.
] ifFalse:[
self rememberGlobalUsed:(Smalltalk undeclaredPrefix) , tokenName.
self rememberGlobalUsed:tokenName.
@@ -8561,6 +8580,7 @@
]
].
"/ ].
+ self parseError:'undeclared variable: ',tokenName.
^ #Error
"Modified: / 18-01-2011 / 18:02:32 / cg"
@@ -8711,6 +8731,7 @@
self nextToken.
^value.
].
+ self parseError:tokenType,' unexpected in annotation'.
^ #Error
"Created: / 12-11-2009 / 14:08:29 / Jan Travnicek <travnja3@fel.cvut.cz>"
@@ -8729,25 +8750,25 @@
"/ notice: '<' has already been parsed.
pragmaType := tokenName.
self nextToken.
- (tokenType ~~ #Symbol) ifTrue:[
- self parseError:'symbol expected'.
- ^ #Error
- ].
+
(pragmaType = 'context:') ifTrue:[
- (tokenValue == #return) ifTrue:[
+ ((tokenType == #Symbol) and:[tokenValue == #return]) ifTrue:[
self rememberContextReturnablePragma
] ifFalse:[
- self parseError:'unrecognized context pragma: ' , tokenValue.
+ self parseError:'invalid context pragma: ' , (tokenValue ? tokenName).
].
].
(pragmaType = 'exception:') ifTrue:[
- (tokenValue == #handle
- or:[ tokenValue == #raise
- or:[ tokenValue == #unwind ]]) ifTrue:[
+ ((tokenType == #Symbol)
+ and:[
+ tokenValue == #handle
+ or:[ tokenValue == #raise
+ or:[ tokenValue == #unwind ]]]
+ ) ifTrue:[
self rememberContextPragma:pragmaType value:tokenValue
] ifFalse:[
- self parseError:'unrecognized exception pragma: ' , tokenValue.
+ self parseError:'invalid exception pragma: ' , (tokenValue ? tokenName).
].
].
@@ -8995,23 +9016,20 @@
].
(tokenName = 'primitive:') ifTrue:[
tmp := self parseTraditionalPrimitive.
- annotations := annotations
- copyWith:(Array with:'primitive:' asSymbol with:tmp).
+ annotations := annotations copyWith:(Array with:'primitive:' asSymbol with:tmp).
^ tmp.
].
(tokenName = 'sysprim:') ifTrue:[
parserFlags allowVisualAgePrimitives ifTrue:[
tmp := self parseTraditionalPrimitive.
- annotations := annotations
- copyWith:(Array with:'sysprim:' asSymbol with:tmp).
+ annotations := annotations copyWith:(Array with:'sysprim:' asSymbol with:tmp).
^ tmp.
].
].
(tokenName = 'primitive') ifTrue:[
self nextToken.
self checkForClosingAngle.
- annotations := annotations
- copyWith:(Array with:'primitive' asSymbol with:0).
+ annotations := annotations copyWith:(Array with:'primitive' asSymbol with:0).
^ 0
"/ no primitive number
.
@@ -9037,38 +9055,17 @@
"/ no primitive number
].
lcTokenName := tokenName asLowercase.
- ((lcTokenName = 'c:'
- "/ vw external function definition
- )
- or:[
- lcTokenName = 'api:'
- "/ st/v external function definition
-
- or:[
- lcTokenName = 'ole:'
- "/ st/v external function definition
-
- or:[
- lcTokenName = 'apicall:'
- "/ squeak external function definition
-
- or:[
- lcTokenName = 'cdecl:'
- "/ squeak external function definition
-
- or:[
- lcTokenName = 'stdcall:'
- "/ dolphin external function definition
- ]
- ]
- ]
- ]
- ])
- ifTrue:[
- self parseExternalFunctionCallDeclaration.
- ^ nil
- "/ no primitive number
- ].
+ ((lcTokenName = 'c:' "/ vw external function definition
+ ) or:[ lcTokenName = 'api:' "/ st/v external function definition
+ or:[ lcTokenName = 'ole:' "/ st/v external function definition
+ or:[ lcTokenName = 'apicall:' "/ squeak external function definition
+ or:[ lcTokenName = 'cdecl:' "/ squeak external function definition
+ or:[ lcTokenName = 'stdcall:' "/ dolphin external function definition
+ ]]]]]) ifTrue:[
+ self parseExternalFunctionCallDeclaration.
+ ^ nil
+ "/ no primitive number
+ ].
^ self parseOtherPrimitives.
"Modified: / 10-01-2010 / 17:10:11 / Jan Travnicek <travnja3@fel.cvut.cz>"
@@ -11784,11 +11781,11 @@
!Parser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.803 2014-02-22 15:56:35 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.804 2014-02-22 23:28:10 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.803 2014-02-22 15:56:35 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.804 2014-02-22 23:28:10 cg Exp $'
!
version_SVN