Skip to content
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

cannot parse file #250

Closed
blset opened this issue Aug 23, 2018 · 7 comments
Closed

cannot parse file #250

blset opened this issue Aug 23, 2018 · 7 comments

Comments

@blset
Copy link

blset commented Aug 23, 2018

Hello

Trying unititzer on a 50 lines script, but got the answer

Error in prsdat_recurse(expr, parse.dat, top.level = 0L) :
Internal Error: mismatch between expression and parse data; contact maintainer.
Warning in parse_tests(x, comments = TRUE) :
Unable to recover comments in parse; attempting simple parse
| 0/0 tests passed; nothing to review.

I can send you the script separately, but do not want to publish it on line

thanks

@brodieG
Copy link
Owner

brodieG commented Aug 23, 2018

Yes I will need the script to debug. Ideally if you could reduce it to something that still causes the error but does not contain proprietary data, and post that, would be the best for future reproducibility. You can sequentially delete half of the script (and then half of the remainder) to do a binary search for the problem code.

One question: are you using special UTF-8 characters?

Also, please post sessionInfo() output.

@blset
Copy link
Author

blset commented Aug 23, 2018

here is the fragment

path = file.path("data-raw", "2017","chains")

chain <- foreach(
    el = iter(df, by = "row"),
    .errorhandling = "pass"
) %do%
{
    init <- new(
        el$class
        # prefix
    )

}

also attached as a txt


R version 3.5.0 (2018-04-23)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib

locale:
[1] fr_FR.UTF-8/fr_FR.UTF-8/fr_FR.UTF-8/C/fr_FR.UTF-8/fr_FR.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] roci_0.2.1        glue_1.3.0        unitizer_1.4.5    foreach_1.4.4     rlist_0.4.6.1    
 [6] RPostgreSQL_0.6-2 DBI_1.0.0         magrittr_1.5      data.table_1.11.4 itertools_0.1-3  
[11] iterators_1.0.9  

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.18     compiler_3.5.0   ensurer_1.1      tools_3.5.0      testthat_2.0.0  
 [6] digest_0.6.15    packrat_0.4.9-3  jsonlite_1.5     memoise_1.1.0    lattice_0.20-35 
[11] rlang_0.2.1      Matrix_1.2-14    rstudioapi_0.7   diffobj_0.1.11   commonmark_1.5  
[16] yaml_2.1.19      parallel_3.5.0   luzlogr_0.2.0    withr_2.1.2      stringr_1.3.1   
[21] roxygen2_6.1.0   xml2_1.2.0       desc_1.2.0       devtools_1.13.6  rprojroot_1.3-2 
[26] grid_3.5.0       R6_2.2.2         survival_2.42-3  backports_1.1.2  codetools_0.2-15
[31] splines_3.5.0    assertthat_0.2.0 stringi_1.2.4    survey_3.33-2    crayon_1.3.4  
[test-preambule.txt](https://github.com/brodieG/unitizer/files/2315457/test-preambule.txt)

@blset
Copy link
Author

blset commented Aug 23, 2018

using also french accented characters

@brodieG
Copy link
Owner

brodieG commented Aug 23, 2018

Great, thanks for taking the time to do this.

One immediate comment is that while there is obviously a problem with the parsing, it seems that the fallback simple parsing is working fine. The parsing that fails is the one that tries to extract the comments and associates the comments with the expressions. So while you'll get that (caught) error and the warning, everything will work fine other than you won't be able to see the comments within unitizer.

The reason this all does not appear to be working, I think, is that there aren't actually any tests in the file as far as unitizer is concerned. A test is an expression that produces visible output (i.e. would print something to the console). To make your code a test you would need:

chain <- foreach( el = iter(df, by = "row"), .errorhandling = "pass") %do% {...}
chain    # this produces visible output, and is therefore a test

or alternatively:

(chain <- foreach( el = iter(df, by = "row"), .errorhandling = "pass") %do% {...})

For more details you can see the "What Constitutes a Test?" section of vignette(package='unitizer', 'u2_tests').

I'll explore the parsing issue to see what's going on there, but that alone should not prevent unitizer from working.

@blset
Copy link
Author

blset commented Aug 23, 2018

Thanks for the feedback

I got the error on a file with a test in it but suppressed anything that did not suppress the parse error before sending you the offending example.

But indeed, that does not prevent using unitizer, just removed all the comments and it worked without warning.

@blset blset closed this as completed Aug 23, 2018
@brodieG
Copy link
Owner

brodieG commented Aug 23, 2018

If you don't mind I'm going to leave this open as a reminder to look into the parsing. It should work, really.

@brodieG brodieG reopened this Aug 23, 2018
@brodieG brodieG added the bug label Aug 23, 2018
@brodieG brodieG added this to the 1.4.6 milestone Aug 23, 2018
@blset
Copy link
Author

blset commented Aug 23, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants