by Vincent » Sat Dec 20, 2008 12:48 pm
Download:(note: up-to-date version in next post)
DumBeX.tar.gz
- Source code distribution
- (12.62 KiB) Downloaded 112 times
Language: Objective Caml
License: GNU GPL
OS: Any
Description:DumBeX is a
filter, taking lines of
B notation on STDIN, and churning out corresponding
LaTeX code on STDOUT. This is useful if you are using the
B method and need to embed some code in a report: translate just what you need on demand or whole source files automatically.
Examples:

- excerpt of "showcase" in verbatim mode. Pink = B notation, black = LaTeX translation
showcase.pdf
- This file shows all B constructs supported by DumBeX
- (57.52 KiB) Downloaded 317 times
showcase-verb.pdf
- same as showcase.pdf, but there DumBeX is in verbatim mode, showing input B notation in pink
- (83.46 KiB) Downloaded 136 times
Usage:It is a filter. So
- Code: Select all
dumbex < file.B > file.B.tex
will do the translation. Note that
file.B.tex won't compile on its own: it is meant to be integrated into a LaTeX document, typically through an
\input command. I recommend writing
- Code: Select all
\definecolor{Bcomment}{rgb}{0.2,0.2,0.6}
\definecolor{Bkeyword}{rgb}{0.3,0,0}
\definecolor{Bverbatim}{rgb}{0.9,0.3,0.3}
\def\loadB#1{{\sffamily \noindent\input{#1.tex}}}
before
\begin{document} and then using
- Code: Select all
\loadB{file.B}
to integrate your translated B file into the document.
If you have several files, feel free to use some shell script to make it easier:
- Code: Select all
for i in *.b; do
dumbex < $i > $i".tex" 2> /dev/null
done
Note that the color definitions can be ommited if you specify predefined colors on the command-line of DumBeX. For instance
- Code: Select all
dumbex cc blue
will put comments in
blue instead of using the
Bcomment color. See source code, function
cl, for more information on command-line arguments.
Notes and restrictions: (in no particular order)
- I called it "dumb" because it is a simple regexp script, the initial version of which was hacked in rougly an hour, because I wanted a program to do the job now and didn't have time or motivation to do anything more subtle. There may be other such translators out there, but I couldn't find one on the net when I needed it. 'B' is such a dreadful keyword for internet search...
- I used my first afternoon of vacations to extend it to support most B operators.
- It is not a parser for B notation. Consequently, while it does the job in most cases, there are things it will never do: for instance, it will never be able to tell the difference between IF-the-keyword and IF-the-set-you-just-defined.
- It outputs the LaTeX code for each symbol directly. A more elegant solution would be to output commands defined in an external package, so as to allow the user to redefine some of them in her document. Until then, if you want different symbols, you'll have to change the source code.
- If you need any help with it, you are welcome to post here (avoid sending me a mail though).
END_OF_FILE

[b]Download:[/b]
(note: up-to-date version in next post)
[attachment=1]DumBeX.tar.gz[/attachment]
[attachment=0]dumbex_binaries.tar.gz[/attachment]
[b]Language:[/b] Objective Caml [b]License:[/b] GNU GPL [b]OS:[/b] Any
[b]Description:[/b]
DumBeX is a [url=http://en.wikipedia.org/wiki/Filter_(Unix)]filter[/url], taking lines of [url=http://en.wikipedia.org/wiki/B-Method][b]B[/b] notation[/url] on STDIN, and churning out corresponding [url=http://en.wikipedia.org/wiki/LaTeX][b]LaTeX[/b][/url] code on STDOUT. This is useful if you are using the [b]B [/b]method and need to embed some code in a report: translate just what you need on demand or whole source files automatically.
[b]Examples:[/b]
[attachment=4]dumbex1.png[/attachment]
[attachment=3]showcase.pdf[/attachment]
[attachment=2]showcase-verb.pdf[/attachment]
[b]Usage:[/b]
It is a filter. So [code]dumbex < file.B > file.B.tex[/code]will do the translation. Note that [i]file.B.tex[/i] won't compile on its own: it is meant to be integrated into a LaTeX document, typically through an [b]\input[/b] command. I recommend writing
[code]\definecolor{Bcomment}{rgb}{0.2,0.2,0.6}
\definecolor{Bkeyword}{rgb}{0.3,0,0}
\definecolor{Bverbatim}{rgb}{0.9,0.3,0.3}
\def\loadB#1{{\sffamily \noindent\input{#1.tex}}}[/code]before [b]\begin{document}[/b] and then using[code]\loadB{file.B}[/code]
to integrate your translated B file into the document.
If you have several files, feel free to use some shell script to make it easier:[code]for i in *.b; do
dumbex < $i > $i".tex" 2> /dev/null
done[/code]
Note that the color definitions can be ommited if you specify predefined colors on the command-line of DumBeX. For instance[code]dumbex cc blue[/code]will put comments in [i]blue[/i] instead of using the [i]Bcomment[/i] color. See source code, function [b]cl[/b], for more information on command-line arguments.
[b]Notes and restrictions:[/b] (in no particular order)
[list][*]I called it "dumb" because it is a simple regexp script, the initial version of which was hacked in rougly an hour, because I wanted a program to do the job [i]now[/i] and didn't have time or motivation to do anything more subtle. There may be other such translators out there, but I couldn't find one on the net when I needed it. 'B' is such a dreadful keyword for internet search...
[*]I used my first afternoon of vacations to extend it to support most B operators.
[*]It is [b]not[/b] a parser for B notation. Consequently, while it does the job in most cases, there are things it will never do: for instance, it will [i]never [/i]be able to tell the difference between IF-the-keyword and IF-the-set-you-just-defined.
[*]It outputs the LaTeX code for each symbol directly. A more elegant solution would be to output commands defined in an external package, so as to allow the user to redefine some of them in her document. Until then, if you want different symbols, you'll have to change the source code.
[*]If you need any help with it, you are welcome to post here (avoid sending me a mail though).[/list]
END_OF_FILE :)