Skip to content

Instantly share code, notes, and snippets.

@jurgenvinju
Created October 4, 2012 14:19
Show Gist options
  • Save jurgenvinju/3833802 to your computer and use it in GitHub Desktop.
Save jurgenvinju/3833802 to your computer and use it in GitHub Desktop.
A test file to experiment with the robust parsing feature of Rascal
module TestRecovery
extend lang::pico::\syntax::Main;
import util::IDE;
import ParseTree;
import IO;
public map[Production robust, CharClass lookaheads] robust
= (p:[range(10,10),range(59,59)] | /p:prod(label(_,sort("Statement")),_,_) := #Statement)
+ (p:[range(10,10),range(59,59),range(44,44)] | /p:prod(label(_,sort("IdType")),_,_) := #IdType);
public Program picoParse(loc l) = picoParse(readFile(l), l);
public Program picoParse(str x, loc l) {
Program p = parse(#start[Program], robust, x, l).top;
rprintln(p);
return p;
}
public void main() {
registerLanguage("Pico","pico", picoParse);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment