Search in sources :

Example 1 with NudeEContext

use of antlrGenerated.L42Parser.NudeEContext in project L42 by ElvisResearchGroup.

the class Parser method parse.

public static synchronized Expression parse(String fileName, String s) {
    String old = Parser.fileName;
    Parser.fileName = fileName;
    try {
        checkForTab(s);
        checkForBalancedParenthesis(s);
        s = replaceORoundWithTab(s);
        NudeEContext ctxResult = parseCtx(s);
        Expression result = ctxResult.accept(new ToAst());
        return result;
    } finally {
        Parser.fileName = old;
    }
}
Also used : NudeEContext(antlrGenerated.L42Parser.NudeEContext) ToAst(sugarVisitors.ToAst) Expression(ast.Expression)

Example 2 with NudeEContext

use of antlrGenerated.L42Parser.NudeEContext in project L42 by ElvisResearchGroup.

the class Parser method parseCtx.

private static NudeEContext parseCtx(String s) {
    LoggedPrintStream lpsErr = LoggedPrintStream.create(System.err);
    System.setErr(lpsErr);
    try {
        NudeEContext ctxResult = getParser(s).nudeE();
        if (lpsErr.buf.length() != 0) {
            throw new ParseCancellationException("\n\n------------------------------------\nCurrent file: " + Parser.fileName + "\nParsing error:\n" + lpsErr.buf.toString());
        }
        return ctxResult;
    } finally {
        System.setErr(lpsErr.underlying);
    }
}
Also used : NudeEContext(antlrGenerated.L42Parser.NudeEContext) ParseCancellationException(org.antlr.v4.runtime.misc.ParseCancellationException)

Aggregations

NudeEContext (antlrGenerated.L42Parser.NudeEContext)2 Expression (ast.Expression)1 ParseCancellationException (org.antlr.v4.runtime.misc.ParseCancellationException)1 ToAst (sugarVisitors.ToAst)1