Search in sources :

Example 46 with Start

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

the class PositionAspectTest method testSimpleNode.

@Test
public void testSimpleNode() throws Exception {
    final String testMachine = "#EXPRESSION x";
    final BParser parser = new BParser("testcase");
    final Start startNode = parser.parse(testMachine, true);
    final PExpression expression = ((AExpressionParseUnit) startNode.getPParseUnit()).getExpression();
    final SourcePosition startPos = expression.getStartPos();
    final SourcePosition endPos = expression.getEndPos();
    assertNotNull(startNode);
    assertNotNull(endPos);
    assertEquals(1, startPos.getLine());
    assertEquals(13, startPos.getPos());
    assertEquals(1, endPos.getLine());
    assertEquals(14, endPos.getPos());
}
Also used : AExpressionParseUnit(de.be4.classicalb.core.parser.node.AExpressionParseUnit) Start(de.be4.classicalb.core.parser.node.Start) SourcePosition(de.hhu.stups.sablecc.patch.SourcePosition) BParser(de.be4.classicalb.core.parser.BParser) PExpression(de.be4.classicalb.core.parser.node.PExpression) Test(org.junit.Test)

Example 47 with Start

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

the class DefinitionsOrderTest method testReordered.

@Test
public void testReordered() throws IOException, BCompoundException {
    machine = new File(PATH + "DefinitionsOccurReordered.mch");
    final BParser parser = new BParser(machine.getName());
    Start start = parser.parseFile(machine, false);
    assertNotNull(start);
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) File(java.io.File) Test(org.junit.Test)

Example 48 with Start

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

the class LexerTest method testStringLabeledElements.

@Test
public void testStringLabeledElements() throws BException {
    final Start rootNode = parseInput("machine Test invariants \n\t@inv1 asdf \n fdsa \n\t@inv2 qwer: \t rewq \nend", false);
    final AMachineParseUnit parseUnit = (AMachineParseUnit) rootNode.getPParseUnit();
    final LinkedList<PInvariant> invariants = parseUnit.getInvariants();
    AInvariant invariant = (AInvariant) invariants.get(0);
    // correct invariant label?
    assertEquals("inv1", invariant.getName().getText());
    // correct string representation for predicate?
    assertEquals("asdf \n fdsa", invariant.getPredicate().getText());
    invariant = (AInvariant) invariants.get(1);
    // correct invariant label?
    assertEquals("inv2", invariant.getName().getText());
    // correct string representation for predicate?
    assertEquals("qwer: \t rewq", invariant.getPredicate().getText());
}
Also used : Start(de.be4.eventb.core.parser.node.Start) PInvariant(de.be4.eventb.core.parser.node.PInvariant) AInvariant(de.be4.eventb.core.parser.node.AInvariant) AMachineParseUnit(de.be4.eventb.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 49 with Start

use of de.be4.ltl.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.eventb.core.parser.node.Start) AVariant(de.be4.eventb.core.parser.node.AVariant) AMachineParseUnit(de.be4.eventb.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 50 with Start

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

the class StructureTest method testIdentifierTick.

@Test
public void testIdentifierTick() throws Exception {
    final Start root = parseInput("machine Mac variables x' y end", false);
    final AMachineParseUnit parseUnit = (AMachineParseUnit) root.getPParseUnit();
    final LinkedList<PVariable> variables = parseUnit.getVariables();
    assertEquals(2, variables.size());
    assertEquals("x'", ((AVariable) variables.get(0)).getName().getText());
    assertEquals("y", ((AVariable) variables.get(1)).getName().getText());
}
Also used : AVariable(de.be4.eventb.core.parser.node.AVariable) Start(de.be4.eventb.core.parser.node.Start) PVariable(de.be4.eventb.core.parser.node.PVariable) AMachineParseUnit(de.be4.eventb.core.parser.node.AMachineParseUnit) 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