-
Notifications
You must be signed in to change notification settings - Fork 0
Description
(From we-like-parsers/pegen#84.)
Items in an alternative may be named, and the names may be referenced in actions. But there are some "forbidden" names. E.g. don't name an item p
, because (when generating C code) every rule parsing function has an argument named p
. There are other possible name clashes too: res
and mark
are always local variables. And there are many helper functions, with names like And of course anything that's a C reserved word (e.g. is_memoized
or singleton_seq
.if
) cannot be used either. Also there are systematic generated names like *_var
, *_type
and *_rule
.
It's easy to rename p
, mark
and res
in the generated code to start with an underscore (by convention, rule names don't start with _
, and maybe we should make this a hard requirement). I'm not sure we need to worry about the others, though we may have to warn about them in the docs.
When generating Python code there are other possible clashes, e.g. self
, mark
and cut
. We can handle these the same way. (There are a few others that seem less important, like ast
and of course Python builtins and keywords.)