Tuesday, September 22, 2009

GNU Source-Highlight 3.1.1

In this new version of GNU Source-Highlight some additions were made to the API of the library; the most important are:

  • access to static global LangDefManager, LangMaps is provided through the new class Instances so that there's no need to create continuously instances of these classes;
  • the library also provides now utility functions for accessing .lang and .outlang files;
  • functions are provided for setting the data dir option globally, in order to increase consistency in applications that use the library (changing such value globally makes sure that the change will be visible in all parts of the library).
Moreover, two new language definition files were added: Texinfo and Haskell (thanks to Sergey Astanin); here are two examples:

texinfo

(@ref{Generating References}).
\input texinfo @c -*-texinfo-*-
@c This file uses the @command command introduced in Texinfo 4.0.
@c %**start of header
@setfilename source-highlight.info
@include version.texi
@settitle GNU Source-highlight @value{VERSION}
@finalout
@c @setchapternewpage odd
@c %**end of header

@example
my example
@end example

@set myhomepage @uref{http://www.lorenzobettini.it}

field names, etc.) by relying on the program @emph{ctags},
@url{http://ctags.sourceforge.net}
@xref{My Long
Reference}.

@inforef{Introduction,,source-highlight-info}.

@c All the menus can be updated with the EMACS command
@c texinfo-all-menus-update, which is normally bound to C-c C-u C-a.
@menu
* Introduction:: What's it for?
* Installation:: Download and installation
* Invoking source-highlight:: How to run @command{source-highlight}.
* Language Definitions:: How to define an input language
* Problems:: Reporting bugs.
* Mailing Lists::
* Concept Index:: Index of concepts.
@end menu

This is an escaped @@ at symbol.

This ``is a string''.

@example
@i{/// read the files }FIXME@i{ of a directory }@@param@i{ }@b{<f} foo="bar"@b{>}

@b{#include} <stddef.h>
@b{#include} <stdio.h>
@b{#include} <sys/types.h>
@b{#include} <dirent.h>

int
@b{main} (void)
@{
DIR *dp;
@b{struct} dirent *ep;

dp = @b{opendir} ("./");
@b{if} (dp != NULL)
@{
@b{while} (ep = @b{readdir} (dp))
@b{puts} (ep->d_name);
(void) @b{closedir} (dp);
@}
@b{else}
@b{perror} ("Couldn't open the directory");

@b{return} 0;
@}

@end example



haskell

-- A test snippet based on
-- http://google-code-prettify.googlecode.com/svn/trunk/tests/prettify_test.html
--
-- A comment
These --> are --| not |-- comments
--but this is a comment again

module Foo(bar) where
import Blah
import BlahBlah(blah)
import Monads(Exception(..), FIO(..),unFIO,handle,runFIO,fixFIO,fio,
write,writeln,HasNext(..),HasOutput(..))

{- nested comments
- should {- just -} work -}
instance Thingy Foo where
a = b

data Foo :: (* -> * -> *) -> * > * -> * where
Nil :: Foo a b c
Cons :: a b c -> Foo abc -> Foo a b c

str = "Foo\\Bar"
chars = [ 'x', '\'', '\\', '\"', '\120', '\o100', '\xbeef' ] -- Escapes too
Not.A.Char = 'too long' -- Don't barf. Show that 't is a lexical error.

(ident, ident', Fo''o.b'ar)

(0, 12, 0x45, 0xA7, 0o177, 0O377, 0.1, 1.0, 1e3, 0.5E-3, 1.0E+45)

[1,2..10]

(#) = \x y -> s x y
where s x y = (x+y) `mod` 13

bar (x:_) = putStrLn x

main = do
let foo x = do { spam $ eggs x }
foo >>= bar

No comments: