Search in sources :

Example 11 with Start

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

the class TheoriesIssuesTest method testCommentPredicates1.

@Test
public void testCommentPredicates1() throws Exception {
    final Start rootNode = parseInput("context C4 \naxioms\n@axm2 {1↦1,2↦2} = seqAppend({1↦1},2)\nend", false);
    final AContextParseUnit parseUnit = (AContextParseUnit) rootNode.getPParseUnit();
    final LinkedList<PAxiom> axioms = parseUnit.getAxioms();
    final AAxiom axiom = (AAxiom) axioms.get(0);
    assertEquals("{1↦1,2↦2} = seqAppend({1↦1},2)", axiom.getPredicate().getText());
}
Also used : Start(de.be4.eventb.core.parser.node.Start) AContextParseUnit(de.be4.eventb.core.parser.node.AContextParseUnit) AAxiom(de.be4.eventb.core.parser.node.AAxiom) PAxiom(de.be4.eventb.core.parser.node.PAxiom) Test(org.junit.Test)

Example 12 with Start

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

the class LTLFormulaVisitor method handleQuantification.

private void handleQuantification(de.be4.ltl.core.parser.node.Node node, String parameterName, String bPredicateString, PLtl ltl) {
    // create an identifier (b ast node) for the parameter of the
    // quantification
    List<TIdentifierLiteral> list = new ArrayList<TIdentifierLiteral>();
    list.add(new TIdentifierLiteral(parameterName));
    AIdentifierExpression parameterNode = new AIdentifierExpression(list);
    // add the created identifier to the current context
    Hashtable<String, AIdentifierExpression> currentContext = new Hashtable<String, AIdentifierExpression>();
    currentContext.put(parameterName, parameterNode);
    this.contextTable.add(currentContext);
    // collection the all parameters in
    ltlIdentifierTable.put(parameterName, parameterNode);
    // parse the b predicate and create a reference to the b ast node
    de.be4.classicalb.core.parser.node.Start start = parseBPredicate(bPredicateString);
    ltlNodeToBNodeTable.put(node, start);
    // collect all identifiers which can be used in the bPredicate and
    // verify the bPredicate
    LTLBPredicate ltlBPredicate = new LTLBPredicate(getUnifiedContext(), start);
    this.bPredicates.add(ltlBPredicate);
    machineContext.checkLTLBPredicate(ltlBPredicate);
    // remaining LTL formula
    ltl.apply(this);
    // remove currentContext from contextTable
    contextTable.remove(contextTable.size() - 1);
}
Also used : AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) TIdentifierLiteral(de.be4.classicalb.core.parser.node.TIdentifierLiteral)

Example 13 with Start

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

the class LTLFormulaVisitor method parseBPredicate.

private de.be4.classicalb.core.parser.node.Start parseBPredicate(String text) {
    String bPredicate = "#PREDICATE " + text;
    BParser parser = new BParser("Testing");
    de.be4.classicalb.core.parser.node.Start start = null;
    try {
        start = parser.parse(bPredicate, false);
    } catch (BCompoundException e) {
        throw new LTLParseException(e.getMessage());
    }
    return start;
}
Also used : LTLParseException(de.prob.typechecker.exceptions.LTLParseException) BParser(de.be4.classicalb.core.parser.BParser) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException)

Example 14 with Start

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

the class ASTPrologTest method checkProlog.

private void checkProlog(final int counter, final String bspec, final String expected) throws BCompoundException {
    final BParser parser = new BParser("testcase");
    if (remove_restrictions) {
        parser.getOptions().setRestrictProverExpressions(false);
    }
    final Start startNode = parser.parse(bspec, false, new NoContentProvider());
    checkAST(counter, expected, startNode);
}
Also used : Start(de.be4.classicalb.core.parser.node.Start)

Example 15 with Start

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

the class CreateFreetypeTest method createMachine.

private Start createMachine(String name) {
    final AFreetypesMachineClause freetypes = createFreetype();
    final AConstantsMachineClause variables = new AConstantsMachineClause(createIdentifiers(VAR_NAME));
    final AMemberPredicate member = new AMemberPredicate(createIdentifier(VAR_NAME), new APowSubsetExpression(createIdentifier(FREETYPE_NAME)));
    final AInvariantMachineClause inv = new AInvariantMachineClause(member);
    final AInitialisationMachineClause init = new AInitialisationMachineClause(createAssignment(VAR_NAME, new AEmptySetExpression()));
    final AOperationsMachineClause operations = createOperations();
    final AMachineHeader header = new AMachineHeader(createIdLits(name), EMPTY_EXPRS);
    final AAbstractMachineParseUnit machine = new AAbstractMachineParseUnit(new AMachineMachineVariant(), header, Arrays.asList(freetypes, variables, inv, init, operations));
    return new Start(machine, new EOF());
}
Also used : AMachineMachineVariant(de.be4.classicalb.core.parser.node.AMachineMachineVariant) AInitialisationMachineClause(de.be4.classicalb.core.parser.node.AInitialisationMachineClause) AMachineHeader(de.be4.classicalb.core.parser.node.AMachineHeader) AConstantsMachineClause(de.be4.classicalb.core.parser.node.AConstantsMachineClause) Start(de.be4.classicalb.core.parser.node.Start) AMemberPredicate(de.be4.classicalb.core.parser.node.AMemberPredicate) AAbstractMachineParseUnit(de.be4.classicalb.core.parser.node.AAbstractMachineParseUnit) AOperationsMachineClause(de.be4.classicalb.core.parser.node.AOperationsMachineClause) AInvariantMachineClause(de.be4.classicalb.core.parser.node.AInvariantMachineClause) AFreetypesMachineClause(de.be4.classicalb.core.parser.node.AFreetypesMachineClause) APowSubsetExpression(de.be4.classicalb.core.parser.node.APowSubsetExpression) AEmptySetExpression(de.be4.classicalb.core.parser.node.AEmptySetExpression) EOF(de.be4.classicalb.core.parser.node.EOF)

Aggregations

Start (de.be4.classicalb.core.parser.node.Start)104 Test (org.junit.Test)84 BParser (de.be4.classicalb.core.parser.BParser)43 Ast2String (util.Ast2String)32 File (java.io.File)20 Start (de.be4.eventbalg.core.parser.node.Start)19 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)18 Start (de.be4.eventb.core.parser.node.Start)18 AMachineParseUnit (de.be4.eventb.core.parser.node.AMachineParseUnit)14 AMachineParseUnit (de.be4.eventbalg.core.parser.node.AMachineParseUnit)14 IOException (java.io.IOException)12 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)11 PushbackReader (java.io.PushbackReader)11 StringReader (java.io.StringReader)11 ASTProlog (de.be4.classicalb.core.parser.analysis.prolog.ASTProlog)8 AExpressionParseUnit (de.be4.classicalb.core.parser.node.AExpressionParseUnit)7 AbstractParseMachineTest (util.AbstractParseMachineTest)7 ParsingBehaviour (de.be4.classicalb.core.parser.ParsingBehaviour)6 ClassicalPositionPrinter (de.be4.classicalb.core.parser.analysis.prolog.ClassicalPositionPrinter)6 ASTPrinter (de.be4.classicalb.core.parser.visualisation.ASTPrinter)6