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

Reply via email to