Re: [isabelle] sloccount for .thy files?



On Wed, 25 Jul 2012, Rafal Kolanski wrote:

We need something like sloccount (count lines of code in a file with comments removed) for Isabelle. It seems I have to hack up such a tool, but I worry that trying to do so quickly may result in not getting it right. I would much rather piggyback on a tool written by someone else already.

Does anyone know of such a tool, or a hackable approximation of one?

I don't know any approximations, only the official Isabelle functions for that. (According to Isabelle2012.)


This is how it works in Isabelle/Scala, e.g. with the "isabelle scala" toplevel loop:

  val syntax = isabelle.Outer_Syntax.empty
  syntax.scan("theory (* (* \n *) *) A {* *}")

You can then walk through the token list and remove comments, count newlines etc.

Note that the empty outer syntax does not know about any keywords, but that should be OK in this application.


There are also similar operations in src/Pure/Thy/thy_syntax.ML, but Isabelle/ML system programming is a bit old-fashioned. It is worth spending a little time getting acquainted with Isabelle/Scala; such an investment will pay off rather quickly for other projects.


	Makarius





This archive was generated by a fusion of Pipermail (Mailman edition) and MHonArc.