I have a set of rules under one production in my CFG that both have basically duplicated blocks of code, and could be handled in one. Is there a way to do this? The following example is what my code looks like:
numeric_with_modulus: DCNumericType {
numeric_type_token[mut nt] Percent number[n] => {
// do something
}
numeric_with_explicit_cast[mut nt] Percent number[n] => {
// do something very similar
}
}
Would be nice to have something like this:
numeric_with_modulus: DCNumericType {
numeric_type_token[mut nt] Percent number[n] |
numeric_with_explicit_cast[mut nt] Percent number[n] => {
// do the similar thing :p
}
}
of course, both rules would have to have the same parameters. or, same 'function' signature if that's the right term :p Since each block is a bit like a function; with the non-terminals / terminals being the parameters.
I have a set of rules under one production in my CFG that both have basically duplicated blocks of code, and could be handled in one. Is there a way to do this? The following example is what my code looks like:
Would be nice to have something like this:
of course, both rules would have to have the same parameters. or, same 'function' signature if that's the right term :p Since each block is a bit like a function; with the non-terminals / terminals being the parameters.