Re: [Compiler-sig] Re: example checkers based on compiler package
Moshe Zadka <moshez@math.huji.ac.il> writes:
On Mon, 6 Mar 2000, Jeremy Hylton wrote:
I think these kinds of warnings are useful, and I'd like to see a more general framework for them built are Python abstract syntax originally from P2C. Ideally, they would be available as command line tools and integrated into GUIs like IDLE in some useful way.
Yes! Guido already suggested we have a standard API to them. One thing I suggested was that the abstract API include not only the input (one form or another of an AST), but the output: so IDE's wouldn't have to parse strings, but get a warning class.
That would be seriously cool.
Something like a:
An output of a warning can be a subclass of GeneralWarning, and should implemented the following methods:
1. line-no() -- returns an integer 2. columns() -- returns either a pair of integers, or None 3. message() -- returns a string containing a message 4. __str__() -- comes for free if inheriting GeneralWarning, and formats the warning message.
Wouldn't it make sense to include function/class name here too? A checker is likely to now, and it would save reparsing to find it out. [little snip]
I'm hoping to collect a few more examples of checkers and generalize from them to develop a framework for checking for errors and reporting them.
Cool! Brainstorming: what kind of warnings would people find useful? In selfnanny, I wanted to include checking for assigment to self, and checking for "possible use before definition of local variables" sounds good. Another check could be a CP4E "checking that no two identifiers differ only by case". I might code up a few if I have the time...
Is there stuff in the current Compiler code to do control flow analysis? You'd need that to check for use before definition in meaningful cases, and also if you ever want to do any optimisation...
What I'd really want (but it sounds really hard) is a framework for partial ASTs: warning people as they write code.
I agree (on both points). Cheers, M. -- very few people approach me in real life and insist on proving they are drooling idiots. -- Erik Naggum, comp.lang.lisp
participants (1)
-
Michael Hudson