浏览代码

Added support for multi-dimensional arrays.
Fixed string comparison generation (now uses bbStringCompare).
Fixed semanting order for types (fixes #8).
Improved handling of => and =< operators.
Fixed munged name generation for files using dots for word separators.
License updates.
Added AUTHORS.md

woollybah 11 年之前
父节点
当前提交
08f1993b12
共有 15 个文件被更改,包括 359 次插入98 次删除
  1. 15 0
      AUTHORS.md
  2. 1 3
      COPYING.md
  3. 7 7
      config.bmx
  4. 69 20
      ctranslator.bmx
  5. 22 14
      decl.bmx
  6. 83 11
      expr.bmx
  7. 33 12
      parser.bmx
  8. 7 7
      stmt.bmx
  9. 40 0
      tests/framework/language/arrays_0.bmx
  10. 28 0
      tests/framework/types/global_01.bmx
  11. 22 0
      tests/framework/types/global_02.bmx
  12. 1 0
      tests/mods.conf
  13. 7 7
      toker.bmx
  14. 13 8
      translator.bmx
  15. 11 9
      type.bmx

+ 15 - 0
AUTHORS.md

@@ -0,0 +1,15 @@
+Authors
+=======
+
+Names below are sorted alphabetically.
+
+Author
+------
+
+- Bruce A Henderson <[email protected]>
+
+
+Contributors
+------------
+
+- Ronny Otto

+ 1 - 3
COPYING.md

@@ -1,6 +1,4 @@
-Copyright (c) 2013-2014 Bruce A Henderson & Ronny Otto 
-
-Based on the public domain Monkey "trans" by Mark Sibly
+Copyright (c) 2013-2014 Bruce A Henderson
 
 
 This software is provided 'as-is', without any express or implied
 This software is provided 'as-is', without any express or implied
 warranty. In no event will the authors be held liable for any damages
 warranty. In no event will the authors be held liable for any damages

+ 7 - 7
config.bmx

@@ -1,26 +1,26 @@
-' Copyright (c) 2013-2014 Bruce A Henderson & Ronny Otto 
+' Copyright (c) 2013-2014 Bruce A Henderson
 '
 '
 ' Based on the public domain Monkey "trans" by Mark Sibly
 ' Based on the public domain Monkey "trans" by Mark Sibly
-' 
+'
 ' This software is provided 'as-is', without any express or implied
 ' This software is provided 'as-is', without any express or implied
 ' warranty. In no event will the authors be held liable for any damages
 ' warranty. In no event will the authors be held liable for any damages
 ' arising from the use of this software.
 ' arising from the use of this software.
-' 
+'
 ' Permission is granted to anyone to use this software for any purpose,
 ' Permission is granted to anyone to use this software for any purpose,
 ' including commercial applications, and to alter it and redistribute it
 ' including commercial applications, and to alter it and redistribute it
 ' freely, subject to the following restrictions:
 ' freely, subject to the following restrictions:
-' 
+'
 '    1. The origin of this software must not be misrepresented; you must not
 '    1. The origin of this software must not be misrepresented; you must not
 '    claim that you wrote the original software. If you use this software
 '    claim that you wrote the original software. If you use this software
 '    in a product, an acknowledgment in the product documentation would be
 '    in a product, an acknowledgment in the product documentation would be
 '    appreciated but is not required.
 '    appreciated but is not required.
-' 
+'
 '    2. Altered source versions must be plainly marked as such, and must not be
 '    2. Altered source versions must be plainly marked as such, and must not be
 '    misrepresented as being the original software.
 '    misrepresented as being the original software.
-' 
+'
 '    3. This notice may not be removed or altered from any source
 '    3. This notice may not be removed or altered from any source
 '    distribution.
 '    distribution.
-' 
+'
 SuperStrict
 SuperStrict
 
 
 Import BRL.LinkedList
 Import BRL.LinkedList

+ 69 - 20
ctranslator.bmx

@@ -1,26 +1,26 @@
-' Copyright (c) 2013-2014 Bruce A Henderson & Ronny Otto 
-' 
+' Copyright (c) 2013-2014 Bruce A Henderson
+'
 ' Based on the public domain Monkey "trans" by Mark Sibly
 ' Based on the public domain Monkey "trans" by Mark Sibly
-' 
+'
 ' This software is provided 'as-is', without any express or implied
 ' This software is provided 'as-is', without any express or implied
 ' warranty. In no event will the authors be held liable for any damages
 ' warranty. In no event will the authors be held liable for any damages
 ' arising from the use of this software.
 ' arising from the use of this software.
-' 
+'
 ' Permission is granted to anyone to use this software for any purpose,
 ' Permission is granted to anyone to use this software for any purpose,
 ' including commercial applications, and to alter it and redistribute it
 ' including commercial applications, and to alter it and redistribute it
 ' freely, subject to the following restrictions:
 ' freely, subject to the following restrictions:
-' 
+'
 '    1. The origin of this software must not be misrepresented; you must not
 '    1. The origin of this software must not be misrepresented; you must not
 '    claim that you wrote the original software. If you use this software
 '    claim that you wrote the original software. If you use this software
 '    in a product, an acknowledgment in the product documentation would be
 '    in a product, an acknowledgment in the product documentation would be
 '    appreciated but is not required.
 '    appreciated but is not required.
-' 
+'
 '    2. Altered source versions must be plainly marked as such, and must not be
 '    2. Altered source versions must be plainly marked as such, and must not be
 '    misrepresented as being the original software.
 '    misrepresented as being the original software.
-' 
+'
 '    3. This notice may not be removed or altered from any source
 '    3. This notice may not be removed or altered from any source
 '    distribution.
 '    distribution.
-' 
+'
 SuperStrict
 SuperStrict
 
 
 Import "parser.bmx"
 Import "parser.bmx"
@@ -698,10 +698,24 @@ Type TCTranslator Extends TTranslator
 	End Method
 	End Method
 	
 	
 	Method TransNewArrayExpr$( expr:TNewArrayExpr )
 	Method TransNewArrayExpr$( expr:TNewArrayExpr )
-'		Local texpr$=expr.expr.Trans()
-		'
-		Return "bbArrayNew1D" + Bra(TransArrayType(expr.ty) + ", " + expr.expr.Trans())
-		'Return "Array<"+TransRefType( expr.ty, "LL" )+" >"+Bra( expr.expr.Trans() )
+
+		If expr.expr.length = 1 Then
+			Return "bbArrayNew1D" + Bra(TransArrayType(expr.ty) + ", " + expr.expr[0].Trans())
+		Else
+			' multiple array
+			Local s:String
+			
+			For Local i:Int = 0 Until expr.expr.length
+				If i Then
+					s:+ ", "
+				End If
+				
+				s:+ expr.expr[i].Trans()
+			Next
+			
+			Return "bbArrayNew" + Bra(TransArrayType(expr.ty) + ", " + expr.expr.length + ", " + s)
+		End If
+
 	End Method
 	End Method
 		
 		
 	Method TransSelfExpr$( expr:TSelfExpr )
 	Method TransSelfExpr$( expr:TSelfExpr )
@@ -842,7 +856,7 @@ Type TCTranslator Extends TTranslator
 				t_expr = TransSubExpr( expr.expr,pri )
 				t_expr = TransSubExpr( expr.expr,pri )
 			End If
 			End If
 		Else
 		Else
-				t_expr = TransSubExpr( expr.expr,pri )
+			t_expr = TransSubExpr( expr.expr,pri )
 		End If
 		End If
 
 
 '		TransSubExpr( expr.expr,pri )
 '		TransSubExpr( expr.expr,pri )
@@ -857,13 +871,41 @@ Type TCTranslator Extends TTranslator
 		If TStringType(expr.exprType) And expr.op = "+" Then
 		If TStringType(expr.exprType) And expr.op = "+" Then
 			Return "bbStringConcat(" + t_lhs + "," + t_rhs + ")"
 			Return "bbStringConcat(" + t_lhs + "," + t_rhs + ")"
 		End If
 		End If
-		
+
+		If TBinaryCompareExpr(expr) And TStringType(TBinaryCompareExpr(expr).ty) Then
+			Return "bbStringCompare" + Bra(t_lhs + ", " + t_rhs) + TransBinaryOp(expr.op, "") + "0"
+		End If
+
 		Return bra(t_lhs+TransBinaryOp( expr.op,t_rhs )+t_rhs)
 		Return bra(t_lhs+TransBinaryOp( expr.op,t_rhs )+t_rhs)
 	End Method
 	End Method
 	
 	
 	Method TransIndexExpr$( expr:TIndexExpr )
 	Method TransIndexExpr$( expr:TIndexExpr )
 		Local t_expr$=TransSubExpr( expr.expr )
 		Local t_expr$=TransSubExpr( expr.expr )
-		Local t_index$=expr.index.Trans()
+		
+		Local t_index$
+		If expr.index.length = 1 Then
+			If TArraySizeExpr(expr.index[0]) Then
+				Local sizes:TArraySizeExpr = TArraySizeExpr(expr.index[0])
+				sizes.Trans()
+				Local v:String = sizes.val.munged
+				Local i:Int = 0
+				For i = 0 Until sizes.index.length - 1
+					If i Then
+						t_index :+ " + "
+					End If
+					t_index :+ "(*(" + v
+					If i Then
+						t_index :+ "+" + i
+					End If
+					t_index :+ ")) * " + sizes.index[i].Trans()
+				Next
+				t_index :+ " + " + sizes.index[i].Trans()
+				' (*(v+0)) * var1 + (*(v+1)) * var2 + var3
+'DebugStop
+			Else
+				t_index=expr.index[0].Trans()
+			End If
+		End If
 		
 		
 		If TStringType( expr.expr.exprType ) Then
 		If TStringType( expr.expr.exprType ) Then
 			Return Bra(t_expr) + "->buf[" + t_index + "]" 
 			Return Bra(t_expr) + "->buf[" + t_index + "]" 
@@ -874,12 +916,12 @@ Type TCTranslator Extends TTranslator
 			Return Bra("(" + TransType(expr.exprType, "") + "*)BBARRAYDATA(" + t_expr + "," + t_expr + "->dims)") + "[" + t_index + "]"
 			Return Bra("(" + TransType(expr.exprType, "") + "*)BBARRAYDATA(" + t_expr + "," + t_expr + "->dims)") + "[" + t_index + "]"
 		End If
 		End If
 		
 		
-		Local swiz$
-		If TObjectType( expr.exprType )And expr.exprType.GetClass().IsInterface() swiz=".p"
+		'Local swiz$
+		'If TObjectType( expr.exprType )And expr.exprType.GetClass().IsInterface() swiz=".p"
 		
 		
 		'If ENV_CONFIG="debug" Return t_expr+".At("+t_index+")"+swiz
 		'If ENV_CONFIG="debug" Return t_expr+".At("+t_index+")"+swiz
 		
 		
-		Return t_expr+"["+t_index+"]"+swiz
+		Return t_expr+"["+t_index+"]"
 	End Method
 	End Method
 	
 	
 	Method TransSliceExpr$( expr:TSliceExpr )
 	Method TransSliceExpr$( expr:TSliceExpr )
@@ -931,11 +973,18 @@ Type TCTranslator Extends TTranslator
 '		If Not _env tt="static "
 '		If Not _env tt="static "
 
 
 		Emit tt+TransType( elemType, tmp.munged )+" "+tmp.munged+"[]={"+t+"};"
 		Emit tt+TransType( elemType, tmp.munged )+" "+tmp.munged+"[]={"+t+"};"
-'DebugStop
+
 		Return "bbArrayFromData" + Bra(TransArrayType(elemType) + "," + count + "," + tmp.munged )
 		Return "bbArrayFromData" + Bra(TransArrayType(elemType) + "," + count + "," + tmp.munged )
 		'Return "Array<"+TransRefType( elemType, "MM" )+" >("+tmp.munged+","+expr.exprs.Length+")"
 		'Return "Array<"+TransRefType( elemType, "MM" )+" >("+tmp.munged+","+expr.exprs.Length+")"
 	End Method
 	End Method
 
 
+	Method TransArraySizeExpr$ ( expr:TArraySizeExpr )
+		' scales[0] is the total size of the array
+		' we start from [1] because it is the size of the next full dimension.
+		' in the case of a 2-dimensional array, [1] represents the length of a row.
+		Return Bra("(BBARRAY)" + expr.expr.Trans()) + "->scales + 1"
+	End Method
+
 	Method TransIntrinsicExpr$( decl:TDecl,expr:TExpr,args:TExpr[] )
 	Method TransIntrinsicExpr$( decl:TDecl,expr:TExpr,args:TExpr[] )
 		Local texpr$,arg0$,arg1$,arg2$
 		Local texpr$,arg0$,arg1$,arg2$
 		
 		
@@ -2650,7 +2699,7 @@ End Rem
 	End Method
 	End Method
 	
 	
 	Method TransApp( app:TAppDecl )
 	Method TransApp( app:TAppDecl )
-	
+
 		If app.mainModule.IsSuperStrict()
 		If app.mainModule.IsSuperStrict()
 			opt_issuperstrict = True
 			opt_issuperstrict = True
 		End If
 		End If

+ 22 - 14
decl.bmx

@@ -1,26 +1,26 @@
-' Copyright (c) 2013-2014 Bruce A Henderson & Ronny Otto 
+' Copyright (c) 2013-2014 Bruce A Henderson
 '
 '
 ' Based on the public domain Monkey "trans" by Mark Sibly
 ' Based on the public domain Monkey "trans" by Mark Sibly
-' 
+'
 ' This software is provided 'as-is', without any express or implied
 ' This software is provided 'as-is', without any express or implied
 ' warranty. In no event will the authors be held liable for any damages
 ' warranty. In no event will the authors be held liable for any damages
 ' arising from the use of this software.
 ' arising from the use of this software.
-' 
+'
 ' Permission is granted to anyone to use this software for any purpose,
 ' Permission is granted to anyone to use this software for any purpose,
 ' including commercial applications, and to alter it and redistribute it
 ' including commercial applications, and to alter it and redistribute it
 ' freely, subject to the following restrictions:
 ' freely, subject to the following restrictions:
-' 
+'
 '    1. The origin of this software must not be misrepresented; you must not
 '    1. The origin of this software must not be misrepresented; you must not
 '    claim that you wrote the original software. If you use this software
 '    claim that you wrote the original software. If you use this software
 '    in a product, an acknowledgment in the product documentation would be
 '    in a product, an acknowledgment in the product documentation would be
 '    appreciated but is not required.
 '    appreciated but is not required.
-' 
+'
 '    2. Altered source versions must be plainly marked as such, and must not be
 '    2. Altered source versions must be plainly marked as such, and must not be
 '    misrepresented as being the original software.
 '    misrepresented as being the original software.
-' 
+'
 '    3. This notice may not be removed or altered from any source
 '    3. This notice may not be removed or altered from any source
 '    distribution.
 '    distribution.
-' 
+'
 
 
 Const DECL_EXTERN:Int=		$010000
 Const DECL_EXTERN:Int=		$010000
 Const DECL_PRIVATE:Int=	    $020000
 Const DECL_PRIVATE:Int=	    $020000
@@ -1459,13 +1459,6 @@ End Rem
 				Exit
 				Exit
 			Next
 			Next
 			
 			
-			For Local decl:TConstDecl = EachIn Decls()
-				decl.Semant()
-			Next
-			
-			For Local decl:TGlobalDecl = EachIn Decls()
-				decl.Semant()
-			Next
 			
 			
 			' Don't need default new?
 			' Don't need default new?
 			'If Not fdecl
 			'If Not fdecl
@@ -1481,6 +1474,21 @@ End Rem
 		End If
 		End If
 	End Method
 	End Method
 	
 	
+	Method Semant()
+		If IsSemanted() Return
+		
+		Super.Semant()
+		
+		For Local decl:TConstDecl = EachIn Decls()
+			decl.Semant()
+		Next
+		
+		For Local decl:TGlobalDecl = EachIn Decls()
+			decl.Semant()
+		Next
+		
+	End Method
+	
 	'Ok, this dodgy looking beast 'resurrects' methods that may not currently be alive, but override methods that ARE.
 	'Ok, this dodgy looking beast 'resurrects' methods that may not currently be alive, but override methods that ARE.
 	Method UpdateLiveMethods:Int()
 	Method UpdateLiveMethods:Int()
 	
 	

+ 83 - 11
expr.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2013-2014 Bruce A Henderson & Ronny Otto
+' Copyright (c) 2013-2014 Bruce A Henderson
 '
 '
 ' Based on the public domain Monkey "trans" by Mark Sibly
 ' Based on the public domain Monkey "trans" by Mark Sibly
 '
 '
@@ -186,6 +186,11 @@ Type TStmtExpr Extends TExpr
 		Return _trans.TransStmtExpr( Self )
 		Return _trans.TransStmtExpr( Self )
 	End Method
 	End Method
 
 
+	Method TransVar$()
+		Semant
+		Return _trans.TransStmtExpr( Self )
+	End Method
+
 End Type
 End Type
 
 
 '	literal
 '	literal
@@ -558,9 +563,11 @@ End Type
 
 
 Type TNewArrayExpr Extends TExpr
 Type TNewArrayExpr Extends TExpr
 	Field ty:TType
 	Field ty:TType
-	Field expr:TExpr
 
 
-	Method Create:TNewArrayExpr( ty:TType,expr:TExpr )
+	Field expr:TExpr[]
+	
+	Method Create:TNewArrayExpr( ty:TType,expr:TExpr[] )
+
 		Self.ty=ty
 		Self.ty=ty
 		Self.expr=expr
 		Self.expr=expr
 		Return Self
 		Return Self
@@ -568,7 +575,11 @@ Type TNewArrayExpr Extends TExpr
 
 
 	Method Copy:TExpr()
 	Method Copy:TExpr()
 		If exprType InternalErr
 		If exprType InternalErr
-		Return New TNewArrayExpr.Create( ty,CopyExpr(expr) )
+		Local cexpr:TExpr[expr.length]
+		For Local i:Int = 0 Until expr.length
+			cexpr[i] = CopyExpr(expr[i])
+		Next
+		Return New TNewArrayExpr.Create( ty,cexpr )
 	End Method
 	End Method
 
 
 	Method Semant:TExpr()
 	Method Semant:TExpr()
@@ -576,7 +587,9 @@ Type TNewArrayExpr Extends TExpr
 
 
 		ty=ty.Semant()
 		ty=ty.Semant()
 		exprType=New TArrayType.Create( ty )
 		exprType=New TArrayType.Create( ty )
-		expr=expr.SemantAndCast( TType.intType )
+		For Local i:Int = 0 Until expr.length
+			expr[i]=expr[i].SemantAndCast( TType.intType )
+		Next
 		Return Self
 		Return Self
 	End Method
 	End Method
 
 
@@ -1131,29 +1144,48 @@ End Type
 
 
 Type TIndexExpr Extends TExpr
 Type TIndexExpr Extends TExpr
 	Field expr:TExpr
 	Field expr:TExpr
-	Field index:TExpr
+	Field index:TExpr[]
 
 
-	Method Create:TIndexExpr( expr:TExpr,index:TExpr )
+	Method Create:TIndexExpr( expr:TExpr,index:TExpr[] )
 		Self.expr=expr
 		Self.expr=expr
 		Self.index=index
 		Self.index=index
 		Return Self
 		Return Self
 	End Method
 	End Method
 
 
 	Method Copy:TExpr()
 	Method Copy:TExpr()
-		Return New TIndexExpr.Create( CopyExpr(expr),CopyExpr(index) )
+		Local ind:TExpr[]
+		For Local i:Int = 0 Until index.length
+			ind = ind + [CopyExpr(index[i])]
+		Next
+		Return New TIndexExpr.Create( CopyExpr(expr),ind )
 	End Method
 	End Method
 
 
 	Method Semant:TExpr()
 	Method Semant:TExpr()
 		If exprType Return Self
 		If exprType Return Self
 
 
 		expr=expr.Semant()
 		expr=expr.Semant()
-		index=index.SemantAndCast( TType.intType )
+		For Local i:Int = 0 Until index.length
+			index[i]=index[i].SemantAndCast( TType.intType )
+		Next
 
 
 		If TStringType( expr.exprType )
 		If TStringType( expr.exprType )
 			exprType=TType.intType
 			exprType=TType.intType
+			If index.length > 1 Then
+				Err "Illegal subexpression for string index"
+			End If
 		Else If TArrayType( expr.exprType )
 		Else If TArrayType( expr.exprType )
 			exprType=TArrayType( expr.exprType ).elemType
 			exprType=TArrayType( expr.exprType ).elemType
 
 
+			If TArrayType( expr.exprType ).dims > 1 Then
+				Local sizeExpr:TExpr = New TArraySizeExpr.Create(expr, Null, index)
+				index = [sizeExpr]
+				Local tmp:TLocalDecl=New TLocalDecl.Create( "", TType.intPointerType, sizeExpr )
+				TArraySizeExpr(sizeExpr).val = tmp
+				Local stmt:TExpr = New TStmtExpr.Create( New TDeclStmt.Create( tmp ), Self ).Semant()
+				stmt.exprType = exprType
+				Return stmt
+				
+			End If
 			'If TObjectType(exprType) And Not TStringType(exprType) And Not TArrayType(exprType) Then
 			'If TObjectType(exprType) And Not TStringType(exprType) And Not TArrayType(exprType) Then
 			'	Local tmp:TLocalDecl=New TLocalDecl.Create( "", exprType,expr )
 			'	Local tmp:TLocalDecl=New TLocalDecl.Create( "", exprType,expr )
 			'	Local stmt:TExpr = New TStmtExpr.Create( New TDeclStmt.Create( tmp ),New TVarExpr.Create( tmp ) ).Semant()
 			'	Local stmt:TExpr = New TStmtExpr.Create( New TDeclStmt.Create( tmp ),New TVarExpr.Create( tmp ) ).Semant()
@@ -1171,8 +1203,8 @@ Type TIndexExpr Extends TExpr
 	End Method
 	End Method
 
 
 	Method SemantSet:TExpr( op$,rhs:TExpr )
 	Method SemantSet:TExpr( op$,rhs:TExpr )
-		Semant
-		Return Self
+		Return Semant()
+		'Return Self
 	End Method
 	End Method
 
 
 	Method Trans$()
 	Method Trans$()
@@ -1270,6 +1302,46 @@ Type TArrayExpr Extends TExpr
 
 
 End Type
 End Type
 
 
+Type TArraySizeExpr Extends TExpr
+
+	Field expr:TExpr
+	Field val:TDecl
+	Field index:TExpr[]
+
+	Method Create:TArraySizeExpr( expr:TExpr, val:TDecl, index:TExpr[] )
+		Self.expr=expr
+		Self.val=val
+		Self.index=index
+		Return Self
+	End Method
+
+	Method Copy:TExpr()
+		Local ind:TExpr[]
+		For Local i:Int = 0 Until index.length
+			ind = ind + [CopyExpr(index[i])]
+		Next
+		Return New TArraySizeExpr.Create( CopyExpr(expr), val, ind )
+	End Method
+
+	Method Semant:TExpr()
+		If exprType Return Self
+
+		expr=expr.Semant()
+		
+		For Local i:Int = 0 Until index.length
+			index[i]=index[i].SemantAndCast( TType.intType )
+		Next
+		
+		exprType=TType.intPointerType
+		Return Self
+	End Method
+
+	Method Trans$()
+		Return _trans.TransArraySizeExpr( Self )
+	End Method
+
+End Type
+
 Type TIdentTypeExpr Extends TExpr
 Type TIdentTypeExpr Extends TExpr
 	Field cdecl:TClassDecl
 	Field cdecl:TClassDecl
 
 

+ 33 - 12
parser.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2013-2014 Bruce A Henderson & Ronny Otto
+' Copyright (c) 2013-2014 Bruce A Henderson
 '
 '
 ' Based on the public domain Monkey "trans" by Mark Sibly
 ' Based on the public domain Monkey "trans" by Mark Sibly
 '
 '
@@ -89,7 +89,7 @@ Type TForEachinStmt Extends TStmt
 
 
 			Local cmpExpr:TExpr=New TBinaryCompareExpr.Create( "<",New TVarExpr.Create( indexTmp ),lenExpr )
 			Local cmpExpr:TExpr=New TBinaryCompareExpr.Create( "<",New TVarExpr.Create( indexTmp ),lenExpr )
 
 
-			Local indexExpr:TExpr=New TIndexExpr.Create( New TVarExpr.Create( exprTmp ),New TVarExpr.Create( indexTmp ) )
+			Local indexExpr:TExpr=New TIndexExpr.Create( New TVarExpr.Create( exprTmp ),[New TVarExpr.Create( indexTmp )] )
 			Local addExpr:TExpr=New TBinaryMathExpr.Create( "+",New TVarExpr.Create( indexTmp ),New TConstExpr.Create( TType.intType,"1" ) )
 			Local addExpr:TExpr=New TBinaryMathExpr.Create( "+",New TVarExpr.Create( indexTmp ),New TConstExpr.Create( TType.intType,"1" ) )
 
 
 			block.stmts.AddFirst New TAssignStmt.Create( "=",New TVarExpr.Create( indexTmp ),addExpr )
 			block.stmts.AddFirst New TAssignStmt.Create( "=",New TVarExpr.Create( indexTmp ),addExpr )
@@ -665,8 +665,13 @@ Type TParser
 			NextToke
 			NextToke
 			Local ty:TType=ParseType()
 			Local ty:TType=ParseType()
 			If CParse( "[" )
 			If CParse( "[" )
-				Local ln:TExpr=ParseExpr()
-				Parse "]"
+				Local ln:TExpr[]
+				Repeat
+					ln = ln + [ParseExpr()]
+					If CParse("]") Exit
+					Parse ","
+				Forever
+				'Parse "]"
 				While CParse( "[]" )
 				While CParse( "[]" )
 					ty=New TArrayType.Create( ty)
 					ty=New TArrayType.Create( ty)
 				Wend
 				Wend
@@ -901,7 +906,6 @@ Type TParser
 				End If
 				End If
 
 
 			Case "["
 			Case "["
-
 				NextToke
 				NextToke
 				If CParse( ".." )
 				If CParse( ".." )
 					If _toke="]"
 					If _toke="]"
@@ -909,6 +913,7 @@ Type TParser
 					Else
 					Else
 						expr=New TSliceExpr.Create( expr,Null,ParseExpr() )
 						expr=New TSliceExpr.Create( expr,Null,ParseExpr() )
 					EndIf
 					EndIf
+					Parse "]"
 				Else
 				Else
 					Local from:TExpr=ParseExpr()
 					Local from:TExpr=ParseExpr()
 					If CParse( ".." )
 					If CParse( ".." )
@@ -917,11 +922,22 @@ Type TParser
 						Else
 						Else
 							expr=New TSliceExpr.Create( expr,from,ParseExpr() )
 							expr=New TSliceExpr.Create( expr,from,ParseExpr() )
 						EndIf
 						EndIf
+						Parse "]"
 					Else
 					Else
-						expr=New TIndexExpr.Create( expr,from )
+						Local ind:TExpr[] = [from]
+						Repeat
+							If CParse("]") Then
+								Exit
+							End If
+						
+							Parse ","							
+
+							ind = ind + [ParseExpr()]
+						Forever
+						
+						expr=New TIndexExpr.Create( expr,ind )
 					EndIf
 					EndIf
 				EndIf
 				EndIf
-				Parse "]"
 			Default
 			Default
 				Return expr
 				Return expr
 			End Select
 			End Select
@@ -1028,11 +1044,11 @@ Type TParser
 			Case "=","<",">","<=","=<",">=","=>","<>"
 			Case "=","<",">","<=","=<",">=","=>","<>"
 				NextToke
 				NextToke
 				' <= or =>
 				' <= or =>
-				If (op=">" And (_toke="=")) OR (op="=" And (_toke=">"))
+				If (op=">" And (_toke="=")) Or (op="=" And (_toke=">"))
 					op:+_toke
 					op:+_toke
 					NextToke
 					NextToke
 				' <> or <= or =<
 				' <> or <= or =<
-				Else If (op="<" and _toke=">") OR (op="<" and _toke="=") OR (op="=" and _toke="<")
+				Else If (op="<" And _toke=">") Or (op="<" And _toke="=") Or (op="=" And _toke="<")
 					op:+_toke
 					op:+_toke
 					NextToke
 					NextToke
 				EndIf
 				EndIf
@@ -1554,13 +1570,18 @@ Type TParser
 			If CParse( "=" )
 			If CParse( "=" )
 				init=ParseExpr()
 				init=ParseExpr()
 			Else If CParse( "[" )
 			Else If CParse( "[" )
-				Local ln:TExpr=ParseExpr()
-				Parse "]"
+				Local ln:TExpr[]
+				Repeat
+					ln = ln + [ParseExpr()]
+					If CParse("]") Exit
+					Parse(",")
+				Forever
+				'Parse "]"
 				While CParse( "[]" )
 				While CParse( "[]" )
 					ty=New TArrayType.Create(ty)
 					ty=New TArrayType.Create(ty)
 				Wend
 				Wend
 				init=New TNewArrayExpr.Create( ty,ln)
 				init=New TNewArrayExpr.Create( ty,ln)
-				ty=New TArrayType.Create( ty )
+				ty=New TArrayType.Create( ty, ln.length )
 			Else If _toke = "(" Then
 			Else If _toke = "(" Then
 	 			' function pointer?
 	 			' function pointer?
 
 

+ 7 - 7
stmt.bmx

@@ -1,26 +1,26 @@
-' Copyright (c) 2013-2014 Bruce A Henderson & Ronny Otto 
+' Copyright (c) 2013-2014 Bruce A Henderson
 '
 '
 ' Based on the public domain Monkey "trans" by Mark Sibly
 ' Based on the public domain Monkey "trans" by Mark Sibly
-' 
+'
 ' This software is provided 'as-is', without any express or implied
 ' This software is provided 'as-is', without any express or implied
 ' warranty. In no event will the authors be held liable for any damages
 ' warranty. In no event will the authors be held liable for any damages
 ' arising from the use of this software.
 ' arising from the use of this software.
-' 
+'
 ' Permission is granted to anyone to use this software for any purpose,
 ' Permission is granted to anyone to use this software for any purpose,
 ' including commercial applications, and to alter it and redistribute it
 ' including commercial applications, and to alter it and redistribute it
 ' freely, subject to the following restrictions:
 ' freely, subject to the following restrictions:
-' 
+'
 '    1. The origin of this software must not be misrepresented; you must not
 '    1. The origin of this software must not be misrepresented; you must not
 '    claim that you wrote the original software. If you use this software
 '    claim that you wrote the original software. If you use this software
 '    in a product, an acknowledgment in the product documentation would be
 '    in a product, an acknowledgment in the product documentation would be
 '    appreciated but is not required.
 '    appreciated but is not required.
-' 
+'
 '    2. Altered source versions must be plainly marked as such, and must not be
 '    2. Altered source versions must be plainly marked as such, and must not be
 '    misrepresented as being the original software.
 '    misrepresented as being the original software.
-' 
+'
 '    3. This notice may not be removed or altered from any source
 '    3. This notice may not be removed or altered from any source
 '    distribution.
 '    distribution.
-' 
+'
 
 
 Type TStmt
 Type TStmt
 	Field errInfo$
 	Field errInfo$

+ 40 - 0
tests/framework/language/arrays_0.bmx

@@ -0,0 +1,40 @@
+SuperStrict
+
+Framework BRL.Standardio
+
+Local a1:Int[] = [1,2,3,4,5,6,7,8,9,10]
+
+Local b1:Int[10]
+
+Local c1:Int[2,5]
+
+For Local i:Int = 0 Until a1.length
+	b1[i] = a1[i]
+	
+	c1[i/5,i Mod 5] = a1[i]
+Next
+
+Local s:String = "b1 = ["
+For Local i:Int = 0 Until a1.length
+	If i Then
+		s :+ ","
+	End If
+
+	s :+ b1[i]
+Next
+
+Print s + "]"
+
+s = "c1 = ["
+Local n:Int
+For Local x:Int = 0 Until 2
+	For Local y:Int = 0 Until 5
+		If n Then
+			s :+ ","
+		End If
+		n :+ 1
+		s:+ c1[x,y]
+	Next
+Next
+
+Print s + "]"

+ 28 - 0
tests/framework/types/global_01.bmx

@@ -0,0 +1,28 @@
+SuperStrict
+
+Framework BRL.Standardio
+
+
+' instance no init
+Global instance:TInstanceType
+
+Global instInit:TInstanceType = New TInstanceType
+
+If Not instance Then
+	Print "No Instance"
+Else
+	Print "Has Instance"
+End If
+
+If Not instInit Then
+	Print "No InstInit"
+Else
+	Print "Has InstInit"
+End If
+
+
+Type TInstanceType
+
+End Type
+
+

+ 22 - 0
tests/framework/types/global_02.bmx

@@ -0,0 +1,22 @@
+SuperStrict
+
+Framework BRL.Standardio
+
+
+If Not TInstanceType.instance Then
+	Print "No Instance"
+Else
+	Print "Has Instance"
+End If
+
+If Not TInstanceType.instInit Then
+	Print "No InstInit"
+Else
+	Print "Has InstInit"
+End If
+
+Type TInstanceType
+	Global instance:TInstanceType
+	Global instInit:TInstanceType = New TInstanceType
+
+End Type

+ 1 - 0
tests/mods.conf

@@ -50,3 +50,4 @@ brl.basic
 brl.httpstream
 brl.httpstream
 pub.oggvorbis
 pub.oggvorbis
 brl.oggloader
 brl.oggloader
+brl.wavloader

+ 7 - 7
toker.bmx

@@ -1,26 +1,26 @@
-' Copyright (c) 2013-2014 Bruce A Henderson & Ronny Otto 
+' Copyright (c) 2013-2014 Bruce A Henderson
 '
 '
 ' Based on the public domain Monkey "trans" by Mark Sibly
 ' Based on the public domain Monkey "trans" by Mark Sibly
-' 
+'
 ' This software is provided 'as-is', without any express or implied
 ' This software is provided 'as-is', without any express or implied
 ' warranty. In no event will the authors be held liable for any damages
 ' warranty. In no event will the authors be held liable for any damages
 ' arising from the use of this software.
 ' arising from the use of this software.
-' 
+'
 ' Permission is granted to anyone to use this software for any purpose,
 ' Permission is granted to anyone to use this software for any purpose,
 ' including commercial applications, and to alter it and redistribute it
 ' including commercial applications, and to alter it and redistribute it
 ' freely, subject to the following restrictions:
 ' freely, subject to the following restrictions:
-' 
+'
 '    1. The origin of this software must not be misrepresented; you must not
 '    1. The origin of this software must not be misrepresented; you must not
 '    claim that you wrote the original software. If you use this software
 '    claim that you wrote the original software. If you use this software
 '    in a product, an acknowledgment in the product documentation would be
 '    in a product, an acknowledgment in the product documentation would be
 '    appreciated but is not required.
 '    appreciated but is not required.
-' 
+'
 '    2. Altered source versions must be plainly marked as such, and must not be
 '    2. Altered source versions must be plainly marked as such, and must not be
 '    misrepresented as being the original software.
 '    misrepresented as being the original software.
-' 
+'
 '    3. This notice may not be removed or altered from any source
 '    3. This notice may not be removed or altered from any source
 '    distribution.
 '    distribution.
-' 
+'
 SuperStrict
 SuperStrict
 
 
 Import "config.bmx"
 Import "config.bmx"

+ 13 - 8
translator.bmx

@@ -1,26 +1,26 @@
-' Copyright (c) 2013-2014 Bruce A Henderson & Ronny Otto 
+' Copyright (c) 2013-2014 Bruce A Henderson
 '
 '
 ' Based on the public domain Monkey "trans" by Mark Sibly
 ' Based on the public domain Monkey "trans" by Mark Sibly
-' 
+'
 ' This software is provided 'as-is', without any express or implied
 ' This software is provided 'as-is', without any express or implied
 ' warranty. In no event will the authors be held liable for any damages
 ' warranty. In no event will the authors be held liable for any damages
 ' arising from the use of this software.
 ' arising from the use of this software.
-' 
+'
 ' Permission is granted to anyone to use this software for any purpose,
 ' Permission is granted to anyone to use this software for any purpose,
 ' including commercial applications, and to alter it and redistribute it
 ' including commercial applications, and to alter it and redistribute it
 ' freely, subject to the following restrictions:
 ' freely, subject to the following restrictions:
-' 
+'
 '    1. The origin of this software must not be misrepresented; you must not
 '    1. The origin of this software must not be misrepresented; you must not
 '    claim that you wrote the original software. If you use this software
 '    claim that you wrote the original software. If you use this software
 '    in a product, an acknowledgment in the product documentation would be
 '    in a product, an acknowledgment in the product documentation would be
 '    appreciated but is not required.
 '    appreciated but is not required.
-' 
+'
 '    2. Altered source versions must be plainly marked as such, and must not be
 '    2. Altered source versions must be plainly marked as such, and must not be
 '    misrepresented as being the original software.
 '    misrepresented as being the original software.
-' 
+'
 '    3. This notice may not be removed or altered from any source
 '    3. This notice may not be removed or altered from any source
 '    distribution.
 '    distribution.
-' 
+'
 
 
 Global _trans:TTranslator
 Global _trans:TTranslator
 
 
@@ -128,6 +128,7 @@ Type TTranslator
 
 
 			If TModuleDecl( decl )
 			If TModuleDecl( decl )
 				munged=decl.ModuleScope().munged+"_"+id
 				munged=decl.ModuleScope().munged+"_"+id
+				munged = munged.Replace(".", "_")
 			EndIf
 			EndIf
 
 
 '		End Select
 '		End Select
@@ -284,6 +285,8 @@ End Rem
 		Case "=" Return "=="
 		Case "=" Return "=="
 		Case "<>" Return "!="
 		Case "<>" Return "!="
 		Case "<","<=",">",">=" Return op
 		Case "<","<=",">",">=" Return op
+		Case "=<" Return "<="
+		Case "=>" Return ">="
 		Case "&","|" Return op
 		Case "&","|" Return op
 		Case "~~" Return "^"
 		Case "~~" Return "^"
 		End Select
 		End Select
@@ -318,7 +321,7 @@ End Rem
 			Case "*","/","mod" Return 4
 			Case "*","/","mod" Return 4
 			Case "+","-" Return 5
 			Case "+","-" Return 5
 			Case "shl","shr", "sar" Return 6
 			Case "shl","shr", "sar" Return 6
-			Case "<","<=",">",">=" Return 7
+			Case "<","<=",">",">=", "=<", "=>" Return 7
 			Case "=","<>" Return 8
 			Case "=","<>" Return 8
 			Case "&" Return 9
 			Case "&" Return 9
 			Case "~~" Return 10
 			Case "~~" Return 10
@@ -398,6 +401,8 @@ End Rem
 	
 	
 	Method TransArrayExpr$( expr:TArrayExpr ) Abstract
 	Method TransArrayExpr$( expr:TArrayExpr ) Abstract
 	
 	
+	Method TransArraySizeExpr$ ( expr:TArraySizeExpr ) Abstract
+	
 	Method TransIntrinsicExpr$( decl:TDecl,expr:TExpr,args:TExpr[]=Null ) Abstract
 	Method TransIntrinsicExpr$( decl:TDecl,expr:TExpr,args:TExpr[]=Null ) Abstract
 
 
 	Method BeginLocalScope()
 	Method BeginLocalScope()

+ 11 - 9
type.bmx

@@ -1,26 +1,26 @@
-' Copyright (c) 2013-2014 Bruce A Henderson & Ronny Otto 
+' Copyright (c) 2013-2014 Bruce A Henderson
 '
 '
 ' Based on the public domain Monkey "trans" by Mark Sibly
 ' Based on the public domain Monkey "trans" by Mark Sibly
-' 
+'
 ' This software is provided 'as-is', without any express or implied
 ' This software is provided 'as-is', without any express or implied
 ' warranty. In no event will the authors be held liable for any damages
 ' warranty. In no event will the authors be held liable for any damages
 ' arising from the use of this software.
 ' arising from the use of this software.
-' 
+'
 ' Permission is granted to anyone to use this software for any purpose,
 ' Permission is granted to anyone to use this software for any purpose,
 ' including commercial applications, and to alter it and redistribute it
 ' including commercial applications, and to alter it and redistribute it
 ' freely, subject to the following restrictions:
 ' freely, subject to the following restrictions:
-' 
+'
 '    1. The origin of this software must not be misrepresented; you must not
 '    1. The origin of this software must not be misrepresented; you must not
 '    claim that you wrote the original software. If you use this software
 '    claim that you wrote the original software. If you use this software
 '    in a product, an acknowledgment in the product documentation would be
 '    in a product, an acknowledgment in the product documentation would be
 '    appreciated but is not required.
 '    appreciated but is not required.
-' 
+'
 '    2. Altered source versions must be plainly marked as such, and must not be
 '    2. Altered source versions must be plainly marked as such, and must not be
 '    misrepresented as being the original software.
 '    misrepresented as being the original software.
-' 
+'
 '    3. This notice may not be removed or altered from any source
 '    3. This notice may not be removed or altered from any source
 '    distribution.
 '    distribution.
-' 
+'
 SuperStrict
 SuperStrict
 
 
 Import "config.bmx"
 Import "config.bmx"
@@ -406,9 +406,11 @@ End Type
 
 
 Type TArrayType Extends TType
 Type TArrayType Extends TType
 	Field elemType:TType
 	Field elemType:TType
+	Field dims:Int
 	
 	
-	Method Create:TArrayType( elemType:TType )
+	Method Create:TArrayType( elemType:TType, dims:Int = 1 )
 		Self.elemType=elemType
 		Self.elemType=elemType
+		Self.dims = dims
 		Return Self
 		Return Self
 	End Method
 	End Method
 	
 	
@@ -430,7 +432,7 @@ Type TArrayType Extends TType
 	
 	
 	Method Semant:TType()
 	Method Semant:TType()
 		Local ty:TType=elemType.Semant()
 		Local ty:TType=elemType.Semant()
-		If ty<>elemType Return New TArrayType.Create( ty )
+		If ty<>elemType Return New TArrayType.Create( ty, dims )
 		Return Self
 		Return Self
 	End Method
 	End Method