Skip to content

Instantly share code, notes, and snippets.

@hastebrot
Created December 8, 2011 15:33
Show Gist options
  • Save hastebrot/1447314 to your computer and use it in GitHub Desktop.
Save hastebrot/1447314 to your computer and use it in GitHub Desktop.
parboiled: Illegal rule definition: Unwrapped action expression!
import org.parboiled.BaseParser
import org.parboiled.Parboiled
import org.parboiled.Rule
import org.parboiled.annotations.BuildParseTree
import org.parboiled.parserunners.ReportingParseRunner
import org.parboiled.support.ParseTreeUtils
@BuildParseTree
class ExampleGroovyParser extends BaseParser {
// start = "a"+ "b"+
Rule start() { Sequence(OneOrMore(String("a")),
OneOrMore(String("b")), push("fin")) }
static void main(String[] args) {
ExampleGroovyParser parser = Parboiled.createParser(ExampleGroovyParser)
def parseRunner = new ReportingParseRunner(parser.start())
def input = "aabbb"
def result = parseRunner.run(input)
println ParseTreeUtils.printNodeTree(result)
}
}
import org.parboiled.BaseParser;
import org.parboiled.Parboiled;
import org.parboiled.Rule;
import org.parboiled.annotations.BuildParseTree;
import org.parboiled.parserunners.ReportingParseRunner;
import org.parboiled.support.ParseTreeUtils;
import org.parboiled.support.ParsingResult;
@BuildParseTree
public class ExampleJavaParser extends BaseParser<Object> {
// start = "a"+ "b"+
Rule start() { return Sequence(OneOrMore(String("a")),
OneOrMore(String("b")), push("fin")); }
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void main(String[] args) {
ExampleJavaParser parser = Parboiled.createParser(ExampleJavaParser.class);
ReportingParseRunner parseRunner = new ReportingParseRunner(parser.start());
String input = "aabbb";
ParsingResult result = parseRunner.run(input);
System.out.println(ParseTreeUtils.printNodeTree(result));
}
}
Exception in thread "main" org.parboiled.errors.GrammarException: Illegal rule definition: Unwrapped action expression!
at org.parboiled.support.Checks.ensure(Checks.java:49)
at org.parboiled.BaseActions.check(BaseActions.java:435)
at org.parboiled.BaseActions.push(BaseActions.java:172)
at org.parboiled.BaseActions$push.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
at ExampleGroovyParser.start(ExampleGroovyParser.groovy:12)
at ExampleGroovyParser$$parboiled.start(Unknown Source)
at ExampleGroovyParser$$parboiled$start.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at ExampleGroovyParser.main(ExampleGroovyParser.groovy:16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment