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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations