[antlr-interest] grammar to latex

Ana Nelson nelson.ana at gmail.com
Wed Jun 4 07:20:53 PDT 2008


The red boxes are where the grammar detects an error in syntax. (As I said,
the grammar isn't quite finished yet, so those should go away, at least for
valid ANTLR files.)

Regarding automatic linebreaks, I don't think it's currently supported in
pygments, but it should be possible to implement. I know for java code it's
almost a necessity, I've done it by hand before and it's no fun.



2008/6/4 Johannes Luber <JALuber at gmx.de>:

> > 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
>
> Looking through the files I noticed two problems, all in the Java example.
> The first is that the labels a1 and a2 aren't formatted correctly. The
> numbers are red-boxed. Also I haven't figured quite out what the red boxes
> should show actually. The second problem is that overly long lines don't
> receive automatic linebreaks. So some text is practically invisible. Can
> that be helped?
>
> Johannes
> >
> >
> >
> > 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
> > >>
> > >
> > >
>
> --
> Psssst! Schon vom neuen GMX MultiMessenger gehört?
> Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080604/4af0d13f/attachment.html 


More information about the antlr-interest mailing list