Hi Luc,
On Tue, 12 Nov 2024, Luc De Wilde wrote:
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.
What do you mean by "SEM terms" ? I have not seen a situation yet that a
grammar could not be handled by bison, it does have mechanism to deal with
exceptions to pure LR syntax.
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.
My thought was that perhaps some sort of memory issues occurs because of
the hand-written parser.
For example, one possibility is that stack sizes in R and Rstudio could be
different. So if you are parsing something recursively it might work in
one and not another.
The parsers generated by flex and bison are designed to handle arbitrary
length inputs.
best
Vladimir Dergachev
Kind regards,
Luc De Wilde
________________________________________
Van: Vladimir Dergachev <volo...@mindspring.com>
Verzonden: dinsdag 12 november 2024 18:15
Aan: Luc De Wilde <luc.dewi...@ugent.be>
CC: r-package-devel@r-project.org <r-package-devel@r-project.org>; Yves Rosseel
<yves.ross...@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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel
______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel