Blocks ending with "end" #257
Replies: 4 comments
-
I'm not sure what the exact issue is (if you can include some code that compiles and illustrates your problem, that would be helpful), but this kind of thing will work: type Def struct {
Name string `"def" @Ident "(" ")" ":"`
Body []*Stmt `@@* "end"`
} A raw string such as |
Beta Was this translation helpful? Give feedback.
-
I have something that you suggested, but he doesn't find the end when there are two functions. I'll take another look to find the bug in my code, thanks. type Function struct {
Name string `"def" @Ident`
Args []*Arg `"(" ( @@ ( "," @@ )* )? ")"`
Return string `"-" ">" @Ident ":"`
Body []*Command `@@* "end"`
} |
Beta Was this translation helpful? Give feedback.
-
It seems to come from this type Command struct {
Pos lexer.Position
Print *Print `( @@ `
Expression *Expression `| @@ )`
} With only one, |
Beta Was this translation helpful? Give feedback.
-
I can't seem to make it work. I've created a repo |
Beta Was this translation helpful? Give feedback.
-
I want to end blocks with "end". It seems to work with when I have one element to match, but not an array [] where it includes end somehow.
My understanding the default parser in participle is C-oriented, which would mean { } blocks.
Do I need to change the lexer/parser to have
blocks?
Or do I need to tell blocks somehow (E.g. Body) that "end" is a keyword that should not be included in the match? Or do I do something wrong?
Beta Was this translation helpful? Give feedback.
All reactions