Skip to content

Commit

Permalink
Added Interpreter.forceKill flag
Browse files Browse the repository at this point in the history
Setting the forceKill flag to True will stop the interpreter running.
  • Loading branch information
gkjpettet committed Jul 17, 2018
1 parent 10a0179 commit 1b7f3d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
15 changes: 14 additions & 1 deletion src/Roo/Interpreter.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ Implements ExprVisitor,StmtVisitor
limit = statements.Ubound
for i = 0 to limit
Execute(statements(i))
if forceKill then return
next i

End Sub
Expand Down Expand Up @@ -198,6 +199,8 @@ Implements ExprVisitor,StmtVisitor
Sub Reset()
' Reset the interpreter.

self.forceKill = False

self.globals = new Environment
self.environment = globals

Expand Down Expand Up @@ -1206,7 +1209,7 @@ Implements ExprVisitor,StmtVisitor
Function VisitWhileStmt(stmt as WhileStmt) As Variant
try

while IsTruthy(Evaluate(stmt.condition))
while IsTruthy(Evaluate(stmt.condition)) and not forceKill
Execute(stmt.body)
wend

Expand Down Expand Up @@ -1246,6 +1249,10 @@ Implements ExprVisitor,StmtVisitor
Private environment As Environment
#tag EndProperty

#tag Property, Flags = &h0
forceKill As Boolean = False
#tag EndProperty

#tag Property, Flags = &h0
#tag Note
Holds a fixed reference to the outermost global environment.
Expand Down Expand Up @@ -1306,6 +1313,12 @@ Implements ExprVisitor,StmtVisitor
InitialValue="0"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="forceKill"
Group="Behavior"
InitialValue="False"
Type="Boolean"
#tag EndViewProperty
#tag EndViewBehavior
End Class
#tag EndClass
13 changes: 0 additions & 13 deletions src/Roo/Parser.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,6 @@ Protected Class Parser

#tag Method, Flags = &h21
Private Function BreakStatement() As Stmt
' ' BreakStmt → BREAK SEMICOLON
'
' ' Get a reference to the triggering `break` token in case we encounter an error and need
' ' to inform the user of it's position in the source code.
' dim keyword as Token = tokens(current - 1)
'
' call Consume(TokenType.SEMICOLON, "Expected a `;` after the break keyword.")
'
' return new BreakStmt(keyword)




' BreakStmt → BREAK SEMICOLON
' BreakStmt → BREAK (IF Expression)? SEMICOLON

Expand Down

0 comments on commit 1b7f3d1

Please sign in to comment.