Pascal code checker!

Neil Cerutti horpner at yahoo.com
Thu Dec 13 10:27:26 EST 2007


On 2007-12-13, Dotan Cohen <dotancohen at gmail.com> wrote:
> On 13/12/2007, Tim Chase <python.list at tim.thechases.com> wrote:
>>  >> Oof!  Fond as I am of promoting pyparsing, writing a Pascal
>>  >> compiler (or even just syntax checker) is not a job I would
>>  >> tackle lightly, much less suggest to a new Python developer.
>>
>> True enough...thus my weeks/months/years estimate for such an
>> undertaking :)
>>
>> But if not mentioned, you know the next question would be "how do
>> I create a regular expression to match valid Pascal programs?"
>>
>
> Go track down the source code of an open source text editor
> that supports Pascal highlighting. Kate comes to mind. It's not
> written in Python, but it will have Pascal parsing code for the
> highlighter.

A syntax highlighter usually knows very little about the syntax
of a language. Mostly, it just finds keywords and highlights
them. The improvements beyond that will generally be haphazard,
e.g., the Vim syntax highlighting code for Python knows basically
what a function header looks like so it can highlight the
function name. It also (doesn't really) know how to figure out
what's a string and what isn't.

The auto-indenter is often smarter about syntax, but knows just a
small subset of syntax rules, enought to do proper indenting. For
some languages, e.g., Python, that's a fairly small subset. For
others, it's cumbersomely large and Vim's support is cruddy.

-- 
Neil Cerutti



More information about the Python-list mailing list