|
@@ -30,7 +30,7 @@ Import "iparser.bmx"
|
|
|
|
|
|
Global FILE_EXT$="bmx"
|
|
Global FILE_EXT$="bmx"
|
|
|
|
|
|
-Type TForEachinStmt Extends TStmt
|
|
|
|
|
|
+Type TForEachinStmt Extends TLoopStmt
|
|
Field varid$
|
|
Field varid$
|
|
Field varty:TType
|
|
Field varty:TType
|
|
Field varlocal:Int
|
|
Field varlocal:Int
|
|
@@ -39,17 +39,18 @@ Type TForEachinStmt Extends TStmt
|
|
|
|
|
|
Field stmts:TList=New TList
|
|
Field stmts:TList=New TList
|
|
|
|
|
|
- Method Create:TForEachinStmt( varid$,varty:TType,varlocal:Int,expr:TExpr,block:TBlockDecl )
|
|
|
|
|
|
+ Method Create:TForEachinStmt( varid$,varty:TType,varlocal:Int,expr:TExpr,block:TBlockDecl,loopLabel:TLoopLabelDecl )
|
|
Self.varid=varid
|
|
Self.varid=varid
|
|
Self.varty=varty
|
|
Self.varty=varty
|
|
Self.varlocal=varlocal
|
|
Self.varlocal=varlocal
|
|
Self.expr=expr
|
|
Self.expr=expr
|
|
Self.block=block
|
|
Self.block=block
|
|
|
|
+ Self.loopLabel=loopLabel
|
|
Return Self
|
|
Return Self
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method OnCopy:TStmt( scope:TScopeDecl )
|
|
Method OnCopy:TStmt( scope:TScopeDecl )
|
|
- Return New TForEachinStmt.Create( varid,varty,varlocal,expr.Copy(),block.CopyBlock( scope ) )
|
|
|
|
|
|
+ Return New TForEachinStmt.Create( varid,varty,varlocal,expr.Copy(),block.CopyBlock( scope ),TLoopLabelDecl(loopLabel.Copy()) )
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method OnSemant()
|
|
Method OnSemant()
|
|
@@ -120,7 +121,7 @@ Type TForEachinStmt Extends TStmt
|
|
|
|
|
|
EndIf
|
|
EndIf
|
|
|
|
|
|
- Local whileStmt:TWhileStmt=New TWhileStmt.Create( cmpExpr,block )
|
|
|
|
|
|
+ Local whileStmt:TWhileStmt=New TWhileStmt.Create( cmpExpr,block,Null )
|
|
|
|
|
|
block=New TBlockDecl.Create( block.scope )
|
|
block=New TBlockDecl.Create( block.scope )
|
|
block.AddStmt New TDeclStmt.Create( exprTmp )
|
|
block.AddStmt New TDeclStmt.Create( exprTmp )
|
|
@@ -167,7 +168,7 @@ Type TForEachinStmt Extends TStmt
|
|
block.stmts.AddFirst New TAssignStmt.Create( "=",New TIdentExpr.Create( varid ),nextObjExpr )
|
|
block.stmts.AddFirst New TAssignStmt.Create( "=",New TIdentExpr.Create( varid ),nextObjExpr )
|
|
EndIf
|
|
EndIf
|
|
|
|
|
|
- Local whileStmt:TWhileStmt=New TWhileStmt.Create( hasNextExpr,block )
|
|
|
|
|
|
+ Local whileStmt:TWhileStmt=New TWhileStmt.Create( hasNextExpr,block,Null )
|
|
|
|
|
|
block=New TBlockDecl.Create( block.scope )
|
|
block=New TBlockDecl.Create( block.scope )
|
|
If tmpDecl Then
|
|
If tmpDecl Then
|
|
@@ -1214,7 +1215,7 @@ Type TParser
|
|
_block.AddStmt stmt
|
|
_block.AddStmt stmt
|
|
End Method
|
|
End Method
|
|
|
|
|
|
- Method ParseWhileStmt()
|
|
|
|
|
|
+ Method ParseWhileStmt(loopLabel:TLoopLabelDecl = Null)
|
|
Parse "while"
|
|
Parse "while"
|
|
|
|
|
|
Local expr:TExpr=ParseExpr()
|
|
Local expr:TExpr=ParseExpr()
|
|
@@ -1241,12 +1242,12 @@ Type TParser
|
|
Wend
|
|
Wend
|
|
PopBlock
|
|
PopBlock
|
|
|
|
|
|
- Local stmt:TWhileStmt=New TWhileStmt.Create( expr,block )
|
|
|
|
|
|
+ Local stmt:TWhileStmt=New TWhileStmt.Create( expr,block,loopLabel )
|
|
|
|
|
|
_block.AddStmt stmt
|
|
_block.AddStmt stmt
|
|
End Method
|
|
End Method
|
|
|
|
|
|
- Method ParseRepeatStmt()
|
|
|
|
|
|
+ Method ParseRepeatStmt(loopLabel:TLoopLabelDecl = Null)
|
|
|
|
|
|
Parse "repeat"
|
|
Parse "repeat"
|
|
|
|
|
|
@@ -1268,12 +1269,12 @@ Type TParser
|
|
expr=New TConstExpr.Create( New TBoolType,"" )
|
|
expr=New TConstExpr.Create( New TBoolType,"" )
|
|
EndIf
|
|
EndIf
|
|
|
|
|
|
- Local stmt:TRepeatStmt=New TRepeatStmt.Create( block,expr )
|
|
|
|
|
|
+ Local stmt:TRepeatStmt=New TRepeatStmt.Create( block,expr,loopLabel )
|
|
|
|
|
|
_block.AddStmt stmt
|
|
_block.AddStmt stmt
|
|
End Method
|
|
End Method
|
|
|
|
|
|
- Method ParseForStmt()
|
|
|
|
|
|
+ Method ParseForStmt(loopLabel:TLoopLabelDecl = Null)
|
|
'DebugStop
|
|
'DebugStop
|
|
Parse "for"
|
|
Parse "for"
|
|
|
|
|
|
@@ -1310,7 +1311,7 @@ Type TParser
|
|
Wend
|
|
Wend
|
|
PopBlock
|
|
PopBlock
|
|
|
|
|
|
- Local stmt:TForEachinStmt=New TForEachinStmt.Create( varid,varty,varlocal,expr,block )
|
|
|
|
|
|
+ Local stmt:TForEachinStmt=New TForEachinStmt.Create( varid,varty,varlocal,expr,block,loopLabel )
|
|
|
|
|
|
_block.AddStmt stmt
|
|
_block.AddStmt stmt
|
|
|
|
|
|
@@ -1365,7 +1366,7 @@ Type TParser
|
|
|
|
|
|
NextToke
|
|
NextToke
|
|
|
|
|
|
- Local stmt:TForStmt=New TForStmt.Create( init,expr,incr,block )
|
|
|
|
|
|
+ Local stmt:TForStmt=New TForStmt.Create( init,expr,incr,block,loopLabel )
|
|
|
|
|
|
_block.AddStmt stmt
|
|
_block.AddStmt stmt
|
|
End Method
|
|
End Method
|
|
@@ -1379,12 +1380,16 @@ Type TParser
|
|
|
|
|
|
Method ParseExitStmt()
|
|
Method ParseExitStmt()
|
|
Parse "exit"
|
|
Parse "exit"
|
|
- _block.AddStmt New TBreakStmt
|
|
|
|
|
|
+ Local expr:TExpr
|
|
|
|
+ If Not AtEos() expr=ParseExpr()
|
|
|
|
+ _block.AddStmt New TBreakStmt.Create(expr)
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method ParseContinueStmt()
|
|
Method ParseContinueStmt()
|
|
Parse "continue"
|
|
Parse "continue"
|
|
- _block.AddStmt New TContinueStmt
|
|
|
|
|
|
+ Local expr:TExpr
|
|
|
|
+ If Not AtEos() expr=ParseExpr()
|
|
|
|
+ _block.AddStmt New TContinueStmt.Create(expr)
|
|
End Method
|
|
End Method
|
|
|
|
|
|
Method ParseTryStmt()
|
|
Method ParseTryStmt()
|
|
@@ -1665,6 +1670,19 @@ Type TParser
|
|
ParseEndStmt()
|
|
ParseEndStmt()
|
|
Case "extern"
|
|
Case "extern"
|
|
ParseExternBlock(_module, 0)
|
|
ParseExternBlock(_module, 0)
|
|
|
|
+ Case "#"
|
|
|
|
+ Local decl:TLoopLabelDecl = ParseLoopLabelDecl()
|
|
|
|
+ NextToke
|
|
|
|
+ Select _toke
|
|
|
|
+ Case "while"
|
|
|
|
+ ParseWhileStmt(decl)
|
|
|
|
+ Case "repeat"
|
|
|
|
+ ParseRepeatStmt(decl)
|
|
|
|
+ Case "for"
|
|
|
|
+ ParseForStmt(decl)
|
|
|
|
+ Default
|
|
|
|
+ Err "Expecting loop statement"
|
|
|
|
+ End Select
|
|
Default
|
|
Default
|
|
Local expr:TExpr=ParsePrimaryExpr( True )
|
|
Local expr:TExpr=ParsePrimaryExpr( True )
|
|
|
|
|
|
@@ -1847,6 +1865,12 @@ Type TParser
|
|
_block.AddStmt New TDeclStmt.Create( decl )
|
|
_block.AddStmt New TDeclStmt.Create( decl )
|
|
Until Not CParse(",")
|
|
Until Not CParse(",")
|
|
End Method
|
|
End Method
|
|
|
|
+
|
|
|
|
+ Method ParseLoopLabelDecl:TLoopLabelDecl()
|
|
|
|
+ NextToke
|
|
|
|
+ Local id:String = ParseIdent()
|
|
|
|
+ Return New TLoopLabelDecl.Create(id, 0)
|
|
|
|
+ End Method
|
|
|
|
|
|
'handle end-of-line "dot dot return"-line connector
|
|
'handle end-of-line "dot dot return"-line connector
|
|
'-> skips EOL tokens
|
|
'-> skips EOL tokens
|
|
@@ -2381,7 +2405,6 @@ End Rem
|
|
|
|
|
|
' try to import interface
|
|
' try to import interface
|
|
Local par:TIParser = New TIParser
|
|
Local par:TIParser = New TIParser
|
|
-
|
|
|
|
If par.ParseModuleImport(_module, modpath, origPath, path, , , filepath) Return
|
|
If par.ParseModuleImport(_module, modpath, origPath, path, , , filepath) Return
|
|
Else
|
|
Else
|
|
If filepath.startswith("-") Then
|
|
If filepath.startswith("-") Then
|