FriCAS Syntax Highlighting

Syntax highlighting seems to be an absolute necessity for editing any source code. However Spad, the language used in FriCAS/Axiom, is not so widespread to have syntax highlighting in major ordinary user text editors, like gedit.

Fortunately, one can enable syntax highlighting for Axiom files in vim. Just follow the instructions on MathAction site.

But what if you are not a hardcore linux programmer to use vim? For those who knows only :q! vim command there is an editor called Cream. Basically, Cream is the Vim, but with interface you used to in Notepad, Gedit, Kate or whatever you have.

After you have installed Cream and Axiom highlighting file you are ready to write .input (or .spad) files:

FriCAS .input file in Cream.

And a small tip for Cream — if you want to highlight matching brackets study the howto in Cream’s FAQ.

NOTE. There was emacs mode for Axiom, with syntax highlighting, more information is available at MathAction. I’ve never used emacs so neither I tried it for axiom.

Highlighting FriCAS code in your blog.

Vim also allows you to produce colored html from the source file:

)clear all

q : Integer -> Symbol
q i == subscript('q, [1::OutputForm])

p : Integer -> Symbol
p i == subscript('p, [1::OutputForm])

Hamiltonian : Expression(Float)
Hamiltonian == (p 1)^2 + (q 1)^2

PoissonBracket : (Expression(Float), Expression(Float)) -> Expression(Float)
PoissonBracket(f, g) == D(f, q 1) * D(g, p 1) - D(f, p 1) * D(g, q 1)

This can be achieved with the command

gvim MyFile.input +TOhtml '+w! out.html' '+qall!'

That’s all.

Advertisements
This entry was posted in FriCAS, Tips and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s