Instantly share code, notes, and snippets.

@liufengyun /FSM.scala Secret
Created Nov 5, 2018

Embed
What would you like to do?
FSM scala
class transfer(pair: (Int, Int)) extends scala.annotation.Annotation
trait FSM {
val INIT: 0 = 0
val END: 1 = 1
var state: Int = INIT
}
trait File extends FSM {
val OPEN: 10 = 10
val FINISH: 11 = 11
@transfer(INIT -> OPEN)
def open(): Unit
@transfer(OPEN -> (OPEN | FINISH))
def readLine(): String
@transfer((OPEN | FINISH) -> END)
def close(): Unit
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment