[Python-Dev] Needing help to change the grammar

"Martin v. Löwis" martin at v.loewis.de
Sat Apr 11 07:45:49 CEST 2009


> It appears to be a simple change, but strangely, I'm not being able to
> perform it. I already made correct modifications in Grammar/Grammar
> file, the new keywords already appear in Lib/keyword.py and I also
> changed the function validate_comp_op in Modules/parsermodule.c:
>> static int
> validate_comp_op(node *tree)
> {
> (...)
> else if ((res = validate_numnodes(tree, 2, "comp_op")) != 0) {
> res = (validate_ntype(CHILD(tree, 0), NAME)
> && validate_ntype(CHILD(tree, 1), NAME)
> && (((strcmp(STR(CHILD(tree, 0)), "não") == 0)
> && (strcmp(STR(CHILD(tree, 1)), "é") == 0))
> || ((strcmp(STR(CHILD(tree, 0)), "não") == 0)
> && (strcmp(STR(CHILD(tree, 1)), "em") == 0))));
> if (!res && !PyErr_Occurred())
> err_string("operador de comparação desconhecido");
> }
> return (res);
> }
>
Notice that Python source is represented in UTF-8 in the parser.
It might be that the C source code has a different encoding, which
would cause the strcmp to fail.
Regards,
Martin


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /