Search in sources :

Example 61 with Start

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

the class PredVarsTest method getTreeAsStringOrg.

private String getTreeAsStringOrg(final String testMachine) throws BCompoundException {
    final BParser parser = new BParser("testcase");
    final Start startNode = parser.parse(testMachine, false);
    final Ast2String ast2String = new Ast2String();
    startNode.apply(ast2String);
    final String string = ast2String.toString();
    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)

Example 62 with Start

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

the class PrettyAssignmentPrinterTest method testExpression.

@Test
public void testExpression() throws Exception {
    Start parse = BParser.parse(PREFIX + theString);
    PrettyPrinter prettyprinter = new PrettyPrinter();
    parse.apply(prettyprinter);
    String prettyPrint = prettyprinter.getPrettyPrint();
    // System.out.println("org: " + theString);
    // System.out.println("pp: " + prettyPrint);
    Start parse2 = BParser.parse(PREFIX + prettyPrint);
    PrettyPrinter prettyprinter2 = new PrettyPrinter();
    parse2.apply(prettyprinter2);
    assertEquals(Ast2String.getTreeAsString(parse), Ast2String.getTreeAsString(parse2));
    assertEquals(prettyPrint, prettyprinter2.getPrettyPrint());
}
Also used : PrettyPrinter(de.be4.classicalb.core.parser.util.PrettyPrinter) Start(de.be4.classicalb.core.parser.node.Start) Test(org.junit.Test)

Example 63 with Start

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

the class LexerTest method testStringVariant.

@Test
public void testStringVariant() throws BException {
    final Start rootNode = parseInput("machine Test\nvariant y-x\nend", false);
    final AMachineParseUnit parseUnit = (AMachineParseUnit) rootNode.getPParseUnit();
    final AVariant variantClause = (AVariant) parseUnit.getVariant();
    assertEquals("y-x", variantClause.getExpression().getText());
}
Also used : Start(de.be4.eventbalg.core.parser.node.Start) AVariant(de.be4.eventbalg.core.parser.node.AVariant) AMachineParseUnit(de.be4.eventbalg.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 64 with Start

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

the class SourcePositionsTest method testGetEndLine.

@Test
public void testGetEndLine() throws Exception {
    final Start root = parser.parse("machine\nTestMachine\n\nvariables\nx\n\nend", false);
    final AMachineParseUnit parseUnit = (AMachineParseUnit) root.getPParseUnit();
    assertEquals(7, ((PositionedNode) parseUnit).getEndPos().getLine());
    final LinkedList<PVariable> variables = parseUnit.getVariables();
    assertEquals(5, ((PositionedNode) variables.get(0)).getEndPos().getLine());
}
Also used : Start(de.be4.eventbalg.core.parser.node.Start) PositionedNode(de.hhu.stups.sablecc.patch.PositionedNode) PVariable(de.be4.eventbalg.core.parser.node.PVariable) AMachineParseUnit(de.be4.eventbalg.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 65 with Start

use of de.be4.eventb.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.eventbalg.core.parser.node.Start) AContextParseUnit(de.be4.eventbalg.core.parser.node.AContextParseUnit) AAxiom(de.be4.eventbalg.core.parser.node.AAxiom) PAxiom(de.be4.eventbalg.core.parser.node.PAxiom) Test(org.junit.Test)

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