use of de.be4.classicalb.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;
}
use of de.be4.classicalb.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());
}
use of de.be4.classicalb.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());
}
use of de.be4.classicalb.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());
}
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());
}
Aggregations