[antlr-interest] grammar to latex
Ana Nelson
nelson.ana at gmail.com
Tue Jun 3 16:26:20 PDT 2008
Okay, for anyone who is interested in colour and/or font syntax highlighting
of ANTLR grammars, say if you happen to be writing a book featuring loads of
ANTLR code snippets or something, examples are here (in no particular
order):
(temporary URLs)
http://dev.agent.ie/antlr-python-example.pdf
http://dev.agent.ie/antlr-java-example.pdf
http://dev.agent.ie/antlr-ruby-example.pdf
Adding new target languages takes about 30 seconds. Pygments is just
brilliant. :-)
The grammar's not quite finished yet, and I probably won't get back to it
for a week or two, but it's close enough to get the idea.
I did a quick hack just now to see if I could get typewriter, roman and sans
serif fonts in latex, and it worked. :-) (That's why those PDFs have
horrible unaligned code.) So, Felix, I think this might work for you.
If anyone needs this urgently feel free to contact me off-list, otherwise
I'll post here when the code is suitable for human consumption.
-Ana
2008/6/1 Ana Nelson <nelson.ana at gmail.com>:
> Hi, Felix,
>
> Don't worry, this wasn't your fault. :-) These things are just addictive.
> And, when I read your email I wasn't sure if this was exactly what were
> looking for so I just did this out of curiosity.
>
> If you want syntax highlighting using fonts rather than colours, this
> should be possible to implement in Pygments but it's not supported at the
> moment, just bold/italic etc. are. I think it'd just be a case of writing a
> custom latex formatter which emitted e.g. \textrm rather than \colorbox.
>
> It would probably be useful to have this option for people needing to
> publish in black and white. I might take a quick look, but I don't know if
> I'll have time to do this myself.
>
> Anyway, if you think you want to use this you might try installing
> Pygments, preferably the development version, and see how you get on with
> it.
>
> You could alternatively search for a syntax highlighter with font support
> already (I don't know if there is one or not) and write a grammar for that.
> Or, if you are just looking for very basic decorations, maybe an existing
> grammar would be close enough. (I used to use highlight
> http://www.andre-simon.de/ and it worked fine, but I never tried modifying
> a grammar.)
>
> -Ana
>
>
> 2008/5/31 Felix Dorner <felix_do at web.de>:
>
>> Hei Ana,
>>
>> gee, I hope I didn't keep you from socializing this weekend... The example
>> looks cool. I don' t know pygments, what I really would like is not syntax
>> coloring, but fontification, such that terminals (Strings in ' ' would get
>> typewriter font, braces and other ebnf specials roman, and all other stuff
>> (rules and subrules) italic. Would this be easy too?
>>
>> Felix
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080604/5b23edef/attachment.html
More information about the antlr-interest
mailing list