--- a/MessageNode.st Tue Mar 23 13:41:07 2021 +0000
+++ b/MessageNode.st Tue Jun 29 20:39:06 2021 +0100
@@ -1,5 +1,6 @@
"
COPYRIGHT (c) 1989 by Claus Gittinger
+ COPYRIGHT (c) 2021 LabWare
All Rights Reserved
This software is furnished under a license and may be used
@@ -26,6 +27,7 @@
copyright
"
COPYRIGHT (c) 1989 by Claus Gittinger
+ COPYRIGHT (c) 2021 LabWare
All Rights Reserved
This software is furnished under a license and may be used
@@ -1809,8 +1811,11 @@
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler
|arg1 rightExpr pos1|
- (selector == #and:
- or:[selector == #or:]) ifTrue:[
+ "JV@2021-05-19: No, do not optimize `^ x and: y` because
+ this prevent one from implementing bool-like objects."
+
+ "/(selector == #and: or:[selector == #or:]) ifTrue:[
+ false ifTrue: [
arg1 := argArray at:1.
"/ for now:
@@ -1874,6 +1879,8 @@
inBlock:b
lineNumber:lineNrOrNil
for:aCompiler
+
+ "Modified (format): / 19-05-2021 / 11:44:44 / Jan Vrany <jan.vrany@labware.com>"
!
codeIfElseOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
@@ -3540,6 +3547,11 @@
^ '$Header$'
!
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+!
+
version_SVN
^ '$ Id $'
! !
--- a/Parser.st Tue Mar 23 13:41:07 2021 +0000
+++ b/Parser.st Tue Jun 29 20:39:06 2021 +0100
@@ -1,7 +1,7 @@
"
COPYRIGHT (c) 1989 by Claus Gittinger
COPYRIGHT (c) 2015-2017 Jan Vrany
- COPYRIGHT (c) 2020 LabWare
+ COPYRIGHT (c) 2020-2021 LabWare
All Rights Reserved
This software is furnished under a license and may be used
@@ -40,7 +40,7 @@
variableTypeOfLastCorrectAction usedPoolVars readPoolVars
modifiedPoolVars warnings didWarnAboutSTXExtensions
annotationStartPosition annotationEndPosition autoDefineVariables
- initExpressionsForLocals'
+ initExpressionsForLocals unknownVariableResolver'
classVariableNames:'PrevClass PrevInstVarNames PrevClassVarNames
PrevClassInstVarNames LazyCompilation FoldConstants
LineNumberInfo SuppressDoItCompilation ParseErrorSignal
@@ -175,7 +175,7 @@
"
COPYRIGHT (c) 1989 by Claus Gittinger
COPYRIGHT (c) 2015-2017 Jan Vrany
- COPYRIGHT (c) 2020 LabWare
+ COPYRIGHT (c) 2020-2021 LabWare
All Rights Reserved
This software is furnished under a license and may be used
@@ -2569,6 +2569,34 @@
tree := aTree
!
+unknownVariableResolver
+ "
+ Return an object responsible for resolving unknown variables. See comment
+ io setter #unknownVariableResolver:
+ "
+ ^ unknownVariableResolver
+
+ "Created: / 09-05-2020 / 13:16:19 / cg"
+ "Modified (comment): / 24-06-2021 / 17:31:38 / Jan Vrany <jan.vrany@labware.com>"
+!
+
+unknownVariableResolver: anObject
+ "
+ Set an object responsible for resolving unknown variables, that is, variables
+ which does not resolve to temporary, instvar, class name, pool variable and so on.
+
+ The resolver object must respond to #variableNodeFor:startPosition:endPosition: and
+ must return either nil or an instance of VariableNode.
+
+ Normally there's none - this interface is provided for cases where user wants to
+ provide its own variable bindings - useful when evaluating custom scripts.
+ "
+
+ unknownVariableResolver := anObject
+
+ "Created: / 24-06-2021 / 17:30:57 / Jan Vrany <jan.vrany@labware.com>"
+!
+
warnSTXHereExtensionUsed
^ parserFlags warnSTXHereExtensionUsed
!
@@ -3018,7 +3046,7 @@
]
]
] ifFalse:[
- (mthd isSubclassResponsibility) ifTrue:[
+ (mthd sendsAnySelector:#(#subclassResponsibility #subclassResponsibility: #implementedBySubclass)) ifTrue:[
"methods in abstract classes may send messages to abstract methods in the same class or its instances"
allowed := (cls == classToCompileFor or:[cls class == classToCompileFor]).
allowed ifFalse:[
@@ -3046,7 +3074,7 @@
"/ we need more advanced analysis, if it is sent at all.
].
].
- ] ifFalse:[mthd isObsolete ifTrue:[
+ ] ifFalse:[(mthd askFor: #isObsolete) ifTrue:[
err := 'is deprecated'.
]]
].
@@ -3055,6 +3083,7 @@
"Modified: / 16-07-2017 / 11:28:48 / cg"
"Modified: / 09-10-2017 / 16:17:33 / stefan"
+ "Modified: / 25-06-2021 / 14:06:46 / Jan Vrany <jan.vrany@labware.com>"
!
checkUnusedMethodVars
@@ -10043,7 +10072,12 @@
].
self unknownVariableResolver notNil ifTrue:[
- ^ self unknownVariableResolver variableNodeFor:varName startPosition:tokenPosition endPosition:endPosition
+ | node |
+
+ node := self unknownVariableResolver variableNodeFor:varName startPosition:tokenPosition endPosition:tokenPosition + varName size - 1.
+ node notNil ifTrue: [
+ ^ node
+ ].
].
"/ do not raise parseError here, but instead report it via the old stupid #Error token.
@@ -10056,8 +10090,11 @@
"Modified: / 05-10-2011 / 15:25:20 / az"
"Modified (format): / 04-12-2018 / 11:28:12 / Stefan Vogel"
"Modified: / 08-06-2019 / 18:27:36 / Claus Gittinger"
+ "Modified (format): / 04-12-2018 / 11:28:12 / Stefan Vogel"
+ "Modified: / 08-06-2019 / 18:27:36 / Claus Gittinger"
"Modified: / 16-12-2020 / 16:17:37 / Jan Vrany <jan.vrany@labware.com>"
"Modified: / 09-05-2020 / 13:22:04 / cg"
+ "Modified: / 24-06-2021 / 17:32:22 / Jan Vrany <jan.vrany@labware.com>"
! !
!Parser methodsFor:'parsing-primitives & pragmas'!
@@ -11379,12 +11416,7 @@
"/ ^ selfNode
"Modified: / 19-07-2011 / 17:22:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-unknownVariableResolver
- ^ nil
-
- "Created: / 09-05-2020 / 13:16:19 / cg"
+
! !
!Parser methodsFor:'queries'!
--- a/Scanner.st Tue Mar 23 13:41:07 2021 +0000
+++ b/Scanner.st Tue Jun 29 20:39:06 2021 +0100
@@ -2620,6 +2620,26 @@
^ false
!
+isIdentifierCharacter:nextChar
+ ^ nextChar isLetterOrDigit
+ or:[ (nextChar == $_ and:[parserFlags allowUnderscoreInIdentifier])
+ or:[ (parserFlags allowDollarInIdentifier and:[nextChar == $$ ])
+ or:[ (nextChar == $� and:[ parserFlags allowParagraphInIdentifier])
+ or:[ (parserFlags allowNationalCharactersInIdentifier and:[ nextChar notNil and:[nextChar isNationalLetter]])
+ or:[ false"/(parserFlags allowGreekCharactersInIdentifier and:[ nextChar notNil and:[nextChar isNationalLetter]])
+ ]]]]]
+
+
+ "
+ self new isIdentifierCharacter:$a
+ self new isIdentifierCharacter:$2
+ self new isIdentifierCharacter:$_
+
+ "
+
+ "Created: / 30-04-2021 / 11:54:20 / Jan Vrany <jan.vrany@labware.com>"
+!
+
isSpecialOrExtendedSpecialCharacter:ch
|code charType|
@@ -2692,21 +2712,34 @@
nextCharacter
"a $ has been read - return a character token"
- |nextChar t|
+ | nextChar t|
source next.
nextChar := source next.
nextChar notNil ifTrue:[
- t := nextChar.
- tokenType := #Character.
+ t := nextChar.
+ tokenType := #Character.
+ "/ Following is to allow identifiers to start with $ (dollar)
+ (t isSeparator not and:[parserFlags allowDollarInIdentifier]) ifTrue: [
+ | nextNextChar |
+ nextNextChar := source peek.
+ (nextNextChar notNil and:[self isIdentifierCharacter: nextNextChar]) ifTrue: [
+ self nextIdentifier.
+ tokenType == #Identifier ifTrue: [
+ token := tokenName := '$' , nextChar , token.
+ ].
+ ^ tokenType
+ ].
+ ].
] ifFalse:[
- t := nil.
- tokenType := #EOF
+ t := nil.
+ tokenType := #EOF
].
tokenValue := token := t.
^ tokenType
- "Modified: / 13.5.1998 / 15:09:50 / cg"
+ "Modified: / 13-05-1998 / 15:09:50 / cg"
+ "Modified: / 24-06-2021 / 17:03:51 / Jan Vrany <jan.vrany@labware.com>"
!
nextColonOrAssign
@@ -4436,6 +4469,11 @@
version_CVS
^ '$Header$'
+!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
! !
--- a/SyntaxHighlighter.st Tue Mar 23 13:41:07 2021 +0000
+++ b/SyntaxHighlighter.st Tue Jun 29 20:39:06 2021 +0100
@@ -1,6 +1,7 @@
"
COPYRIGHT (c) 1998 by eXept Software AG
COPYRIGHT (c) 2016-2017 Jan Vrany
+ COPYRIGHT (c) 2021 LabWare
All Rights Reserved
This software is furnished under a license and may be used
@@ -17,7 +18,7 @@
AbstractSyntaxHighlighter subclass:#SyntaxHighlighter
instanceVariableNames:'currentSuperclasses currentSubclasses
cachedLocalIdentifierEmphasis cachedLocalIdentifierColor
- cachedStringEmphasis cachedStringColor unknownVariableResolver'
+ cachedStringEmphasis cachedStringColor'
classVariableNames:''
poolDictionaries:''
category:'System-Compiler'
@@ -29,6 +30,7 @@
"
COPYRIGHT (c) 1998 by eXept Software AG
COPYRIGHT (c) 2016-2017 Jan Vrany
+ COPYRIGHT (c) 2021 LabWare
All Rights Reserved
This software is furnished under a license and may be used
@@ -70,22 +72,16 @@
"Created: / 21-10-2017 / 13:25:14 / cg"
!
+codeAspectMethod
+ ^ #method
+
+ "Created: / 27-07-2012 / 22:01:42 / cg"
+!
+
codeAspectStatements
^ #statements
"Created: / 22-02-2016 / 20:57:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-codeAspectMethod
- ^ #method
-
- "Created: / 27-07-2012 / 22:01:42 / cg"
-! !
-
-!SyntaxHighlighter methodsFor:'accessing'!
-
-unknownVariableResolver
- ^ unknownVariableResolver
! !
!SyntaxHighlighter methodsFor:'initialization'!