Unix Review > Archives > 2002 > April 2002

April 2002

Regular Expressions: Syntax Checking the Scripting Way

by Cameron Laird and Kathryn Soraiz

The static syntax validation of pychecker and similar utilities can improve the quality of your programs.

That's not the only way, of course. There are all sorts of tools and techniques to help you manage the correctness of the code you write. Our last "Regular Expressions" column, for example, presented Erlang as a language designed to make it easier to write correct programs.

Static syntax analysis, though, is a particularly low-cost way to improve your programs. It fits the "scripting mentality" this column regularly advertises in that you can try out syntax checkers for yourself with little effort and make your own quick judgment about whether they fit your needs.

What "Syntax Analysis" Means

"Static syntax analysis" is what lint does for C programmers, or validators for HTML coders. These programs report on constructions that generally can be compiled or browsed respectively, but are still hazardous. Typical lint warnings include implicit casts and suspicious assignments: did programmers really intend:

     if (counter = limit) return;
   

or was it:

     if (counter == limit) return;
   
they wanted? Both of these are syntactically valid. Experience has shown, however, that the former often appears as a misspelling of the latter. Syntax analyzers draw attention to source that has this sort of potential for mistake.

Comparison with "spelling checkers" is apt, in fact. The "feel" of a syntax analyzer is much like that of a spelling checker. Different people make different uses for each; some engineers run lint every time they compile, others never, and most seem to do it only for "final drafts."

Sys Admin Spotlight

CMP DevNet Spotlight

Christmas Chaos
Jerry shares his gift recommendations for tech-savvy friends and family.

In the News

CD-ROM

Sys Admin and The Perl Journal CD-ROM version 11.0

Version 11.0 delivers every issue of Sys Admin from 1992 through 2005 and every issue of The Perl Journal from 1996-2002 in one convenient CD-ROM!

Order now!




MarketPlace

Get the ports you need for your VMs to succeed.
HP network adapters help get the most from your virtualized servers. Learn more at HP.IntelVT.com.

BugSplat - Automatic Crash Analysis
Fast online exception analysis. Capture customer crash data online.

Flowcharts from C/C++ code -- Free trial download
Understand C/C++ code in less time. A new team member ? Inherited legacy code ? Get up to speed faster with Crystal Flow for C/C++. Code-formatting improves readability. Flowcharts are integrated with code browser. Export flowcharts to Visio.

Discover WinDev 11 RAD
and develop 10 times faster ! ALM, IDE, .Net, PDF, 5GL, Database, 64-bit, etc. Free Express version

Wanna see your ad here?