--- a/Scanner.st Mon Feb 20 10:10:05 2006 +0100
+++ b/Scanner.st Mon Feb 20 10:48:02 2006 +0100
@@ -1208,14 +1208,12 @@
!
notifyWarning:aMessage doNotShowAgainAction:doNotShowAgainAction position:position to:endPos
- "notify requestor of an warning - if there is no requestor
- put it on the transcript.
- Return the result passed back by the requestor."
+ "notify requestor of an warning - if there is no requestor, just ignore it.
+ Return the result passed back from the requestor (or false, if there is none)."
|answer|
ignoreWarnings ifTrue:[ ^ false ].
-
requestor isNil ifTrue:[
"/ self showErrorMessage:aMessage position:position.
^ false
@@ -1375,7 +1373,7 @@
"warn about a possible incompatibility with other ST systems"
ignoreWarnings ifFalse:[
- parserFlags warnPossibleIncompatibilities ifTrue:[
+ parserFlags warnPossibleIncompatibilities ifTrue:[
self
warning:('Possible incompatibility.\\' , msg) withCRs
doNotShowAgainAction:[ ParserFlags warnPossibleIncompatibilities:false ]
@@ -1675,14 +1673,14 @@
(string = 'super') ifTrue:[tokenType := #Super. ^true]
].
(firstChar == $n) ifTrue:[
- (string = 'nil') ifTrue:[tokenType := #Nil. ^true]
+ (string = 'nil') ifTrue:[tokenType := #Nil. tokenValue := nil. ^true]
].
(firstChar == $t) ifTrue:[
- (string = 'true') ifTrue:[tokenType := #True. ^true].
+ (string = 'true') ifTrue:[tokenType := #True. tokenValue := true. ^true].
(string = 'thisContext') ifTrue:[tokenType := #ThisContext. ^true]
].
(firstChar == $f) ifTrue:[
- (string = 'false') ifTrue:[tokenType := #False. ^true]
+ (string = 'false') ifTrue:[tokenType := #False. tokenValue := false. ^true]
].
^ false
@@ -1735,20 +1733,20 @@
much like character escapes in C-literals;
expands:
- `n newLine
- `r return
- `t tab
- `b backspace
- `f formfeed
- `g bell
-
- `` backTick
- ` ...` ignored
- `xNN hexCharacter
- `xNN hexCharacter
+ \n newLine
+ \r return
+ \t tab
+ \b backspace
+ \f formfeed
+ \g bell
+
+ \\ backSlash
+ \ ...\ (backslash-separator) ignored up to next backslash
+ \xNN hexCharacter
+ \uNNNN hex UnicodeCharacter
"
- |ascii nextChar|
+ |ascii nextChar fetchNext|
aCharacter == $n ifTrue:[^ Character nl].
aCharacter == $r ifTrue:[^ Character return].
@@ -1756,10 +1754,10 @@
aCharacter == $b ifTrue:[^ Character backspace].
aCharacter == $f ifTrue:[^ Character ff].
aCharacter == $g ifTrue:[^ Character bell].
- aCharacter == $` ifTrue:[^ aCharacter].
+ aCharacter == $\ ifTrue:[^ aCharacter].
aCharacter isSeparator ifTrue:[
nextChar := source next.
- [nextChar notNil and:[nextChar ~~ $`]] whileTrue:[
+ [nextChar notNil and:[nextChar ~~ $\]] whileTrue:[
(nextChar == Character cr) ifTrue:[
lineNr := lineNr + 1
].
@@ -1768,31 +1766,23 @@
^ nil
].
- aCharacter == $x ifTrue:[
- ascii := 0.
- nextChar := source next.
- (nextChar notNil and:[nextChar isDigitRadix:16]) ifTrue:[
- ascii := nextChar digitValue.
- nextChar := source next.
- (nextChar notNil and:[nextChar isDigitRadix:16]) ifTrue:[
- ascii := (ascii bitShift:4) bitOr:nextChar digitValue.
- ]
- ].
- ^ Character value:ascii.
- ].
- aCharacter == $0 ifTrue:[
- ascii := 0.
- nextChar := source next.
- (nextChar notNil and:[nextChar isDigitRadix:8]) ifTrue:[
- ascii := nextChar digitValue.
- nextChar := source next.
- (nextChar notNil and:[nextChar isDigitRadix:8]) ifTrue:[
- ascii := (ascii bitShift:3) bitOr:nextChar digitValue.
+ (aCharacter == $x or:[ aCharacter == $u ]) ifTrue:[
+ fetchNext :=
+ [
nextChar := source next.
- (nextChar notNil and:[nextChar isDigitRadix:8]) ifTrue:[
- ascii := (ascii bitShift:3) bitOr:nextChar digitValue.
- ]
- ]
+ (nextChar notNil and:[nextChar isDigitRadix:16]) ifFalse:[
+ self syntaxError:'hex digit expected in string literal'
+ position:(source position1Based-1) to:(source position1Based-1).
+ ].
+ nextChar digitValue
+ ].
+
+ ascii := fetchNext value.
+ ascii := (ascii bitShift:4) bitOr:(fetchNext value).
+
+ (aCharacter == $u ) ifTrue:[
+ ascii := (ascii bitShift:4) bitOr:(fetchNext value).
+ ascii := (ascii bitShift:4) bitOr:(fetchNext value).
].
^ Character value:ascii.
].
@@ -1802,11 +1792,15 @@
ParserFlags allowExtendedSTXSyntax:true
"
"
- 'hello`nworld'
- 'hello`x08world'
- 'hello`
- `world'
+ 'hello\nworld'
+ 'hello\x0Dworld'
+ 'hello\x08world'
+ 'hello\
+ \world'
"
+ "
+ ParserFlags allowExtendedSTXSyntax:false
+ "
!
ignoreErrors
@@ -2599,7 +2593,7 @@
]
] ifFalse:[
parserFlags allowExtendedSTXSyntax == true ifTrue:[
- (nextChar == $`) ifTrue:[
+ (nextChar == $\) ifTrue:[
peekChar := source peekOrNil.
peekChar notNil ifTrue:[
source next.
@@ -2626,7 +2620,6 @@
nextChar := source next
]
].
- self markStringFrom:pos to:source position1Based-1.
tokenValue := token := string copyTo:(index - 1).
tokenType := #String.
@@ -3045,7 +3038,7 @@
!Scanner class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.214 2006-02-17 15:23:53 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.215 2006-02-20 09:48:02 cg Exp $'
! !
Scanner initialize!