[R-pkg-devel] New package with C++ code causes R abort in RStudio, not in R console.
Luc De Wilde
Luc@DeW||de @end|ng |rom UGent@be
Tue Nov 12 18:49:14 CET 2024
Dear Vladimir,
thank you for your reply.
The model syntax is not simple though and the parser needs to look at the meaning in SEM terms to accept or reject certain things.
Moreover, this is only a first step and later other calculations need to be done in C++, which is why I find it important to know exactly why the code works in R console but not in RStudio, and of course what can be done to make it work in RStudio also.
Kind regards,
Luc De Wilde
________________________________________
Van: Vladimir Dergachev <volodya using mindspring.com>
Verzonden: dinsdag 12 november 2024 18:15
Aan: Luc De Wilde <Luc.DeWilde using UGent.be>
CC: r-package-devel using r-project.org <r-package-devel using r-project.org>; Yves Rosseel <Yves.Rosseel using UGent.be>
Onderwerp: Re: [R-pkg-devel] New package with C++ code causes R abort in RStudio, not in R console.
Hi Luc,
The standard tools for writing parsers are "flex" and "bison" - they
generate code automatically and so can save you a lot of effort. For
language with simple syntax you can get away with just using "flex".
Here are some examples:
Flex:
https://westes.github.io/flex/manual/Simple-Examples.html#Simple-Examples
Bison:
https://www.gnu.org/software/bison/manual/bison.html#Infix-Calc
best
Vladimir Dergachev
On Tue, 12 Nov 2024, Luc De Wilde wrote:
> Dear R package developers,
>
> I'm helping with the development of the lavaan package (see https://lavaan.ugent.be/) and currently writing a C++ version of the parser of the model syntax in lavaan. The package with C++ code is in https://github.com/lucdw/lavaanC.
>
> When testing with a bunch of models, there is one model that causes an abort of the R session in RStudio (on Windows), but in the R console or in a batch job it causes no errors. The model is the following :
> model <- '
> F1 =~ "a b"*X1
> F2 =~ a * X1 + 3*X2 # dat is hier een beetje commentaar
> # efa block 2
> efa("efa2")*f3 +
> efa("efa2")*f4 =~ y1 + y2 + y3 + y1:y3
> f4 := 3.14159 * F2
> F1 ~ start(0.76)*F2 + a*F2
> a == (b + f3)^2
> b1 > exp(b2 + b3) '
>
> and the translation can be tested - after installing lavaanC - with
>
> lavaanC::lav_parse_model_string_c(model)
>
> As mentioned, this causes an abort of the R session when executed in RStudio on Windows (10 or 11), but passes without problem in the R console or a batch job.
>
> Because many users are using RStudio I 'd like to tackle this problem, but don't know how to pinpoint the cause of the problem. I hope some of you have an idea how to handle this problem ...
>
> All the best,
>
>
> Luc De Wilde
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>
More information about the R-package-devel
mailing list