Replies: 2 comments
-
I'm out and about, but you should almost certainly use the default Go lexer. For recursive constructs like {} I would probably capture them into some throwaway field. Use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First - huge thanks to Alec Thomas for this library. I've used it in the past for a custom SQL grammar and this is just amazing. Thank you!
Question
I'm trying to make a high level Go parser. I don't need to parse all the expressions. I just want the major blocks:
Basically, I want to capture the function signature and then the full body should just be a string capture - all new lines, whitespaces, etc.
I've tried a few methods such as the Stateful lexer but didn't get very far. This example is the furthest I got but is unquoting strings. I have the parser set to unquote strings due to the import statement.
Does anyone have suggestions I can try? It seems like I need a new parser with different rules for just the function body such as capture everything (.*) including other curly brackets but break out once the function body is closed.
I appreciate anyone's help on this - exhausted a lot of stack overflow and GPT questions :)
Test code:
Beta Was this translation helpful? Give feedback.
All reactions