Parser.st
changeset 3402 1f8f2e633587
parent 3400 d8fc074a046c
child 3404 f181370f72db
equal deleted inserted replaced
3401:b9c13d91d6fe 3402:1f8f2e633587
  7037     class setSuperclass: InlineObject.
  7037     class setSuperclass: InlineObject.
  7038     class setInstanceVariableString:(names asStringWith:Character space).
  7038     class setInstanceVariableString:(names asStringWith:Character space).
  7039     class instSize: names size.
  7039     class instSize: names size.
  7040 
  7040 
  7041     names keysAndValuesDo:[:idx :instVarName |
  7041     names keysAndValuesDo:[:idx :instVarName |
  7042 	idx <= InlineObjectPrototype instSize ifTrue:[
  7042         idx <= InlineObjectPrototype instSize ifTrue:[
  7043 	    class basicAddSelector:(instVarName asSymbol) withMethod:(InlineObjectPrototype compiledMethodAt:('i%1' bindWith:idx) asSymbol).
  7043             class basicAddSelector:(instVarName asSymbol) withMethod:(InlineObjectPrototype compiledMethodAt:('i%1' bindWith:idx) asSymbol).
  7044 	    inlineObjectsAreReadonly ifFalse:[
  7044             inlineObjectsAreReadonly ifFalse:[
  7045 		class basicAddSelector:((instVarName,':') asSymbol) withMethod:(InlineObjectPrototype compiledMethodAt:('i%1:' bindWith:idx) asSymbol).
  7045                 class basicAddSelector:(instVarName asMutator) withMethod:(InlineObjectPrototype compiledMethodAt:('i%1:' bindWith:idx) asSymbol).
  7046 	    ].
  7046             ].
  7047 	] ifFalse:[
  7047         ] ifFalse:[
  7048 	    Class withoutUpdatingChangesDo:[
  7048             Class withoutUpdatingChangesDo:[
  7049 		Compiler compile:('%1 ^%1' bindWith:instVarName) forClass:class.
  7049                 Compiler compile:('%1 ^%1' bindWith:instVarName) forClass:class.
  7050 		inlineObjectsAreReadonly ifFalse:[
  7050                 inlineObjectsAreReadonly ifFalse:[
  7051 		    Compiler compile:('%1:something %1 := something' bindWith:instVarName) forClass:class.
  7051                     Compiler compile:('%1:something %1 := something' bindWith:instVarName) forClass:class.
  7052 		].
  7052                 ].
  7053 	    ].
  7053             ].
  7054 	].
  7054         ].
  7055     ].
  7055     ].
  7056 
  7056 
  7057     instance := class new.
  7057     instance := class new.
  7058     1 to:names size do:[:idx | instance instVarAt:idx put:(values at:idx) ].
  7058     1 to:names size do:[:idx | instance instVarAt:idx put:(values at:idx) ].
  7059     ^ instance
  7059     ^ instance
  7491 
  7491 
  7492     (self isDoIt
  7492     (self isDoIt
  7493     and:[ currentBlock isNil
  7493     and:[ currentBlock isNil
  7494     and:[ requestor notNil
  7494     and:[ requestor notNil
  7495     and:[ (autoHow := requestor perform:#autoDefineVariables ifNotUnderstood:nil) notNil]]]) ifTrue:[
  7495     and:[ (autoHow := requestor perform:#autoDefineVariables ifNotUnderstood:nil) notNil]]]) ifTrue:[
  7496 	var := self variableOrError:varName.
  7496         var := self variableOrError:varName.
  7497 	self nextToken.
  7497         self nextToken.
  7498 	(var == #Error) ifTrue:[
  7498         (var == #Error) ifTrue:[
  7499 	    ((tokenType == $_) or:[tokenType == #':=']) ifTrue:[
  7499             ((tokenType == $_) or:[tokenType == #':=']) ifTrue:[
  7500 		autoHow == #workspace ifTrue:[
  7500                 autoHow == #workspace ifTrue:[
  7501 		    holder := Workspace addWorkspaceVariable:varName.
  7501                     holder := Workspace addWorkspaceVariable:varName.
  7502 		    var := VariableNode type:#WorkspaceVariable holder:holder name:varName.
  7502                     var := VariableNode type:#WorkspaceVariable holder:holder name:varName.
  7503 		] ifFalse:[
  7503                 ] ifFalse:[
  7504 		    holder := self addDoItTemporary:varName.
  7504                     holder := self addDoItTemporary:varName.
  7505 		    var := VariableNode type:#DoItTemporary holder:holder name:varName.
  7505                     var := VariableNode type:#DoItTemporary holder:holder name:varName.
  7506 		].
  7506                 ].
  7507 	    ] ifFalse:[
  7507             ] ifFalse:[
  7508 		var := self correctVariable:varName atPosition:pos1 to:pos2.
  7508                 var := self correctVariable:varName atPosition:pos1 to:pos2.
  7509 	    ].
  7509             ].
  7510 	    var startPosition: pos1 endPosition: pos2.
  7510             var startPosition: pos1 endPosition: pos2.
  7511 	]
  7511         ]
  7512     ] ifFalse:[
  7512     ] ifFalse:[
  7513 	var := self variable.
  7513         var := self variable.
  7514 	self nextToken.
  7514         self nextToken.
  7515     ].
  7515     ].
  7516 
  7516 
  7517     "/ errorFlag == true ifTrue:[self halt].
  7517     "/ errorFlag == true ifTrue:[self halt].
  7518     (var == #Error) ifTrue:[
  7518     (var == #Error) ifTrue:[
  7519 	errorFlag := true
  7519         errorFlag := true
  7520     ].
  7520     ].
  7521 
  7521 
  7522     (tokenType == #'::') ifTrue:[
  7522     (tokenType == #'::') ifTrue:[
  7523 	globlName := rawName := varName.
  7523         globlName := rawName := varName.
  7524 
  7524 
  7525 	"is it in a namespace ?"
  7525         "is it in a namespace ?"
  7526 	nameSpace := self findNameSpaceWith:globlName.
  7526         nameSpace := self findNameSpaceWith:globlName.
  7527 	nameSpace notNil ifTrue:[
  7527         nameSpace notNil ifTrue:[
  7528 	    globlName := nameSpace name , '::' , globlName
  7528             globlName := nameSpace name , '::' , globlName
  7529 	].
  7529         ].
  7530 
  7530 
  7531 	[tokenType == #'::'] whileTrue:[
  7531         [tokenType == #'::'] whileTrue:[
  7532 	    nameSpace := globlName.
  7532             nameSpace := globlName.
  7533 
  7533 
  7534 	    self nextToken.
  7534             self nextToken.
  7535 	    (tokenType == #Identifier) ifTrue:[
  7535             (tokenType == #Identifier) ifTrue:[
  7536 		self warnSTXNameSpaceUseAt:pos1.
  7536                 self warnSTXNameSpaceUseAt:pos1.
  7537 		varName := tokenName.
  7537                 varName := tokenName.
  7538 
  7538 
  7539 		globlName := (nameSpace , '::' , varName).
  7539                 globlName := (nameSpace , '::' , varName).
  7540 		rawName := (rawName , '::' , varName).
  7540                 rawName := (rawName , '::' , varName).
  7541 
  7541 
  7542 		nameSpaceGlobal := Smalltalk at:nameSpace asSymbol ifAbsent:nil.
  7542                 nameSpaceGlobal := Smalltalk at:nameSpace asSymbol ifAbsent:nil.
  7543 		nameSpaceGlobal isNil ifTrue:[
  7543                 nameSpaceGlobal isNil ifTrue:[
  7544 		    warnedUnknownNamespaces isNil ifTrue:[
  7544                     warnedUnknownNamespaces isNil ifTrue:[
  7545 			warnedUnknownNamespaces := Set new.
  7545                         warnedUnknownNamespaces := Set new.
  7546 		    ].
  7546                     ].
  7547 		    (warnedUnknownNamespaces includes:nameSpace) ifFalse:[
  7547                     (warnedUnknownNamespaces includes:nameSpace) ifFalse:[
  7548 "/ not needed; already warned.
  7548 "/ not needed; already warned.
  7549 "/                        "correctIt :=" requestor
  7549 "/                        "correctIt :=" requestor
  7550 "/                                        correctableError:('Unknown nameSpace: "', nameSpace,'"')
  7550 "/                                        correctableError:('Unknown nameSpace: "', nameSpace,'"')
  7551 "/                                        position:pos1 to:tokenPosition-1 from:self.
  7551 "/                                        position:pos1 to:tokenPosition-1 from:self.
  7552 
  7552 
  7553 "/                        self warning:('unknown nameSpace: ', nameSpace)
  7553 "/                        self warning:('unknown nameSpace: ', nameSpace)
  7554 "/                             position:pos1 to:tokenPosition-1.
  7554 "/                             position:pos1 to:tokenPosition-1.
  7555 "/                            self parseError:('unknown nameSpace: ', nameSpace) position:pos to:tokenPosition-1.
  7555 "/                            self parseError:('unknown nameSpace: ', nameSpace) position:pos to:tokenPosition-1.
  7556 			warnedUnknownNamespaces add:nameSpace.
  7556                         warnedUnknownNamespaces add:nameSpace.
  7557 		    ]
  7557                     ]
  7558 		] ifFalse:[
  7558                 ] ifFalse:[
  7559 		    nameSpaceGlobal isNameSpace ifTrue:[
  7559                     nameSpaceGlobal isNameSpace ifTrue:[
  7560 			"/ for now: only Smalltalk is allowed
  7560                         "/ for now: only Smalltalk is allowed
  7561 			nameSpaceGlobal ~~ Smalltalk ifTrue:[
  7561                         nameSpaceGlobal ~~ Smalltalk ifTrue:[
  7562 "/                                self parseError:('(currently) the only valid nameSpace is `Smalltalk''') position:pos to:tokenPosition-1.
  7562 "/                                self parseError:('(currently) the only valid nameSpace is `Smalltalk''') position:pos to:tokenPosition-1.
  7563 			] ifFalse:[
  7563                         ] ifFalse:[
  7564 			    globlName := varName
  7564                             globlName := varName
  7565 			].
  7565                         ].
  7566 		    ] ifFalse:[
  7566                     ] ifFalse:[
  7567 			nameSpaceGlobal isBehavior ifFalse:[
  7567                         nameSpaceGlobal isBehavior ifFalse:[
  7568 			    self parseError:('invalid nameSpace: ' , nameSpace)  position:pos1 to:tokenPosition-1.
  7568                             self parseError:('invalid nameSpace: ' , nameSpace)  position:pos1 to:tokenPosition-1.
  7569 			] ifTrue:[
  7569                         ] ifTrue:[
  7570 			    nameSpaceGlobal isLoaded ifTrue:[
  7570                             nameSpaceGlobal isLoaded ifTrue:[
  7571 				(nameSpaceGlobal privateClassesAt:varName asSymbol) isNil ifTrue:[
  7571                                 (nameSpaceGlobal privateClassesAt:varName asSymbol) isNil ifTrue:[
  7572 				    (Smalltalk at:rawName asSymbol) notNil ifTrue:[
  7572                                     (Smalltalk at:rawName asSymbol) notNil ifTrue:[
  7573 					self warning:('Possible name clash (global: ' , rawName , ' vs. private: ' , (nameSpace , '::', varName) , ') - assume globl.')
  7573                                         self warning:('Possible name clash (global: ' , rawName , ' vs. private: ' , (nameSpace , '::', varName) , ') - assume globl.')
  7574 					     position:pos1 to:source position "tokenPosition-1".
  7574                                              position:pos1 to:source position "tokenPosition-1".
  7575 					globlName := rawName asSymbol.
  7575                                         globlName := rawName asSymbol.
  7576 				    ] ifFalse:[
  7576                                     ] ifFalse:[
  7577 					self warning:('no private class: ' , varName allBold , ' in class: ' , nameSpace)
  7577                                         self warning:('no private class: ' , varName allBold , ' in class: ' , nameSpace)
  7578 					     position:pos1 to:source position "tokenPosition-1".
  7578                                              position:pos1 to:source position "tokenPosition-1".
  7579 "/                                        self parseError:('no private class: ' , name , ' in class: ' , nameSpace)  position:pos to:tokenPosition-1.
  7579 "/                                        self parseError:('no private class: ' , name , ' in class: ' , nameSpace)  position:pos to:tokenPosition-1.
  7580 				    ]
  7580                                     ]
  7581 				] ifFalse:[
  7581                                 ] ifFalse:[
  7582 				    "/ reference to a private class
  7582                                     "/ reference to a private class
  7583 				    (classToCompileFor notNil and:[nameSpaceGlobal ~~ classToCompileFor theNonMetaclass]) ifTrue:[
  7583                                     (classToCompileFor notNil and:[nameSpaceGlobal ~~ classToCompileFor theNonMetaclass]) ifTrue:[
  7584 					self classToCompileFor notNil ifTrue:[
  7584                                         self classToCompileFor notNil ifTrue:[
  7585 					    self isDoIt ifFalse:[
  7585                                             self isDoIt ifFalse:[
  7586 						parserFlags warnAboutReferenceToPrivateClass ifTrue:[
  7586                                                 parserFlags warnAboutReferenceToPrivateClass ifTrue:[
  7587 						    self warning:('Referring to private class ''' , varName allBold , ''' here.')
  7587                                                     self warning:('Referring to private class ''' , varName allBold , ''' here.')
  7588 							 doNotShowAgainAction:[ ParserFlags warnAboutReferenceToPrivateClass:false.
  7588                                                          doNotShowAgainAction:[ ParserFlags warnAboutReferenceToPrivateClass:false.
  7589 										parserFlags warnAboutReferenceToPrivateClass:false. ]
  7589                                                                                 parserFlags warnAboutReferenceToPrivateClass:false. ]
  7590 							 position:pos1 to:source position " tokenPosition-1".
  7590                                                          position:pos1 to:source position " tokenPosition-1".
  7591 						].
  7591                                                 ].
  7592 						Tools::ToDoListBrowser notNil ifTrue:[
  7592                                                 Tools::ToDoListBrowser notNil ifTrue:[
  7593 						    self
  7593                                                     self
  7594 							notifyTodo:('Referring to private class ''' , varName allBold , ''' here.') position:pos1
  7594                                                         notifyTodo:('Referring to private class ''' , varName allBold , ''' here.') position:pos1
  7595 							className:(self classToCompileFor name) selector:selector
  7595                                                         className:(self classToCompileFor name) selector:selector
  7596 							severity:#warning priority:#medium
  7596                                                         severity:#warning priority:#medium
  7597 							equalityParameter:nil
  7597                                                         equalityParameter:nil
  7598 							checkAction:nil.
  7598                                                         checkAction:nil.
  7599 						].
  7599                                                 ].
  7600 					    ].
  7600                                             ].
  7601 					].
  7601                                         ].
  7602 				    ]
  7602                                     ]
  7603 				].
  7603                                 ].
  7604 			    ]
  7604                             ]
  7605 			]
  7605                         ]
  7606 		    ].
  7606                     ].
  7607 		].
  7607                 ].
  7608 		pos2 := source position.
  7608                 pos2 := source position.
  7609 		self nextToken.
  7609                 self nextToken.
  7610 	    ].
  7610             ].
  7611 	    var := VariableNode globalNamed:globlName.
  7611             var := VariableNode globalNamed:globlName.
  7612 	    var startPosition: pos1 endPosition: pos2.
  7612             var startPosition: pos1 endPosition: pos2.
  7613 	    parseForCode ifFalse:[self rememberGlobalUsed:globlName].
  7613             parseForCode ifFalse:[self rememberGlobalUsed:globlName].
  7614 	].
  7614         ].
  7615 	self markVariable:var from:pos1 to:pos1 + rawName size - 1 assigned:false.
  7615         self markVariable:var from:pos1 to:pos1 + rawName size - 1 assigned:false.
  7616     ].
  7616     ].
  7617 
  7617 
  7618     var == #Error ifTrue:[
  7618     var == #Error ifTrue:[
  7619 	^ #Error
  7619         ^ #Error
  7620     ].
  7620     ].
  7621 
  7621 
  7622 "/    errorFlag ~~ true ifTrue:[
  7622 "/    errorFlag ~~ true ifTrue:[
  7623 "/        self markVariable:var from:pos1 to:pos1 + varName size - 1.
  7623 "/        self markVariable:var from:pos1 to:pos1 + varName size - 1.
  7624 "/    ].
  7624 "/    ].
  7625     (ignoreErrors or:[parseForCode not and:[ignoreWarnings]]) ifTrue:[
  7625     (ignoreErrors or:[parseForCode not and:[ignoreWarnings]]) ifTrue:[
  7626 	errorFlag := false.
  7626         errorFlag := false.
  7627     ].
  7627     ].
  7628 
  7628 
  7629     ((tokenType ~~ $_) and:[tokenType ~~ #':=']) ifTrue:[
  7629     ((tokenType ~~ $_) and:[tokenType ~~ #':=']) ifTrue:[
  7630 	parseForCode ifFalse:[
  7630         parseForCode ifFalse:[
  7631 	    var isInstanceVariable ifTrue:[ self rememberInstVarRead:var name].
  7631             var isInstanceVariable ifTrue:[ self rememberInstVarRead:var name].
  7632 	    var isClassVariable ifTrue:[ self rememberClassVarRead:var name].
  7632             var isClassVariable ifTrue:[ self rememberClassVarRead:var name].
  7633 	    var isPoolVariable ifTrue:[ self rememberPoolVarRead:var name].
  7633             var isPoolVariable ifTrue:[ self rememberPoolVarRead:var name].
  7634 	    var isGlobalVariable ifTrue:[ self rememberGlobalRead:var name].
  7634             var isGlobalVariable ifTrue:[ self rememberGlobalRead:var name].
  7635 	].
  7635         ].
  7636 	^ var
  7636         ^ var
  7637     ].
  7637     ].
  7638 
  7638 
  7639     "/ assignment...
  7639     "/ assignment...
  7640 
  7640 
  7641     (usedGlobals notNil and:[usedGlobals includes:(Smalltalk undeclaredPrefix,var name)]) ifFalse:[
  7641     (usedGlobals notNil and:[usedGlobals includes:(Smalltalk undeclaredPrefix,var name)]) ifFalse:[
  7642 	self markAssignedVariable:var from:pos1 to:pos1 + var name size - 1.
  7642         self markAssignedVariable:var from:pos1 to:pos1 + var name size - 1.
  7643     ].
  7643     ].
  7644 
  7644 
  7645     "/ careful: it could already be an implicit self send
  7645     "/ careful: it could already be an implicit self send
  7646     parserFlags implicitSelfSends ifTrue:[
  7646     parserFlags implicitSelfSends ifTrue:[
  7647 	var isMessage ifTrue:[
  7647         var isMessage ifTrue:[
  7648 	    self nextToken.
  7648             self nextToken.
  7649 	    expr := self expression.
  7649             expr := self expression.
  7650 	    self isSyntaxHighlighter ifFalse:[
  7650             self isSyntaxHighlighter ifFalse:[
  7651 		(errorFlag or:[expr == #Error]) ifTrue:[^ #Error].
  7651                 (errorFlag or:[expr == #Error]) ifTrue:[^ #Error].
  7652 	    ].
  7652             ].
  7653 	    ^ MessageNode receiver:(self selfNode) selector:('__' , varName , ':') asSymbol arg:expr.
  7653             ^ MessageNode receiver:(self selfNode) selector:('__' , varName) asMutator arg:expr.
  7654 	].
  7654         ].
  7655     ].
  7655     ].
  7656 
  7656 
  7657     assignmentAllowed := true.
  7657     assignmentAllowed := true.
  7658 
  7658 
  7659     (var ~~ #Error) ifTrue:[
  7659     (var ~~ #Error) ifTrue:[
  7660 	t := var type.
  7660         t := var type.
  7661 	t == #MethodVariable ifTrue:[
  7661         t == #MethodVariable ifTrue:[
  7662 	    self rememberLocalModified:var name.
  7662             self rememberLocalModified:var name.
  7663 	] ifFalse:[ (t == #InstanceVariable) ifTrue:[
  7663         ] ifFalse:[ (t == #InstanceVariable) ifTrue:[
  7664 	    varName := self classesInstVarNames at:(var index).
  7664             varName := self classesInstVarNames at:(var index).
  7665 
  7665 
  7666 	    classToCompileFor isMeta ifTrue:[
  7666             classToCompileFor isMeta ifTrue:[
  7667 		"/ ca once assigned to "name" on the class side and wondered what happened to his class ...
  7667                 "/ ca once assigned to "name" on the class side and wondered what happened to his class ...
  7668 		"/ (not really a beginners bug, but may happen as a typo or missing local variable;
  7668                 "/ (not really a beginners bug, but may happen as a typo or missing local variable;
  7669 		"/  and is hard to track down later)
  7669                 "/  and is hard to track down later)
  7670 		ignoreWarnings ifFalse:[
  7670                 ignoreWarnings ifFalse:[
  7671 		    parserFlags warnings ifTrue:[
  7671                     parserFlags warnings ifTrue:[
  7672 			parserFlags warnCommonMistakes ifTrue:[
  7672                         parserFlags warnCommonMistakes ifTrue:[
  7673 			    (classToCompileFor isSubclassOf:Class) ifTrue:[
  7673                             (classToCompileFor isSubclassOf:Class) ifTrue:[
  7674 				(Class allInstVarNames includes:(var name)) ifTrue:[
  7674                                 (Class allInstVarNames includes:(var name)) ifTrue:[
  7675 				    self warning:'assignment to a classInstanceVariable\(see hierarchy of "Class")' withCRs position:pos1 to:pos2.
  7675                                     self warning:'assignment to a classInstanceVariable\(see hierarchy of "Class")' withCRs position:pos1 to:pos2.
  7676 				]
  7676                                 ]
  7677 			    ]
  7677                             ]
  7678 			]
  7678                         ]
  7679 		    ].
  7679                     ].
  7680 		].
  7680                 ].
  7681 	    ].
  7681             ].
  7682 
  7682 
  7683 	    parseForCode ifFalse:[
  7683             parseForCode ifFalse:[
  7684 		self rememberInstVarModified:varName
  7684                 self rememberInstVarModified:varName
  7685 	    ]
  7685             ]
  7686 	] ifFalse:[ (t == #ClassVariable) ifTrue:[
  7686         ] ifFalse:[ (t == #ClassVariable) ifTrue:[
  7687 	    varName := var name.
  7687             varName := var name.
  7688 	    varName := varName copyFrom:((varName indexOf:$:) + 1).
  7688             varName := varName copyFrom:((varName indexOf:$:) + 1).
  7689 	    parseForCode ifFalse:[
  7689             parseForCode ifFalse:[
  7690 		self rememberClassVarModified:varName
  7690                 self rememberClassVarModified:varName
  7691 	    ]
  7691             ]
  7692 	] ifFalse:[ (t == #GlobalVariable) ifTrue:[
  7692         ] ifFalse:[ (t == #GlobalVariable) ifTrue:[
  7693 	    (cls := Smalltalk classNamed:var name) notNil ifTrue:[
  7693             (cls := Smalltalk classNamed:var name) notNil ifTrue:[
  7694 		cls name = var name ifTrue:[
  7694                 cls name = var name ifTrue:[
  7695 		    self warning:'assignment to global which refers to a class' position:pos1 to:pos2.
  7695                     self warning:'assignment to global which refers to a class' position:pos1 to:pos2.
  7696 		]
  7696                 ]
  7697 	    ].
  7697             ].
  7698 	    parseForCode ifFalse:[
  7698             parseForCode ifFalse:[
  7699 		self rememberGlobalModified:var name
  7699                 self rememberGlobalModified:var name
  7700 	    ]
  7700             ]
  7701 	] ifFalse:[
  7701         ] ifFalse:[
  7702 	    (t == #PrivateClass) ifTrue:[
  7702             (t == #PrivateClass) ifTrue:[
  7703 		assignmentAllowed := false.
  7703                 assignmentAllowed := false.
  7704 		self parseError:'assignment to private class' position:pos1 to:pos2.
  7704                 self parseError:'assignment to private class' position:pos1 to:pos2.
  7705 	    ] ifFalse:[ (t == #MethodArg) ifTrue:[
  7705             ] ifFalse:[ (t == #MethodArg) ifTrue:[
  7706 		(assignmentAllowed := parserFlags allowAssignmentToMethodArgument) ifTrue:[
  7706                 (assignmentAllowed := parserFlags allowAssignmentToMethodArgument) ifTrue:[
  7707 		    parserFlags warnAssignmentToMethodArgument ifTrue:[
  7707                     parserFlags warnAssignmentToMethodArgument ifTrue:[
  7708 			DoNotShowCompilerWarningAgainActionQuery handle:[:ex |
  7708                         DoNotShowCompilerWarningAgainActionQuery handle:[:ex |
  7709 			    parserFlags warnAssignmentToMethodArgument:false.
  7709                             parserFlags warnAssignmentToMethodArgument:false.
  7710 			    parserFlags warnAssignmentToMethodArgument:false.
  7710                             parserFlags warnAssignmentToMethodArgument:false.
  7711 			    ex proceed.
  7711                             ex proceed.
  7712 			] do:[
  7712                         ] do:[
  7713 			    self warning:'assignment to method argument.\\Not all Smalltalk dialects allow this.' withCRs position:pos1 to:pos2.
  7713                             self warning:'assignment to method argument.\\Not all Smalltalk dialects allow this.' withCRs position:pos1 to:pos2.
  7714 			]
  7714                         ]
  7715 		    ]
  7715                     ]
  7716 		] ifFalse:[
  7716                 ] ifFalse:[
  7717 		    DoNotShowCompilerWarningAgainActionQuery handle:[:ex |
  7717                     DoNotShowCompilerWarningAgainActionQuery handle:[:ex |
  7718 			parserFlags allowAssignmentToMethodArgument:true.
  7718                         parserFlags allowAssignmentToMethodArgument:true.
  7719 			ParserFlags allowAssignmentToMethodArgument:true.
  7719                         ParserFlags allowAssignmentToMethodArgument:true.
  7720 			ex proceed.
  7720                         ex proceed.
  7721 		    ] do:[
  7721                     ] do:[
  7722 			self parseError:'assignment to method argument.' withCRs position:pos1 to:pos2.
  7722                         self parseError:'assignment to method argument.' withCRs position:pos1 to:pos2.
  7723 			errorFlag := false. "ok, user wants it - so he'll get it"
  7723                         errorFlag := false. "ok, user wants it - so he'll get it"
  7724 			assignmentAllowed := true.  "/ if proceeded
  7724                         assignmentAllowed := true.  "/ if proceeded
  7725 		    ].
  7725                     ].
  7726 		]
  7726                 ]
  7727 	    ] ifFalse:[ (t == #BlockArg) ifTrue:[
  7727             ] ifFalse:[ (t == #BlockArg) ifTrue:[
  7728 		(assignmentAllowed := parserFlags allowAssignmentToBlockArgument) ifTrue:[
  7728                 (assignmentAllowed := parserFlags allowAssignmentToBlockArgument) ifTrue:[
  7729 		    parserFlags warnAssignmentToBlockArgument ifTrue:[
  7729                     parserFlags warnAssignmentToBlockArgument ifTrue:[
  7730 			DoNotShowCompilerWarningAgainActionQuery handle:[:ex |
  7730                         DoNotShowCompilerWarningAgainActionQuery handle:[:ex |
  7731 			    parserFlags warnAssignmentToBlockArgument:false.
  7731                             parserFlags warnAssignmentToBlockArgument:false.
  7732 			    parserFlags warnAssignmentToBlockArgument:false.
  7732                             parserFlags warnAssignmentToBlockArgument:false.
  7733 			    ex proceed.
  7733                             ex proceed.
  7734 			] do:[
  7734                         ] do:[
  7735 			    self warning:'assignment to block argument.\\Not all Smalltalk dialects allow this.' withCRs position:pos1 to:pos2.
  7735                             self warning:'assignment to block argument.\\Not all Smalltalk dialects allow this.' withCRs position:pos1 to:pos2.
  7736 			]
  7736                         ]
  7737 		    ].
  7737                     ].
  7738 		] ifFalse:[
  7738                 ] ifFalse:[
  7739 		    DoNotShowCompilerWarningAgainActionQuery handle:[:ex |
  7739                     DoNotShowCompilerWarningAgainActionQuery handle:[:ex |
  7740 			parserFlags allowAssignmentToBlockArgument:true.
  7740                         parserFlags allowAssignmentToBlockArgument:true.
  7741 			ParserFlags allowAssignmentToBlockArgument:true.
  7741                         ParserFlags allowAssignmentToBlockArgument:true.
  7742 			ex proceed.
  7742                         ex proceed.
  7743 		    ] do:[
  7743                     ] do:[
  7744 			self parseError:'assignment to block argument.' position:pos1 to:pos2.
  7744                         self parseError:'assignment to block argument.' position:pos1 to:pos2.
  7745 		    ]
  7745                     ]
  7746 		].
  7746                 ].
  7747 		errorFlag := false. "ok, user wants it - so he'll get it"
  7747                 errorFlag := false. "ok, user wants it - so he'll get it"
  7748 		assignmentAllowed := true.  "/ if proceeded
  7748                 assignmentAllowed := true.  "/ if proceeded
  7749 	    ] ifFalse:[ (t == #PoolVariable) ifTrue:[
  7749             ] ifFalse:[ (t == #PoolVariable) ifTrue:[
  7750 		self isDoIt ifTrue:[
  7750                 self isDoIt ifTrue:[
  7751 		    self warning:'assignment to pool variable.\\Not all Smalltalk dialects allow this.' withCRs position:pos1 to:pos2.
  7751                     self warning:'assignment to pool variable.\\Not all Smalltalk dialects allow this.' withCRs position:pos1 to:pos2.
  7752 		    assignmentAllowed := true.
  7752                     assignmentAllowed := true.
  7753 		] ifFalse:[
  7753                 ] ifFalse:[
  7754 		    (assignmentAllowed := parserFlags allowAssignmentToPoolVariable) ifTrue:[
  7754                     (assignmentAllowed := parserFlags allowAssignmentToPoolVariable) ifTrue:[
  7755 			parserFlags warnAssignmentToPoolVariable ifTrue:[
  7755                         parserFlags warnAssignmentToPoolVariable ifTrue:[
  7756 			    DoNotShowCompilerWarningAgainActionQuery handle:[:ex |
  7756                             DoNotShowCompilerWarningAgainActionQuery handle:[:ex |
  7757 				parserFlags warnAssignmentToPoolVariable:false.
  7757                                 parserFlags warnAssignmentToPoolVariable:false.
  7758 				ParserFlags warnAssignmentToPoolVariable:false.
  7758                                 ParserFlags warnAssignmentToPoolVariable:false.
  7759 				ex proceed.
  7759                                 ex proceed.
  7760 			    ] do:[
  7760                             ] do:[
  7761 				self warning:'assignment to pool variable.\\Not all Smalltalk dialects allow this.' withCRs position:pos1 to:pos2.
  7761                                 self warning:'assignment to pool variable.\\Not all Smalltalk dialects allow this.' withCRs position:pos1 to:pos2.
  7762 			    ]
  7762                             ]
  7763 			]
  7763                         ]
  7764 		    ] ifFalse:[
  7764                     ] ifFalse:[
  7765 			DoNotShowCompilerWarningAgainActionQuery handle:[:ex |
  7765                         DoNotShowCompilerWarningAgainActionQuery handle:[:ex |
  7766 			    parserFlags allowAssignmentToPoolVariable:true.
  7766                             parserFlags allowAssignmentToPoolVariable:true.
  7767 			    ParserFlags allowAssignmentToPoolVariable:true.
  7767                             ParserFlags allowAssignmentToPoolVariable:true.
  7768 			    ex proceed.
  7768                             ex proceed.
  7769 			] do:[
  7769                         ] do:[
  7770 			    self parseError:'assignment to pool variable' position:pos1 to:pos2.
  7770                             self parseError:'assignment to pool variable' position:pos1 to:pos2.
  7771 			].
  7771                         ].
  7772 			errorFlag := false. "ok, user wants it - so he'll get it"
  7772                         errorFlag := false. "ok, user wants it - so he'll get it"
  7773 			assignmentAllowed := true. "/ if proceeded
  7773                         assignmentAllowed := true. "/ if proceeded
  7774 			parseForCode ifFalse:[
  7774                         parseForCode ifFalse:[
  7775 			    self rememberPoolVarModified:var name
  7775                             self rememberPoolVarModified:var name
  7776 			]
  7776                         ]
  7777 		    ].
  7777                     ].
  7778 		]
  7778                 ]
  7779 	    ]]]]]]]
  7779             ]]]]]]]
  7780 	].
  7780         ].
  7781     ].
  7781     ].
  7782 
  7782 
  7783     lnr := tokenLineNr.
  7783     lnr := tokenLineNr.
  7784 
  7784 
  7785     self nextToken.
  7785     self nextToken.
  7795     "/   var messageSend
  7795     "/   var messageSend
  7796     "/
  7796     "/
  7797     "/   does not what a beginner might think.
  7797     "/   does not what a beginner might think.
  7798 
  7798 
  7799     self isSyntaxHighlighter ifTrue:[
  7799     self isSyntaxHighlighter ifTrue:[
  7800 	(expr == #Error) ifTrue:[^ #Error].
  7800         (expr == #Error) ifTrue:[^ #Error].
  7801     ] ifFalse:[
  7801     ] ifFalse:[
  7802 	(errorFlag or:[expr == #Error]) ifTrue:[^ #Error].
  7802         (errorFlag or:[expr == #Error]) ifTrue:[^ #Error].
  7803 
  7803 
  7804 	(ignoreWarnings not
  7804         (ignoreWarnings not
  7805 	and:[ parserFlags warnings ]) ifTrue:[
  7805         and:[ parserFlags warnings ]) ifTrue:[
  7806 	    parserFlags warnCommonMistakes ifTrue:[
  7806             parserFlags warnCommonMistakes ifTrue:[
  7807 		(expr ~~ #Error and:[expr isSuper]) ifTrue:[
  7807                 (expr ~~ #Error and:[expr isSuper]) ifTrue:[
  7808 		    self warning:'followup messageSends to "' , var name , '" will have normal send semantics\(i.e. NO super- or here-sends). Use self to avoid confusion.' withCRs position:pos1 to:pos2.
  7808                     self warning:'followup messageSends to "' , var name , '" will have normal send semantics\(i.e. NO super- or here-sends). Use self to avoid confusion.' withCRs position:pos1 to:pos2.
  7809 		].
  7809                 ].
  7810 	    ].
  7810             ].
  7811 
  7811 
  7812 	    expr isVariable ifTrue:[
  7812             expr isVariable ifTrue:[
  7813 		expr name = var name ifTrue:[
  7813                 expr name = var name ifTrue:[
  7814 		    self warning:('useless assignment to "' , var name, '"' ) position:pos1 to:pos2-1.
  7814                     self warning:('useless assignment to "' , var name, '"' ) position:pos1 to:pos2-1.
  7815 		].
  7815                 ].
  7816 	    ].
  7816             ].
  7817 	].
  7817         ].
  7818     ].
  7818     ].
  7819     assignmentAllowed ifTrue:[
  7819     assignmentAllowed ifTrue:[
  7820 	node := AssignmentNode variable:var expression:expr.
  7820         node := AssignmentNode variable:var expression:expr.
  7821 	parserFlags fullLineNumberInfo ifTrue:[node lineNumber:lnr].
  7821         parserFlags fullLineNumberInfo ifTrue:[node lineNumber:lnr].
  7822 	node := self assignmentRewriteHookFor:node.
  7822         node := self assignmentRewriteHookFor:node.
  7823     ] ifFalse:[
  7823     ] ifFalse:[
  7824 	self parseError:('assignment to "' , var name, '" suppressed' ) position:pos1 to:pos2-1.
  7824         self parseError:('assignment to "' , var name, '" suppressed' ) position:pos1 to:pos2-1.
  7825 	node := expr.
  7825         node := expr.
  7826     ].
  7826     ].
  7827     ^ node
  7827     ^ node
  7828 
  7828 
  7829     "Modified: / 20-08-2011 / 23:32:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  7829     "Modified: / 20-08-2011 / 23:32:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  7830     "Modified: / 05-10-2011 / 15:36:55 / az"
  7830     "Modified: / 05-10-2011 / 15:36:55 / az"
  8961 
  8961 
  8962     |type flagValue|
  8962     |type flagValue|
  8963 
  8963 
  8964     type := token.
  8964     type := token.
  8965     type ~= 'pragma:' ifTrue:[
  8965     type ~= 'pragma:' ifTrue:[
  8966 	self parseError:'pragma expected'.
  8966         self parseError:'pragma expected'.
  8967 	^ #self
  8967         ^ #self
  8968     ].
  8968     ].
  8969 
  8969 
  8970     self nextToken.
  8970     self nextToken.
  8971     ((token = '+') or:[token = '-']) ifTrue:[
  8971     ((token = '+') or:[token = '-']) ifTrue:[
  8972 	flagValue := (token = '+').
  8972         flagValue := (token = '+').
  8973 	self nextToken.
  8973         self nextToken.
  8974 	(tokenType == #Identifier) ifTrue:[
  8974         (tokenType == #Identifier) ifTrue:[
  8975 	    token = 'arrayIndexSyntaxExtension' ifTrue:[
  8975             token = 'arrayIndexSyntaxExtension' ifTrue:[
  8976 		parserFlags perform:('allow',token asUppercaseFirst,':') asSymbol with:flagValue.
  8976                 parserFlags perform:('allow',token asUppercaseFirst) asMutator with:flagValue.
  8977 		self nextToken.
  8977                 self nextToken.
  8978 		self checkForClosingAngle.
  8978                 self checkForClosingAngle.
  8979 		^ self.
  8979                 ^ self.
  8980 	    ].
  8980             ].
  8981 	].
  8981         ].
  8982 	self breakPoint:#cg.
  8982         self breakPoint:#cg.
  8983 	self parseError:'unknown pragma'.
  8983         self parseError:'unknown pragma'.
  8984 	^  self
  8984         ^  self
  8985     ].
  8985     ].
  8986 
  8986 
  8987     self parseError:'+/- expected'.
  8987     self parseError:'+/- expected'.
  8988     ^ self
  8988     ^ self
  8989 !
  8989 !
 11825 ! !
 11825 ! !
 11826 
 11826 
 11827 !Parser class methodsFor:'documentation'!
 11827 !Parser class methodsFor:'documentation'!
 11828 
 11828 
 11829 version
 11829 version
 11830     ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.813 2014-03-05 16:25:03 cg Exp $'
 11830     ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.814 2014-03-05 22:12:46 cg Exp $'
 11831 !
 11831 !
 11832 
 11832 
 11833 version_CVS
 11833 version_CVS
 11834     ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.813 2014-03-05 16:25:03 cg Exp $'
 11834     ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.814 2014-03-05 22:12:46 cg Exp $'
 11835 !
 11835 !
 11836 
 11836 
 11837 version_SVN
 11837 version_SVN
 11838     ^ '$ Id $'
 11838     ^ '$ Id $'
 11839 ! !
 11839 ! !