[R] code to turn T into TRUE

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Fri Oct 18 09:55:00 CEST 2002


I don't think we have a complete tool.  You do really need to parse the
code, and relating the parsed code to your `beautiful formatting'
is the problem.

When I kept common S/R source code, I used a Perl script for the bulk of
this.  It is conservative, and does not process lines with quoted
expressions at all.  Basically it was

s/=(\s*)F([^A-Za-z0-9\.\"])/=$1FALSE$2/go;
s/=(\s*)T([^A-Za-z0-9\.\"])/=$1TRUE$2/go;
s/\{T\}/{TRUE}/go;
s/\{F\}/{FALSE}/go;

and that correctly converted my source code and help files.


On Fri, 18 Oct 2002 Mark.Bravington at csiro.au wrote:

> Does anyone have code that will methodically process R sourcecode, turning
> T's into TRUE and F's into FALSE? I got bored doing this by hand, after the
> first 30-odd functions-- there are hundreds left to do. I don't want to
> simply deparse everything, because that would destroy my beautiful
> formatting.
>
> The reason it's not trivial, is that comment lines, quotes, and split lines
> need to be kept track of. There are no syntax errors in the code (i.e. it
> all parses OK into functions).
>
> The absolute ideal would be if the code itself was in R (because I need to
> run this from R), but presumably if there was a Perl script, I could launch
> that from within R too.
>
> FWIW I'm running Windows 2000, and hovering between R1.5.1 and R1.6.0.
>
> Thanks for any help
>
> Mark
>
> *******************************
>
> Mark Bravington
> CSIRO (CMIS)
> PO Box 1538
> Castray Esplanade
> Hobart
> TAS 7001
>
> phone (61) 3 6232 5118
> fax (61) 3 6232 5012
> Mark.Bravington at csiro.au
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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