Search in sources :

Example 51 with Start

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

the class StructureTest method testWitnessTick.

@Test
public void testWitnessTick() throws Exception {
    final Start root = parseInput("machine WitnessTick\nevents\nevent Eve\nwith\n@x' x' :: NAT\nend\nend", false);
    final AMachineParseUnit parseUnit = (AMachineParseUnit) root.getPParseUnit();
    final LinkedList<PEvent> events = parseUnit.getEvents();
    assertEquals(1, events.size());
    final AEvent event = (AEvent) events.get(0);
    final LinkedList<PWitness> witnesses = event.getWitnesses();
    assertEquals(1, witnesses.size());
    assertEquals("x'", ((AWitness) witnesses.get(0)).getName().getText());
}
Also used : Start(de.be4.eventb.core.parser.node.Start) AWitness(de.be4.eventb.core.parser.node.AWitness) PWitness(de.be4.eventb.core.parser.node.PWitness) AEvent(de.be4.eventb.core.parser.node.AEvent) PEvent(de.be4.eventb.core.parser.node.PEvent) AMachineParseUnit(de.be4.eventb.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 52 with Start

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

the class CtlParser method applyPrologGenerator.

@Override
protected void applyPrologGenerator(StructuredPrologOutput pto, String stateID, ProBParserBase specParser, Start ast) {
    final PrologCtlGenerator prologGenerator = new PrologCtlGenerator(pto, stateID, specParser);
    ast.apply(prologGenerator);
}
Also used : PrologCtlGenerator(de.be4.ltl.core.parser.internal.PrologCtlGenerator)

Example 53 with Start

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

the class CtlParser method parseFormula.

protected Start parseFormula(final String formula) throws LtlParseException, IOException {
    StringReader reader = new StringReader(formula);
    PushbackReader r = new PushbackReader(reader);
    Lexer l = new CtlLexer(r);
    Parser p = new Parser(l);
    Start ast = null;
    try {
        ast = p.parse();
    } catch (ParserException e) {
        final UniversalToken token = UniversalToken.createToken(e.getToken());
        throw new LtlParseException(token, e.getLocalizedMessage());
    } catch (LexerException e) {
        throw new LtlParseException(null, e.getLocalizedMessage());
    }
    return ast;
}
Also used : ParserException(de.be4.ltl.core.ctlparser.parser.ParserException) CtlLexer(de.be4.ltl.core.parser.internal.CtlLexer) Lexer(de.be4.ltl.core.ctlparser.lexer.Lexer) UniversalToken(de.be4.ltl.core.parser.internal.UniversalToken) Start(de.be4.ltl.core.ctlparser.node.Start) StringReader(java.io.StringReader) CtlLexer(de.be4.ltl.core.parser.internal.CtlLexer) LexerException(de.be4.ltl.core.ctlparser.lexer.LexerException) PushbackReader(java.io.PushbackReader) Parser(de.be4.ltl.core.ctlparser.parser.Parser)

Example 54 with Start

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

the class LtlParser method applyPrologGenerator.

@Override
protected void applyPrologGenerator(StructuredPrologOutput pto, String stateID, ProBParserBase specParser, Start ast) {
    final PrologGenerator prologGenerator = new PrologGenerator(pto, stateID, specParser);
    ast.apply(prologGenerator);
}
Also used : PrologGenerator(de.be4.ltl.core.parser.internal.PrologGenerator)

Example 55 with Start

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

the class ErrorMessagesTest method getTreeAsString.

private String getTreeAsString(final String testMachine) throws BCompoundException {
    // System.out.println("Parsing \"" + testMachine + "\"");
    final BParser parser = new BParser("testcase");
    parser.getOptions().setGrammar(RulesGrammar.getInstance());
    final Start startNode = parser.parse(testMachine, false);
    // startNode.apply(new ASTPrinter());
    final Ast2String ast2String = new Ast2String();
    startNode.apply(ast2String);
    final String string = ast2String.toString();
    // System.out.println(string);
    return string;
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) Ast2String(util.Ast2String) Ast2String(util.Ast2String)

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