lark icon indicating copy to clipboard operation
lark copied to clipboard

Is it possible to parse parts of the input?

Open jjalowie opened this issue 2 weeks ago • 12 comments

What is your question?

I'm interested in writing a transformer for certain parts of input programs that wouldn't require a full language grammar. So let's say I have the below sample cpp code:

void function(int a, int b) {
  // body
}

I want to parse just function signatures and transform them e.g. by adding the '_' suffix to all argument names. I.e. the output for the above input program should be:

void function(int _a, int _b) {
  // body (unchanged)
}

How could I possibly achieve this using Lark?

jjalowie avatar Jun 17 '24 16:06 jjalowie