Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toml Parse Error with seemingly valid .toml file #20

Closed
DersWasTaken opened this issue Nov 29, 2022 · 3 comments
Closed

Toml Parse Error with seemingly valid .toml file #20

DersWasTaken opened this issue Nov 29, 2022 · 3 comments

Comments

@DersWasTaken
Copy link

DersWasTaken commented Nov 29, 2022

Hello! Im encountering a strange error, and after about an hour of attempting to fix it, have gotten nowhere. The code im running is below aswell as the entire error message. This issue also happens with decodeWithDefaults.

        val tomlMapper = tomlMapper {}

        val tomlFile = File(Bukkit.getServer().pluginManager.getPlugin("DawnPlugin").dataFolder, "config.toml")
        if(!tomlFile.exists()) {
            tomlFile.createNewFile()
        }
        val tomlFilePath = tomlFile.absolutePath

        tomlMapper.decode<Config>(tomlFilePath)
        println(config)
        
        //CONFIG CLASS
        
        data class Config(
          val messages: Messages,
         ) {
            data class Messages(val joinMessage: String, val leaveMessage: String, val chatFormat: String)
         }

        val defaultConfig = Config(
           messages = Config.Messages(
             joinMessage = "<green>[+] %playerName%",
            leaveMessage = "<red>[-] %playerName%",
            chatFormat = "%displayName% : %message%"
           )
         )

using this produces the error message below:

cc.ekblad.toml.model.TomlException$ParseError: toml parse error, on line 1: token recognition error at: ':'
	at cc.ekblad.toml.serialization.TomlErrorListener.syntaxError(TomlErrorListener.kt:21) ~[?:?]
	at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41) ~[?:?]
	at org.antlr.v4.runtime.Lexer.notifyListeners(Lexer.java:364) ~[?:?]
	at org.antlr.v4.runtime.Lexer.nextToken(Lexer.java:144) ~[?:?]
	at org.antlr.v4.runtime.BufferedTokenStream.fetch(BufferedTokenStream.java:169) ~[?:?]
	at org.antlr.v4.runtime.BufferedTokenStream.sync(BufferedTokenStream.java:152) ~[?:?]
	at org.antlr.v4.runtime.BufferedTokenStream.consume(BufferedTokenStream.java:136) ~[?:?]
	at org.antlr.v4.runtime.atn.ParserATNSimulator.execATN(ParserATNSimulator.java:537) ~[?:?]
	at org.antlr.v4.runtime.atn.ParserATNSimulator.adaptivePredict(ParserATNSimulator.java:393) ~[?:?]
	at cc.ekblad.toml.parser.TomlParser.key(TomlParser.java:378) ~[?:?]
	at cc.ekblad.toml.parser.TomlParser.key_value(TomlParser.java:333) ~[?:?]
	at cc.ekblad.toml.parser.TomlParser.expression(TomlParser.java:221) ~[?:?]
	at cc.ekblad.toml.parser.TomlParser.document(TomlParser.java:143) ~[?:?]
	at cc.ekblad.toml.serialization.TomlDeserializerKt.from(TomlDeserializer.kt:49) ~[?:?]
	at cc.ekblad.toml.serialization.TomlDeserializerKt.from(TomlDeserializer.kt:20) ~[?:?]
	at me.ders.Main.onEnable(Main.kt:59) ~[?:?]
	at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot-1.8.9.jar:git-Spigot-21fe707-741a1bd]
	at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot-1.8.9.jar:git-Spigot-21fe707-741a1bd]
	at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot-1.8.9.jar:git-Spigot-21fe707-741a1bd]
	at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot-1.8.9.jar:git-Spigot-21fe707-741a1bd]
	at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot-1.8.9.jar:git-Spigot-21fe707-741a1bd]
	at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414) [spigot-1.8.9.jar:git-Spigot-21fe707-741a1bd]
	at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378) [spigot-1.8.9.jar:git-Spigot-21fe707-741a1bd]
	at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333) [spigot-1.8.9.jar:git-Spigot-21fe707-741a1bd]
	at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263) [spigot-1.8.9.jar:git-Spigot-21fe707-741a1bd]
	at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [spigot-1.8.9.jar:git-Spigot-21fe707-741a1bd]
	at java.lang.Thread.run(Thread.java:750) [?:1.8.0_352]
Caused by: org.antlr.v4.runtime.LexerNoViableAltException
	at org.antlr.v4.runtime.atn.LexerATNSimulator.failOrAccept(LexerATNSimulator.java:309) ~[?:?]
	at org.antlr.v4.runtime.atn.LexerATNSimulator.execATN(LexerATNSimulator.java:230) ~[?:?]
	at org.antlr.v4.runtime.atn.LexerATNSimulator.match(LexerATNSimulator.java:114) ~[?:?]
	at org.antlr.v4.runtime.Lexer.nextToken(Lexer.java:141) ~[?:?]
	... 23 more
[messages]
joinMessage = "<green>[+] %playerName%"
leaveMessage = "<red>[-] %playerName%"
chatFormat = "%displayName% : %message%"
@DersWasTaken
Copy link
Author

Issue was also tested with example code provided by the github, same error happens.

@valderman
Copy link
Owner

That file does indeed look like it should be valid. I'll add it as a test case to the remove-antlr-dependency branch, which rewrites the parser entirely. I guess this is as good a reason as any to go ahead and release it.

valderman added a commit that referenced this issue Feb 5, 2023
valderman added a commit that referenced this issue Feb 5, 2023
@valderman
Copy link
Owner

This is fixed in version 1.2.0, which was just released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants