kevinushey / sourcetools

Tools for reading, tokenizing, and parsing R code.
MIT License
77 stars 3 forks source link

validate_syntax does not complain about unexpected end of input #15

Open filipsch opened 8 years ago

filipsch commented 8 years ago

Is there a way to have validate_syntax() to also raise an error for the following examples?

validate_syntax("mean(1:3")
validate_syntax("x[y[1]")

Thanks for considering this!

kevinushey commented 8 years ago

This will become possible with the full parser implementation + diagnostics; right now the parser does report it (although it reports a bunch of nonsense and doesn't get the position right). Using the dev version of sourcetools:

> sourcetools:::parse_string("mean(1:3")
Warning in sourcetools:::parse_string("mean(1:3") :

  [0:0]: expected ',' or 'bracket'
  [0:0]: unexpected end of input
  [0:0]: unexpected token ''; expected type 'bracket'

So hopefully we'll have this soon 😃

filipsch commented 8 years ago

I see, thanks for this clarification. I'm looking forward to a full implementation of the parser then, awesome project!

filipsch commented 8 years ago

I've dug through a lot of the code that RStudio IDE uses for 'parsing diagnostics', and it seems that you're making parts of that available straight inside R now. Very exciting.

Is there a way for me to contribute to this project? Things you don't have the time for yourself that you'd like to see added? I'm happy to help in building out this package further.

kevinushey commented 8 years ago

I haven't had as much time as I'd like to work on this package lately, and don't have as clear a picture of where contributions would be helpful. I think once more of the core is tightened up there will be some places where contributions will be welcomed; hopefully that will come sooner than later!

(In particular, I need to get the C++ side to a state where it's possible to interact with the internal parse trees from R -- once we have that, there's a lot more that can be done, I think)