I would expect using #"..."# would avoid any such issues with lexing, even if the characters are unprintable.
Here's a stack trace from pkl project package:
An unexpected error has occurred. Would you mind filing a bug report?
org.pkl.core.parser.LexParseException$ParseError: No viable alternative at input `(Regex(#"[ --�𐀀-\r\n\t]`.
at org.pkl.core.parser.Parser$1.syntaxError(Parser.java:201)
at org.pkl.core.parser.Parser$1.syntaxError(Parser.java:180)
at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:44)
at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:543)
at org.pkl.core.parser.ErrorStrategy.reportNoViableAlternative(ErrorStrategy.java:41)
at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:139)
at org.pkl.core.parser.antlr.PklParser.expr(PklParser.java:4159)
at org.pkl.core.parser.antlr.PklParser.expr(PklParser.java:3996)
at org.pkl.core.parser.antlr.PklParser.type(PklParser.java:2614)
at org.pkl.core.parser.antlr.PklParser.typeAnnotation(PklParser.java:1951)
at org.pkl.core.parser.antlr.PklParser.classProperty(PklParser.java:1360)
at org.pkl.core.parser.antlr.PklParser.classBody(PklParser.java:1073)
at org.pkl.core.parser.antlr.PklParser.clazz(PklParser.java:859)
at org.pkl.core.parser.antlr.PklParser.module(PklParser.java:454)
at org.pkl.core.parser.Parser.parseProduction(Parser.java:91)
at org.pkl.core.parser.Parser.parseModule(Parser.java:44)
at org.pkl.core.parser.Parser.parseModule(Parser.java:49)
at org.pkl.core.ast.builder.ImportsAndReadsParser.parse(ImportsAndReadsParser.java:59)
at org.pkl.core.project.ProjectPackager.getImportsAndReads(ProjectPackager.java:423)
at org.pkl.core.project.ProjectPackager.validateImportsAndReads(ProjectPackager.java:381)
at org.pkl.core.project.ProjectPackager.validatePklImportsAndReads(ProjectPackager.java:324)
at org.pkl.core.project.ProjectPackager.doPackage(ProjectPackager.java:149)
at org.pkl.core.project.ProjectPackager.createPackages(ProjectPackager.java:122)
at org.pkl.cli.CliProjectPackager.doRun(CliProjectPackager.kt:88)
at org.pkl.commons.cli.CliCommand.run(CliCommand.kt:45)
at org.pkl.cli.commands.ProjectCommand$Companion$PackageCommand.run(ProjectCommand.kt:145)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:198)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:211)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:211)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:18)
at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:400)
at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:397)
at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:415)
at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:440)
at org.pkl.cli.Main$main$1.invoke(Main.kt:52)
at org.pkl.cli.Main$main$1.invoke(Main.kt:40)
at org.pkl.commons.cli.CliMainKt.cliMain(CliMain.kt:31)
at org.pkl.cli.Main.main(Main.kt:40)
Originally created by @masp on GitHub (Feb 18, 2024).
Version
```
Documents/cfnpkl » pkl -v
Pkl 0.25.1 (macOS 14.1, native)
```
`break.pkl`
```
A = #"[ --�𐀀-
]*"#
```
See playground: https://pkl-playground.vercel.app/?share=individual-pure-stomach
## Expected behavior
I would expect using `#"..."#` would avoid any such issues with lexing, even if the characters are unprintable.
Here's a stack trace from `pkl project package`:
```
An unexpected error has occurred. Would you mind filing a bug report?
org.pkl.core.parser.LexParseException$ParseError: No viable alternative at input `(Regex(#"[ --�𐀀-\r\n\t]`.
at org.pkl.core.parser.Parser$1.syntaxError(Parser.java:201)
at org.pkl.core.parser.Parser$1.syntaxError(Parser.java:180)
at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:44)
at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:543)
at org.pkl.core.parser.ErrorStrategy.reportNoViableAlternative(ErrorStrategy.java:41)
at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:139)
at org.pkl.core.parser.antlr.PklParser.expr(PklParser.java:4159)
at org.pkl.core.parser.antlr.PklParser.expr(PklParser.java:3996)
at org.pkl.core.parser.antlr.PklParser.type(PklParser.java:2614)
at org.pkl.core.parser.antlr.PklParser.typeAnnotation(PklParser.java:1951)
at org.pkl.core.parser.antlr.PklParser.classProperty(PklParser.java:1360)
at org.pkl.core.parser.antlr.PklParser.classBody(PklParser.java:1073)
at org.pkl.core.parser.antlr.PklParser.clazz(PklParser.java:859)
at org.pkl.core.parser.antlr.PklParser.module(PklParser.java:454)
at org.pkl.core.parser.Parser.parseProduction(Parser.java:91)
at org.pkl.core.parser.Parser.parseModule(Parser.java:44)
at org.pkl.core.parser.Parser.parseModule(Parser.java:49)
at org.pkl.core.ast.builder.ImportsAndReadsParser.parse(ImportsAndReadsParser.java:59)
at org.pkl.core.project.ProjectPackager.getImportsAndReads(ProjectPackager.java:423)
at org.pkl.core.project.ProjectPackager.validateImportsAndReads(ProjectPackager.java:381)
at org.pkl.core.project.ProjectPackager.validatePklImportsAndReads(ProjectPackager.java:324)
at org.pkl.core.project.ProjectPackager.doPackage(ProjectPackager.java:149)
at org.pkl.core.project.ProjectPackager.createPackages(ProjectPackager.java:122)
at org.pkl.cli.CliProjectPackager.doRun(CliProjectPackager.kt:88)
at org.pkl.commons.cli.CliCommand.run(CliCommand.kt:45)
at org.pkl.cli.commands.ProjectCommand$Companion$PackageCommand.run(ProjectCommand.kt:145)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:198)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:211)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:211)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:18)
at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:400)
at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:397)
at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:415)
at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:440)
at org.pkl.cli.Main$main$1.invoke(Main.kt:52)
at org.pkl.cli.Main$main$1.invoke(Main.kt:40)
at org.pkl.commons.cli.CliMainKt.cliMain(CliMain.kt:31)
at org.pkl.cli.Main.main(Main.kt:40)
```
Looking at the language spec more, I realize the issue is the \n in the raw literal. To do a multiline raw literal, you need to use #"""..."""# instead. I'm leaving this open in case the error message can be improved to match what's reported with pkl eval.
@masp commented on GitHub (Feb 18, 2024):
Looking at the language spec more, I realize the issue is the `\n` in the raw literal. To do a multiline raw literal, you need to use `#"""..."""#` instead. I'm leaving this open in case the error message can be improved to match what's reported with pkl eval.
@stackoverflow commented on GitHub (Feb 19, 2024):
We plan to move out of ANTLR at some point which should improve parser errors. You are right that the message could be better.
@stackoverflow commented on GitHub (Feb 19, 2024):
We plan to move out of ANTLR at some point which should improve parser errors. You are right that the message could be better.
I'm going to close this as it's behaving correctly. We will improve these error messages when we manage to get off of ANTLR as our parser as Islon mentioned.
@bioball commented on GitHub (Feb 21, 2024):
I'm going to close this as it's behaving correctly. We will improve these error messages when we manage to get off of ANTLR as our parser as Islon mentioned.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @masp on GitHub (Feb 18, 2024).
Version
break.pklSee playground: https://pkl-playground.vercel.app/?share=individual-pure-stomach
Expected behavior
I would expect using
#"..."#would avoid any such issues with lexing, even if the characters are unprintable.Here's a stack trace from
pkl project package:@masp commented on GitHub (Feb 18, 2024):
Looking at the language spec more, I realize the issue is the
\nin the raw literal. To do a multiline raw literal, you need to use#"""..."""#instead. I'm leaving this open in case the error message can be improved to match what's reported with pkl eval.@stackoverflow commented on GitHub (Feb 19, 2024):
We plan to move out of ANTLR at some point which should improve parser errors. You are right that the message could be better.
@bioball commented on GitHub (Feb 21, 2024):
I'm going to close this as it's behaving correctly. We will improve these error messages when we manage to get off of ANTLR as our parser as Islon mentioned.