We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
You can continue the conversation there. Go to discussion →
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
I believe that there might be some issue related to double quotes.
package main import ( "fmt" "github.com/alecthomas/participle/v2" "github.com/alecthomas/participle/v2/lexer" ) type Syntax struct { Strings []*String `@@*` } type String struct { Value string `'"' @character '"'` } var rules = lexer.MustSimple([]lexer.SimpleRule{ {`character`, `[^"]`}, }) var parser = participle.MustBuild[Syntax]( participle.Lexer(rules), ) func main() { fmt.Println(parser.String()) }
panic: String:1:1: Strings: invalid syntax: "\"\"\"" goroutine 1 [running]: github.com/alecthomas/participle/v2.MustBuild[...](...) /tmp/gopath1215137364/pkg/mod/github.com/alecthomas/participle/[email protected]/parser.go:55 main.init() /tmp/sandbox1046517504/prog.go:22 +0x112
Syntax = String* . String = '"' <character> '"' .
The text was updated successfully, but these errors were encountered:
You'll need to use:
Value string `"\"" @character "\""`
This limitation is, IIRC, because of how Participle uses the Go lexer internally.
Sorry, something went wrong.
Cool. I recommend documenting this behavior though. Thank you for your work :)
@alecthomas I tried to use your suggestion in my code sample, but it still results in error:
package main import ( "fmt" "os" "github.com/alecthomas/participle/v2" "github.com/alecthomas/participle/v2/lexer" ) type Syntax struct { Strings []*String `@@*` } type String struct { Value string `"\"" @character* "\""` } var rules = lexer.MustSimple([]lexer.SimpleRule{ {`character`, `[^"]`}, }) var parser = participle.MustBuild[Syntax]( participle.Lexer(rules), ) func main() { syntax, err := parser.ParseString("code", `"a"`) if err != nil { fmt.Println(err) os.Exit(1) } fmt.Printf("%v\n", syntax) }
code:1:1: invalid input text "\"a\""
No branches or pull requests
I believe that there might be some issue related to double quotes.
Code:
Output
Expected output
The text was updated successfully, but these errors were encountered: