Hey there folks, I was wondering if anyone could point me in the right direction. I'm looking into parsing partial/invalid Ruby code, specifically for the intent of type inference for code completion. (See http://soc.jayunit.net... I've disappeared under school work for a while, but am trying to reach the surface under the guise of a project for my Language Processors/Compiler Construction course ;) The biggest roadblock I'd hit upon, and would like to revisit, is the fact that,inside an IDE code completion (and therefore type inference) is often requested at a point at which the code is not syntactically valid. I.e.:
def foo if ( cond ) puts myvar. # invoke completion class MyKlass class << self; def method #... and so on So we're in the middle of a method-send on the myvar expr, a puts call, an if statement, and a method definition node, none of which are closed before the MyKlass class declaration node is opened (or, equally often, EOF is hit when we are ten nodes deep). My knowledge of error hooks inside parsers is spotty at best (and limited to error symbols in yacc-based Jay), so I appeal to you all: is there research on heuristics in this area I can read up on? Is there such error recovery functionality in C-Ruby's parse.y (I spy some nice yyerror() calls in there, do they bubble up into JRuby's Jay parser?) or Rubyfront's ruby.g (didn't see any, but I don't know ANTLR)? If not, any thoughts on the idea? Is this something that can be usefully resolved via error symbols? (Perhaps I am simply ignorant of an error-recovery enabling flag in my trusty JRuby parsing calls, and would be better served directing inquiry to the JRuby list?) I'd rather not just blast an arbitrary number of close-parens and "end"s at the cursor position until a valid parse surfaces, the quickest-and-dirtiest solution that originally came to mind ; ) Thanks very much for any input! Jason -- Jason Morrison [EMAIL PROTECTED] http://jayunit.net (585) 216-5657
_______________________________________________ Rubygrammar-grammarians mailing list [email protected] http://rubyforge.org/mailman/listinfo/rubygrammar-grammarians
