--- a/Parser.st Fri Aug 26 00:56:41 2016 +0200
+++ b/Parser.st Fri Aug 26 01:09:06 2016 +0200
@@ -6826,7 +6826,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.
].
@@ -8584,18 +8584,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.
@@ -8615,22 +8617,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.
].