/** * Throw syntax error. * * @param error the error * @throws org.matheclipse.parser.client.SyntaxError the syntax error */ protected void throwSyntaxError( final String error ) throws SyntaxError { throw new SyntaxError( fCurrentPosition - 1, rowCount, fCurrentPosition - fCurrentColumnStartPosition, getErrorLine(), error, 1 ); }
public static int syntaxLength(final String str, EvalEngine engine) throws SyntaxError { try { ExprParser parser = new ExprParser(engine); parser.parse(str); } catch (final SyntaxError e) { return e.getStartOffset(); } return str.length(); }
console = new MMAConsole(); } catch (final SyntaxError e1) { e1.printStackTrace(); return;
return super.call(); } catch (final SyntaxError se) { String msg = se.getMessage(); System.err.println(msg); System.err.println();
} catch (final SyntaxError e1) { e1.printStackTrace(); return;
String msg = se.getMessage(); stderr.println(msg); stderr.println();
/** * Reevaluate the last <code>expression</code> (possibly after a new variable assignment). * * @return * @throws SyntaxError */ public IExpr eval() { if (fExpr == null) { throw new SyntaxError(0, 0, 0, " ", "No parser input defined", 1); } return eval(fExpr); }
@Override public IExpr evaluate(final IAST ast) { Validate.checkSize(ast,2); if (!(ast.get(1) instanceof IStringX)) { return null; } final String str = ast.get(1).toString(); try { new Parser().parse(str); } catch (final SyntaxError e) { return F.integer(e.getStartOffset()); } return F.integer(str.length()); }
console = new Console(); } catch (final SyntaxError e1) { e1.printStackTrace(); return;
String msg = se.getMessage(); stderr.println(msg); stderr.println();
/** * Throw syntax error. * * @param error the error * @param errorLength the error length * @throws org.matheclipse.parser.client.SyntaxError the syntax error */ protected void throwSyntaxError( final String error, final int errorLength ) throws SyntaxError { throw new SyntaxError( fCurrentPosition - errorLength, rowCount, fCurrentPosition - fCurrentColumnStartPosition, getErrorLine(), error, errorLength ); }
/** * {@inheritDoc} */ @Override public Criteria fromQuery( String aQuery ) throws ParseException { // 1.: Normalize the query to use a simple regular expression: aQuery = toNormalized( aQuery ); // 2.: Now escape chars being reserved by the used parser: aQuery = toEscaped( aQuery ); // 3.: Now remove any remaining single quotes: // aQuery = toStripped( aQuery ); if ( aQuery.equals( "" + Wildcard.QUERY.getChar() ) ) { return null; } Parser theParser = new Parser(); try { ASTNode theNode = theParser.parse( aQuery ); if ( theNode instanceof FunctionNode ) { return toCriteria( (FunctionNode) theNode ); } } catch ( SyntaxError e ) { throw new ParseException( aQuery, e.getStartOffset() ); } throw new ParseException( aQuery, 0 ); }
return e.getMessage(); } catch (final MathException e) { if (Config.SHOW_STACKTRACE) {
protected void throwSyntaxError(final String error, final int errorLength) throws SyntaxError { throw new SyntaxError(fCurrentPosition - errorLength, fRowCounter, fCurrentPosition - fCurrentColumnStartPosition, getErrorLine(), error, errorLength); } }
@Override public IExpr call() throws Exception { EvalEngine.set(fEngine); try { return fEngine.evaluate(fExpr); } catch (final SyntaxError se) { String msg = se.getMessage(); fEngine.printMessage(msg); } catch (org.matheclipse.core.eval.exception.TimeoutException e) { return F.$Aborted; } catch (final RecursionLimitExceeded re) { throw re; } catch (final RuntimeException re) { if (Config.SHOW_STACKTRACE) { re.printStackTrace(); } fEngine.printMessage(re.getMessage()); } catch (final Exception e) { fEngine.printMessage(e.getMessage()); } catch (final OutOfMemoryError e) { fEngine.printMessage(e.getMessage()); } catch (final StackOverflowError e) { fEngine.printMessage(e.getMessage()); } finally { EvalEngine.remove(); } return F.$Aborted; }
protected void throwSyntaxError(final String error, final int errorLength) throws SyntaxError { throw new SyntaxError(fCurrentPosition - errorLength, rowCount, fCurrentPosition - fCurrentColumnStartPosition, getErrorLine(), error, errorLength); }
/** * Reevaluate the <code>expression</code> (possibly after a new Variable * assignment). * * @return the data * @throws SyntaxError the syntax error */ public DATA evaluate() { if ( fNode == null ) { throw new SyntaxError( 0, 0, 0, " ", "No parser input defined", 1 ); } return evaluateNode( fNode ); }
/** * Reevaluate the <code>expression</code> (possibly after a new Variable * assignment) * * @param expression * @return * @throws SyntaxError */ public DATA evaluate() { if (fNode == null) { throw new SyntaxError(0, 0, 0, " ", "No parser input defined", 1); } return evaluateNode(fNode); }
/** * Reevaluate the <code>expression</code> (possibly after a new Variable * assignment). * * @return the double * @throws SyntaxError the syntax error */ public double evaluate() { if ( fNode == null ) { throw new SyntaxError( 0, 0, 0, " ", "No parser input defined", 1 ); } return evaluateNode( fNode ); }
protected void throwSyntaxError(final String error) throws SyntaxError { throw new SyntaxError(fCurrentPosition - 1, fRowCounter, fCurrentPosition - fCurrentColumnStartPosition, getErrorLine(), error, 1); }