-
Notifications
You must be signed in to change notification settings - Fork 630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R: Add regular expression R parser #544
Conversation
@vhda, do you have interest to solve this in meta level? The biggest challenge is about Makefile; we have to integrate the translator into the ctags build process. Input is based on your work:
Run the translator called ctagsc(this should be ctagst):
ctagsc itself:
|
The weakness of this code is that bash is needed to compile. |
As you may have noticed, I've barely done much more than commenting on some PRs and/or issues. |
I see. I will add one more comment. Please, look at it. |
... I found a R parser implementation is in geany. |
Makes sense. I'll try to find some time along the weekend. |
Thank you. We don't have to be hurry. |
geany/geany@c67caf0 Originally authored by Ascher Stefan <stievie@utanet.at>
Basic R support should be working now. |
@vhda, thank you for taking time. How do you think about R_REGEX ifdef condition? So the question is which is better, crafted parser or regex parser? If these two implementations are complementary each other, let's use both but (One of the biggest surprising, when I started working on ctags, was that multiple implementations |
I know nothing about R, other than some of the examples I searched for while updating this parser. At this point there aren't many differences between the regex and line parsers, except that the line parser is able to find function definitions that cover more than one line. Nevertheless, I think that a line parser is probably faster and more extensible than a regex parser, so I've kept the first. |
@vhda, I see. Thank you. LGTM. I have one more request. Could you add a test case for `l' kind? |
Hmm... something is fishy here. > ./ctags -o - Units/parser-r.r/r-extended.d/input.r
.First Units/parser-r.r/r-extended.d/input.r /^.First <- function() {$/;" f
MASS Units/parser-r.r/r-extended.d/input.r /^ library(MASS) # attach a package$/;" l
file.path(Sys.getenv("HOME" Units/parser-r.r/r-extended.d/input.r /^ source(file.path(Sys.getenv("HOME"), "R", "mystuff.R"))$/;" s But expected.ctags is incorrect and |
I tried. Something wrong. Maybe a bug of units. I will fix it. |
expected.ctags should be expected.tags. |
If units cannot find expected.tags file, it reports "passed". |
Interesting. The output is helpful for a user who wants to understand the code. I will user ctags for understanding the target code, so I myself loves this tag. |
My bad... but could I ask you to modify units output to include something like:
|
Changes are based on this StackOverflow question: http://stackoverflow.com/questions/32206608/ctags-and-r-regex * Add two new types: global variables and function variables. * Require a '(' after the function in order to guarantee distinction between variable and function declarations. * Add description to all tag types. * Add test cases.
Add support for global and function variables to match functionality of the regex parser.
I see. Good idea. I should do so. |
LGTM. |
R: Add regular expression R parser
Hi @vhda and @masatake , thanks for adding R support. I have however one problem. If I create a x <- 2 Then add to my ctags file:
and finally run
On the the other hand if I remove the regex from my ctags file (in order to use the new
Is that the expected behavior? If I now rename my |
@petobens apparently I've forgot to also include |
Fixed in #553 |
@vhda awesome thank you very much! I have one last question. Suppose I have two files: bar <- function (x) {
return(x)
} and ii) source("bar.R")
print(bar(2)) Ideally I would like to jump from |
That really depends on the editor you are using, but in general you don't need to follow the "include" statement, you simply search for the tag "bar". |
@vhda I'm using VIm. I will try what you suggested. Thanks. |
* Use $BASH_VERSION to check if current shell is bash. * Default shell is now /bin/sh (it would not work if it was non SH POSIX shell, like /bin/tcsh). * Typo fix.
Based on this StackOverflow question:
http://stackoverflow.com/questions/32206608/ctags-and-r-regex