Search in sources :

Example 6 with AMachineParseUnit

use of de.be4.eventbalg.core.parser.node.AMachineParseUnit 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.eventbalg.core.parser.node.AVariable) Start(de.be4.eventbalg.core.parser.node.Start) PVariable(de.be4.eventbalg.core.parser.node.PVariable) AMachineParseUnit(de.be4.eventbalg.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 7 with AMachineParseUnit

use of de.be4.eventbalg.core.parser.node.AMachineParseUnit in project probparsers by bendisposto.

the class CommentTest method testCommentVariables1.

@Test
public void testCommentVariables1() throws Exception {
    final Start rootNode = parseInput("machine CommentVariables1 variables\n" + "varA" + "//varA comment\n" + " varB\n" + "varC\n" + "/*varC\ncomment*/" + "end", false);
    final AMachineParseUnit parseUnit = (AMachineParseUnit) rootNode.getPParseUnit();
    final LinkedList<PVariable> variables = parseUnit.getVariables();
    assertEquals(3, variables.size());
    AVariable variable = (AVariable) variables.get(0);
    assertEquals("varA", variable.getName().getText());
    assertEquals("varA comment", variable.getComments().get(0).getText());
    variable = (AVariable) variables.get(1);
    assertEquals("varB", variable.getName().getText());
    assertEquals(0, variable.getComments().size());
    variable = (AVariable) variables.get(2);
    assertEquals("varC", variable.getName().getText());
    final LinkedList<TComment> comments = variable.getComments();
    assertNotNull(comments);
    assertEquals(1, comments.size());
    final StringTokenizer tokenizer = new StringTokenizer(comments.get(0).getText(), "\n\r");
    assertEquals(2, tokenizer.countTokens());
    assertEquals("varC", tokenizer.nextToken());
    assertEquals("comment", tokenizer.nextToken());
}
Also used : AVariable(de.be4.eventb.core.parser.node.AVariable) StringTokenizer(java.util.StringTokenizer) Start(de.be4.eventb.core.parser.node.Start) TComment(de.be4.eventb.core.parser.node.TComment) PVariable(de.be4.eventb.core.parser.node.PVariable) AMachineParseUnit(de.be4.eventb.core.parser.node.AMachineParseUnit) Test(org.junit.Test)

Example 8 with AMachineParseUnit

use of de.be4.eventbalg.core.parser.node.AMachineParseUnit in project probparsers by bendisposto.

the class CommentTest method testCommentPredicates1.

@Test
public void testCommentPredicates1() throws Exception {
    final Start rootNode = parseInput("machine CommentPredicates1 invariants\n @inv1 asdf //MyComment\nend", false);
    final AMachineParseUnit parseUnit = (AMachineParseUnit) rootNode.getPParseUnit();
    final LinkedList<PInvariant> invariants = parseUnit.getInvariants();
    final AInvariant invariant = (AInvariant) invariants.get(0);
    // correct comment content?
    assertEquals("MyComment", invariant.getComments().get(0).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 9 with AMachineParseUnit

use of de.be4.eventbalg.core.parser.node.AMachineParseUnit 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 10 with AMachineParseUnit

use of de.be4.eventbalg.core.parser.node.AMachineParseUnit 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)

Aggregations

Test (org.junit.Test)28 AMachineParseUnit (de.be4.eventb.core.parser.node.AMachineParseUnit)14 Start (de.be4.eventb.core.parser.node.Start)14 AMachineParseUnit (de.be4.eventbalg.core.parser.node.AMachineParseUnit)14 Start (de.be4.eventbalg.core.parser.node.Start)14 TComment (de.be4.eventb.core.parser.node.TComment)6 TComment (de.be4.eventbalg.core.parser.node.TComment)6 StringTokenizer (java.util.StringTokenizer)6 AInvariant (de.be4.eventb.core.parser.node.AInvariant)5 PInvariant (de.be4.eventb.core.parser.node.PInvariant)5 AInvariant (de.be4.eventbalg.core.parser.node.AInvariant)5 PInvariant (de.be4.eventbalg.core.parser.node.PInvariant)5 PVariable (de.be4.eventb.core.parser.node.PVariable)3 PVariable (de.be4.eventbalg.core.parser.node.PVariable)3 AEvent (de.be4.eventb.core.parser.node.AEvent)2 AVariable (de.be4.eventb.core.parser.node.AVariable)2 AEvent (de.be4.eventbalg.core.parser.node.AEvent)2 AVariable (de.be4.eventbalg.core.parser.node.AVariable)2 PositionedNode (de.hhu.stups.sablecc.patch.PositionedNode)2 AAction (de.be4.eventb.core.parser.node.AAction)1