unexpected token problem #258
-
Hey, I need to parse following expression:
in the following struct: type Expr struct {
Separtor string `parser:"'[$' @Ident '$'"`
Values []string `parser:"@Ident ('|' @Ident)+ ']'"`
} But when I do it, I receive error parser, err := participle.Build[Expr]()
if err != nil {
log.Fatal(err)
}
const text = "[$ string $a|b|c]"
ast, err := parser.ParseString("", text)
if err != nil {
log.Fatal(err)
} What is wrong? |
Beta Was this translation helpful? Give feedback.
Answered by
alecthomas
Aug 10, 2022
Replies: 1 comment
-
The problem is that |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mr-linch
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem is that
[
and$
are separate tokens but when you have'[$'
you're asking the parser to match a single token with those two characters. You need to change it to'[' '$'
.