Created
March 15, 2024 19:31
-
-
Save brokenpylons/ed0ce3ea2a4399359158df90ed72e377 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Recognizer(private val scanner: Scanner) { | |
private var last: Token? = null | |
fun recognizeStart(): Boolean { | |
last = scanner.getToken() | |
val result = // recognize...(); | |
return when(last?.symbol) { | |
Symbol.EOF -> result | |
else -> false | |
} | |
} | |
private fun recognizeTerminal(symbol: Symbol): Boolean = | |
if (last?.symbol == symbol) { | |
last = scanner.getToken() | |
true | |
} else { | |
false | |
} | |
} | |
fun main() { | |
val result = Recognizer(Scanner(Automaton, "input".byteInputStream())).recognizeStart() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment