--- a/Parser.st Thu Aug 25 13:28:10 2016 +0100
+++ b/Parser.st Wed Aug 31 22:47:55 2016 +0100
@@ -6794,7 +6794,7 @@
bytes := newArray
].
] ifFalse:[
- self parseError:'invalid ByteArray element' position:pos2 to:tokenPosition - 1
+ self parseError:'invalid ByteArray element:',elem printString position:pos2 to:tokenPosition - 1
].
self nextToken.
].
@@ -8529,6 +8529,8 @@
typedArray:typeSymbol
"parse a typed array's elements.
This is an ST/X extension, which is not supported by other Smalltalk implementations.
+ For now, the support is disabled; enable with:
+ ParserFlags allowSTXExtendedArrayLiterals:true
Typed literal arrays are written in scheme-style as:
#u8( element... ) - unsigned 8-bit bytes (i.e. a regular ByteArray)
#u16( element... ) - unsigned 16-bit shorts (i.e. a WordArray)
@@ -8550,18 +8552,20 @@
|idx containerType container elStream newArray elem pos1 pos2|
- idx := #( #u8 #u16 #u32 #u64
+ idx := #( #u1 #u8 #u16 #u32 #u64
#s8 #s16 #s32 #s64
#f16 #f32 #f64
- #f #d) indexOf:typeSymbol.
+ #f #d #b
+ #B) indexOf:typeSymbol.
idx == 0 ifTrue:[
self parseError:'unsupported array type:',typeSymbol.
].
containerType := #(
- ByteArray WordArray IntegerArray LongIntegerArray
+ BitArray ByteArray WordArray IntegerArray LongIntegerArray
SignedByteArray SignedWordArray SignedIntegerArray SignedLongIntegerArray
HalfFloatArray FloatArray DoubleArray
- FloatArray DoubleArray
+ FloatArray DoubleArray BitArray
+ BooleanArray
) at:idx.
pos1 := tokenPosition.
container := (Smalltalk at:containerType) uninitializedNew:50.
@@ -8581,22 +8585,22 @@
elem := self arrayConstant.
(elem == #Error) ifTrue:[
(tokenType == #EOF) ifTrue:[
- self syntaxError:'unterminated bytearray-constant; '']'' expected'
+ self syntaxError:'unterminated ',typeSymbol,'-array (',containerType,') constant; '']'' expected'
position:pos1 to:tokenPosition
].
^ #Error
].
].
].
- elem isNumber ifFalse:[
- self parseError:'invalid number-array element' position:pos2 to:tokenPosition.
- elem := 0.
+ (container isValidElement:elem) ifFalse:[
+ self parseError:'element is not appropriate for #',typeSymbol,'-array (',containerType,')' position:pos2 to:tokenPosition.
+ elem := container defaultElement.
] ifTrue:[
- (container isValidElement:elem) ifFalse:[
- self parseError:'array element is not appropiate for type of literal array' position:pos2 to:tokenPosition.
- elem := 0.
+ (typeSymbol == #u8 and:[elem < 0]) ifTrue:[
+ self parseError:'element is not appropriate for #',typeSymbol,'-array (',containerType,')' position:pos2 to:tokenPosition.
+ elem := container defaultElement.
].
- ].
+ ].
elStream nextPut:elem.
self nextToken.
].