Version 25 of Nagelfar

Updated 2006-11-06 18:10:09

What: nagelfar

 Where: http://nagelfar.berlios.de
 Description: Nagelfar is a Tcl application to read a Tcl program and
        provide static syntax analysis - information regarding
        Tcl syntax errors like missing braces, incomplete commands, etc.
        Currently at version 1.1.5.
 Updated: 06/2006
 Contact: peter dot spjuth at space dot se

This tool by Peter Spjuth performs static syntax analysis. It is, moreover, extensible, with a customizable exposed syntax database.


As of June 2004, Version 1.0.1 is available. This version can process {expand}, but "[t]o get it to work you still need to generate your own syntax database from 8.5, and run Nagelfar in an 8.5 interpreter ..."

RLH {expand} is changing to {*}. Just an FYI.


From version 1.1, Nagelfar can help with simple Coverage Analysis.


Is there interest in teaching nagelfar about Itcl?

Peter Spjuth: Checking OO code is tricky. I personally don't use Itcl but checking Tk gives similar problems. Once I figure out how to do it well (and get enough time to do it) I'll probably start with Snit since I occasionally use that. After that Itcl is probably not too much work, but it is far into the future unless someone else does it.

The problem with OO is basically that with [cmd arg arg] it is obvious what command is checked, but with [$obj arg arg] you need to know what kind of object is contained in $obj.


RLH I tried 1.1.3 on OSX and I do not seem to be able to build a syntaxdb:

 robert$ sudo tclsh syntaxbuild.tcl 
 # Automatically generated syntax database.
 # Generated with syntaxbuild Revision: 1.25 

 lappend ::dbInfo {Tcl 8.4.13 unix}
 set ::dbTclVersion 8.4
 set ::knownGlobals {argc argv argv0 auto_index auto_oldpath auto_path env errorCode errorInfo tcl_interactive tcl_libPath tcl_library  set ::syntax(TreeCtrlLoad) 1
 set ::syntax(after) {r 1}
 set ::syntax(append) {n x*}
 set ::syntax(array) {s v x?}
 set {::syntax(array exists)} l
 set {::syntax(array names)} {v x? x?}
 set {::syntax(array set)} {n x}
 set {::syntax(array size)} v
 set {::syntax(array statistics)} v

There was actually a lot more lines...

Peter Spjuth: You didn't specify an output file name, so you got it on standard out. Try 'sudo tclsh syntaxbuild.tcl syntaxdb.tcl'

RLH I will so that. I don't remember having to before though. : )


HZe 2006-07-23 I really would like to use a syntax checker for my project, but it is a bigger project, meaning that there are many files. Most of them are just defining packages and are used later in other files. E.g.:

file1.tcl

  proc square {x} {
      return [expr {$x*$x}]
  } 
  package provide file1 0.1

file2.tcl

  package require file1
  proc main {argv} {
      puts [square [lindex $argv 0]]
  }
  main $argv

I've read, that Nagelfar is using two passes, the first to detect the procs and the second to check them. Here, it would be necessary to detect procs in all files first, then in the second pass use the information to do the check on all files. Is this possible using Nagelfar or do I miss something?

Peter Spjuth: One way is to check all files in one command. Nagelfar remembers procs defined in previous files when it checks the next:

 > nagelfar file1.tcl file2.tcl
 Checking file file1.tcl
 Checking file file2.tcl

This does not work so well if you have cross-calls between files. Then you can generate a header-file before checking:

 > nagelfar -header myprocs file1.tcl file2.tcl
 Checking file file1.tcl
 Checking file file2.tcl
 Writing "myprocs"
 > nagelfar myprocs file1.tcl 
 Checking file myprocs
 Checking file file1.tcl
 > nagelfar myprocs file2.tcl
 Checking file myprocs
 Checking file file2.tcl

[ Category Application

Category Debugging (=> Static syntax analysis)

Category Dev. Tools ]