[Geany-devel] Adding an R parser

Lex Trotman elextr at xxxxx
Fri Feb 19 10:25:38 UTC 2010


On 19 February 2010 21:10, Jon Senior <jon at restlesslemon.co.uk> wrote:

> On Fri, 19 Feb 2010 10:02:22 +0000
> Liviu Andronic <landronimirc at gmail.com> wrote:
> > Nice. Thanks for bringing up the patch.
>
> No problem... it had been bugging me for a while. It's in the tracker
> now so hopefully we'll see it in geany-0.19.
>
> > I have couple more issues with the current support for R in Geany.
> > It's mostly minor, but it affects readability of the code. The syntax
> > highlighting fails in some cases:
> > - for the line below, "sum" and "length" are both functions but will
> > be highlighted with different colours
> > > sum(mtcars$cyl); length(mtcars$cyl)
>
> That's the syntax highlighting. geany is recognising one as a function
> name and the other as a reserved keyword. Not sure why "sum" is being
> seen as a keyword though.
>

Thats because sum is listed as a keyword in Geanys filetypes.r file.
Someone who is knowledgeable in R should have a look and check the
filetypes.r file and submit a patch.

Theer are also lots of packages listed, probably need checking.


>
> > - a function similar to the one below will have "trim" and "qt"
> > highlighted differently.
> > > trim.qt <- function(x) sum(x)
> > > trim.qt(mtcars$cyl)
>
> geany doesn't seem to recognise that a . in R can be used as part of a
> variable / function name.
>

A quick look at the lexer in LexR.cxx from the Scintilla project looks like
it explicitly excludes '.' from identifiers, maybe the test is backward.
Again someone knowledgeable in R (and C++) should check it.

The lexer comes from the Scintilla project and is only used by Geany.  Geany
usually likes to keep an unmodified Scintilla version, so if you are sure
its a bug or if you actually make a patch, please submit it to the Scintilla
project www.scintilla.org



>
> > - so will an object, say,
> > > get.smth <- iris
> >
> > - objects don't seem recognised at all.
>
> In what sense? I think it doesn't highlight objects that you've
> created, although I could be wrong. To be honest I only really notice
> the highlighting for strings and the bracket closing.
>

AFAICT identifiers "should" be recognised as such but there is no
distinction between uses of the identifiers.

Cheers
Lex


>
> > Are these failures of the current parser implementation, or is this
> > something that one should expect? Thanks
>
> It's the syntax highlighting, not the tag parser (tags are things like
> function definitions or global variable definitions). I've not really
> looked at it enough to see how tuneable it is. It's been a while since
> I delved into the R template files. Maybe later today.
>
> Jon
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.geany.org/pipermail/devel/attachments/20100219/d1997846/attachment.html>


More information about the Devel mailing list