Ka-Ping Yee wrote: > > On Tue, 4 Jul 2000, Ka-Ping Yee wrote: > > It turns out that this should be quite easy. If it weren't > > past 4am i would be posting a patch instead of just a verbal > > suggestion right now -- but here's how to do it. > > Okay, done. Looks fine. +1 on the concept. 2 things about the patch: > > >>> if 3: > ... 3 > File "<stdin>", line 2 > 3 > ^ > SyntaxError: expected indent here I'd remove the word "here" so that the error msg is self-contained. "expected indent" & "expected dedent" are fine. > The internal changes are: > > 1. Added E_TOODEEP (too many indentation levels) and > E_DEDENT (no matching outer block for dedent) to errcode.h. > > 2. Made PyTokenizer_Get (in tokenizer.c) return E_TOODEEP and > E_DEDENT instead of printing messages to stderr; added > corresponding error messages in err_input (in pythonrun.c). > > 3. Renamed E_INDENT to E_TABSPACE. > > 4. Added int *expected_ret argument to PyParser_AddToken; on > a syntax error, PyParser_AddToken (in parser.c) places the > expected token type (if any) into this output parameter. I'd suggest passing a pointer to the perrdetail structure (to the whole error, that is), instead of a pointer to one of its fields. > > 5. Added "token" and "expected" to struct perrdetail; made > parsetok (in parsetok.c) copy the current token into "token" > and the expected token into "expected" on a syntax error. > > 6. Added checks in err_input (in pythonrun.c) to print more > detailed error messages if err->token or err->expected > happens to be INDENT or DEDENT when a syntax error occurs. > > This leaves the door open for err_input to say more interesting > things about the syntax error if it wants, based on the information > in err->token and err->expected, though i haven't added any more > detailed messages except for the ones about indentation for now. > > > Look good to you? > Yes. -- Vladimir MARANGOZOV | Vladimir.Marangozov@inrialpes.fr http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4