Search in sources :

Example 1 with MyPCMStoExParser

use of org.palladiosimulator.pcm.stochasticexpressions.parser.MyPCMStoExParser in project Palladio-Editors-Sirius by PalladioSimulator.

the class PCMServices method validExpression.

/**
 * Parses an stochastic expression to determine whether it is valid.
 *
 * @param the
 *            expressionString
 * @return the validity
 */
private boolean validExpression(final String expressionString) {
    final MyPCMStoExLexer lexer = new MyPCMStoExLexer(new ANTLRStringStream(expressionString));
    final MyPCMStoExParser parser = new MyPCMStoExParser(new CommonTokenStream(lexer));
    try {
        parser.expression();
    } catch (final RecognitionException e1) {
        return false;
    }
    if (lexer.hasErrors() || parser.hasErrors()) {
        return false;
    }
    return true;
}
Also used : ANTLRStringStream(org.antlr.runtime.ANTLRStringStream) MyPCMStoExParser(org.palladiosimulator.pcm.stochasticexpressions.parser.MyPCMStoExParser) CommonTokenStream(org.antlr.runtime.CommonTokenStream) MyPCMStoExLexer(org.palladiosimulator.pcm.stochasticexpressions.parser.MyPCMStoExLexer) RecognitionException(org.antlr.runtime.RecognitionException)

Aggregations

ANTLRStringStream (org.antlr.runtime.ANTLRStringStream)1 CommonTokenStream (org.antlr.runtime.CommonTokenStream)1 RecognitionException (org.antlr.runtime.RecognitionException)1 MyPCMStoExLexer (org.palladiosimulator.pcm.stochasticexpressions.parser.MyPCMStoExLexer)1 MyPCMStoExParser (org.palladiosimulator.pcm.stochasticexpressions.parser.MyPCMStoExParser)1