Search in sources :

Example 76 with BParser

use of de.be4.classicalb.core.parser.BParser in project probparsers by bendisposto.

the class ClassicalBParser method parseExpression.

@Override
public void parseExpression(final IPrologTermOutput pto, final String expression, final boolean wrap) throws ProBParseException {
    try {
        Start ast = new BParser().parseExpression(expression);
        printAst(pto, ast, wrap, WRAPPER_EXPR);
    } catch (BCompoundException e) {
        throw new ProBParseException(e.getFirstException().getLocalizedMessage());
    }
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) ProBParseException(de.prob.parserbase.ProBParseException) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException)

Example 77 with BParser

use of de.be4.classicalb.core.parser.BParser in project probparsers by bendisposto.

the class ClassicalBParser method parseTransitionPredicate.

@Override
public void parseTransitionPredicate(final IPrologTermOutput pto, final String trans, final boolean wrap) throws ProBParseException {
    try {
        Start ast = new BParser().parseTranstion(trans);
        printAst(pto, ast, wrap, WRAPPER_TRANS);
    } catch (BCompoundException e) {
        throw new ProBParseException(e.getFirstException().getLocalizedMessage());
    }
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) ProBParseException(de.prob.parserbase.ProBParseException) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException)

Example 78 with BParser

use of de.be4.classicalb.core.parser.BParser in project prob2 by bendisposto.

the class ClassicalBFactory method create.

public ExtractedModel<ClassicalBModel> create(final Start model) {
    ClassicalBModel classicalBModel = modelCreator.get();
    BParser bparser = new BParser();
    final RecursiveMachineLoader rml = parseAllMachines(model, ".", new File(""), new CachingDefinitionFileProvider(), bparser);
    classicalBModel = classicalBModel.create(model, rml, new File("from_string"), bparser);
    return new ExtractedModel<>(classicalBModel, classicalBModel.getMainMachine());
}
Also used : CachingDefinitionFileProvider(de.be4.classicalb.core.parser.CachingDefinitionFileProvider) ClassicalBModel(de.prob.model.classicalb.ClassicalBModel) BParser(de.be4.classicalb.core.parser.BParser) RecursiveMachineLoader(de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader) File(java.io.File)

Example 79 with BParser

use of de.be4.classicalb.core.parser.BParser in project prob2 by bendisposto.

the class ClassicalBFactory method create.

public ExtractedModel<ClassicalBModel> create(final String model) {
    ClassicalBModel classicalBModel = modelCreator.get();
    BParser bparser = new BParser();
    Start ast = parseString(model, bparser);
    final RecursiveMachineLoader rml = parseAllMachines(ast, ".", new File(""), bparser.getContentProvider(), bparser);
    classicalBModel = classicalBModel.create(ast, rml, new File("from_string"), bparser);
    return new ExtractedModel<>(classicalBModel, classicalBModel.getMainMachine());
}
Also used : ClassicalBModel(de.prob.model.classicalb.ClassicalBModel) Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) RecursiveMachineLoader(de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader) File(java.io.File)

Example 80 with BParser

use of de.be4.classicalb.core.parser.BParser in project prob2 by bendisposto.

the class ClassicalBFactory method extract.

@Override
public ExtractedModel<ClassicalBModel> extract(final String modelPath) throws IOException, ModelTranslationError {
    ClassicalBModel classicalBModel = modelCreator.get();
    File f = new File(modelPath);
    BParser bparser = new BParser();
    Start ast = parseFile(f, bparser);
    RecursiveMachineLoader rml = parseAllMachines(ast, f.getParent(), f, bparser.getContentProvider(), bparser);
    classicalBModel = classicalBModel.create(ast, rml, f, bparser);
    return new ExtractedModel<>(classicalBModel, classicalBModel.getMainMachine());
}
Also used : ClassicalBModel(de.prob.model.classicalb.ClassicalBModel) Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) RecursiveMachineLoader(de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader) File(java.io.File)

Aggregations

Start (de.be4.classicalb.core.parser.node.Start)63 BParser (de.be4.classicalb.core.parser.BParser)53 Test (org.junit.Test)39 File (java.io.File)23 Ast2String (util.Ast2String)21 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)18 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)11 ParsingBehaviour (de.be4.classicalb.core.parser.ParsingBehaviour)7 PrintStream (java.io.PrintStream)7 AbstractParseMachineTest (util.AbstractParseMachineTest)7 IOException (java.io.IOException)6 ASTPrinter (de.be4.classicalb.core.parser.visualisation.ASTPrinter)5 ClassicalBModel (de.prob.model.classicalb.ClassicalBModel)4 OutputStream (java.io.OutputStream)4 BLexer (de.be4.classicalb.core.parser.BLexer)3 IDefinitions (de.be4.classicalb.core.parser.IDefinitions)3 LexerException (de.be4.classicalb.core.parser.lexer.LexerException)3 EOF (de.be4.classicalb.core.parser.node.EOF)3 Token (de.be4.classicalb.core.parser.node.Token)3 ProBError (de.prob.exception.ProBError)3