Octave, GNU Octave, Matlab, Scientific Computing, Language, Interpreter, Compiler, C++, LAPACK, Fortran, Fun , GNU

Saturday, June 16, 2007

Octave-Lint

This tool will possibly use the existing parser, and walk the AST to figure out
syntactically correct but semantically wrong constructs statically. This could mean
things in the BNF like stmt: expr op expr which can match semantically wrong constructs
due to compile time invisibily/scoping issues as in x = x + 1 . This statement is wrong
because variable x is un-initialized. So such errors can be discovered using Octave-lint, when someone writes it.

Essentially a bare-bones algorithms would involve
  1. Parse the file & report errors if any.
  2. If no errors, start the (Left-Right-Root) post-order traversal, of the AST.
  3. At each visitor try and note down order of variables into a static table.
    1. Note down variable creation
    2. Flag suspicious variables
    3. Flag undefined variables
    4. Flag possible 'typos' of variables by Levenshtein distance of the misspelt / undefined variable name with variables on the table. Min of this metric must give us a possible suggestion for the wrong typo variable.
    5. Have more heuristic error cases to be trapped in the visitor, based on static tables.
  4. Finally the collected errors/warnings are reported to user, based on input options.
  5. Additional tuning can be done to run Lint on a set of files, with functions defined elsewhere, and rules for specific usage.

I think this would make a really nice project for someone who wants to learn C++ basics and hack on a real piece of software. It would be a great first-dip into the Free Software Ocean.

Cheers,
Muthu

No comments:

Creative Commons License