[R] Writing lgrindefs

Kjetil Kjernsmo kjetil.kjernsmo at astro.uio.no
Wed Apr 26 20:51:02 CEST 2000

Dear all,

I'm writing a lgrind definition for R. Lgrind is a program to produce
pretty program listings for inclusion in LaTeX documents. Does anybody
here have any experience with lgrindefs?

My definition now looks like this:
	:kw=while for in repeat if else switch break next\
	return stop warning function:

Most of this is cut'n'paste from other definitions.
Well, I haven't got it working, my lgrind says "no entry for language R"
when I give this file using the -d option. Never mind...
It is the definition itself that I hope someone will review. 

There are a few things to discuss. First, quotes: Can " and ' both be said
to be string start and end?

Second, lgrind has "character constants". 
- I can see that in e.g. Perl and C, the character constants start and end
  with '. Would this be a character constant in R as well (if they are
  not string start and ends)?
- I came to think of, could e.g. Inf, NA, TRUE etc. be reasonably called
  character constants?

Then, what characters other than letters and digits may occur in
identifiers? The .? 

Then, about the keywords: The keywords I now have are snatched from
ess-vars.el (a thank you is due to Tony! :-) ). I was thinking about,
however, having all the functions defined in base highlighted as keywords.
Would that be a good idea, and if it is, how can I extract the function
names most easily?

Finally, lgrind has regexps that you can use to include TeX math or normal
text etc. in comments. I have adopted what appears to be in use in most
definitions for other languages. Are there special conventions in use? 

Other ideas?

I think lgrind is very nice in producing pretty code for LaTeX documents,
so I hope someone is interested in joining me in producing a good
definition file.


Kjetil Kjernsmo
Graduate astronomy-student                    Problems worthy of attack
University of Oslo, Norway            Prove their worth by hitting back
E-mail: kjetikj at astro.uio.no                                - Piet Hein
Homepage <URL:http://www.astro.uio.no/~kjetikj/>
Webmaster at skepsis.no 

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list