Skip to content

Commit 30ed5bd

Browse files
committed
Make the parse function more generic
The parse function now gets a lexer as a parameter and has an overloaded variant for a simple String.
1 parent ad8892c commit 30ed5bd

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/kotlin/JSONParser.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package net.quickwrite
22

33
import net.quickwrite.lexer.JSONLexeme
44
import net.quickwrite.lexer.JSONLexemeType.*
5+
import net.quickwrite.lexer.JSONLexer
56
import net.quickwrite.lexer.StringJSONLexer
67
import java.math.BigDecimal
78
import java.util.Stack
@@ -14,10 +15,8 @@ private enum class State {
1415
}
1516

1617
@Throws(JSONParseException::class)
17-
fun jsonParse(input: String): Any? {
18-
val lexer = StringJSONLexer(input)
19-
20-
var state = State.START
18+
fun jsonParse(lexer: JSONLexer): Any? {
19+
var state = State.START;
2120

2221
var token: JSONLexeme
2322

@@ -211,3 +210,8 @@ fun jsonParse(input: String): Any? {
211210

212211
return result
213212
}
213+
214+
@Throws(JSONParseException::class)
215+
fun jsonParse(input: String): Any? {
216+
return jsonParse(StringJSONLexer(input))
217+
}

0 commit comments

Comments
 (0)