use of de.be4.classicalb.core.parser.node.Token in project probparsers by bendisposto.
the class PrologGenerator method caseAActionLtl.
@Override
public void caseAActionLtl(final AActionLtl node) {
final Token token = node.getOperation();
p.openTerm("action");
helper.parseTransitionPredicate(UniversalToken.createToken(token));
p.closeTerm();
}
use of de.be4.classicalb.core.parser.node.Token in project probparsers by bendisposto.
the class PrologGenerator method caseAUnparsedLtl.
@Override
public void caseAUnparsedLtl(final AUnparsedLtl node) {
final Token token = node.getPredicate();
helper.caseUnparsed(UniversalToken.createToken(token));
}
use of de.be4.classicalb.core.parser.node.Token in project probparsers by bendisposto.
the class StringLiteralNotClosedTest method testStringLiteralNotClosedLongString.
@Test
public void testStringLiteralNotClosedLongString() {
final String testMachine = "MACHINE Test CONSTANTS the_string PROPERTIES the_string = \"not closed" + randomString(100) + "END";
try {
getTreeAsString(testMachine);
fail("Exception did not occur");
} catch (BCompoundException e) {
System.out.println(e.getCause());
assertTrue(e.getCause() instanceof PreParseException);
assertTrue(e.getLocalizedMessage().contains("Unknown token:"));
}
}
use of de.be4.classicalb.core.parser.node.Token in project probparsers by bendisposto.
the class UnitPragmaTest method testUnitAlias.
@Test
public void testUnitAlias() throws Exception {
String input = "/*@ unit_alias kmph \"km/h\" */ MACHINE UnitAlias VARIABLES lala INVARIANT lala=0 INITIALISATION lala:=0 END";
BLexer lex = new BLexer(new PushbackReader(new StringReader(input), 500));
Token t;
while (!((t = lex.next()) instanceof EOF)) {
System.out.print(t.getClass().getSimpleName() + "(" + t.getText() + ")");
System.out.print(" ");
}
BParser p = new BParser();
Start ast = p.parse(input, false);
ASTPrinter pr = new ASTPrinter();
ast.apply(pr);
System.out.println(printAST(ast));
}
use of de.be4.classicalb.core.parser.node.Token in project probparsers by bendisposto.
the class EventBLexer method collectMultiLineComment.
private void collectMultiLineComment() throws EventBLexerException {
if (state.equals(State.MULTI_COMMENT)) {
if (token instanceof EOF) {
// tokenList.add(token);
throw new EventBLexerException(token, "Comment not closed");
}
/*
* Starting a new multiline comment, so first token is
* TMultiCommentStart
*/
if (commentStart == null) {
commentStart = (TMultiCommentStart) token;
commentBuffer = new StringBuilder();
token = null;
} else {
// end of comment reached?
if (token instanceof TMultiCommentEnd) {
token = new TComment(commentBuffer.toString(), commentStart.getLine(), commentStart.getPos());
commentStart = null;
commentBuffer = null;
state = State.NORMAL;
} else {
commentBuffer.append(token.getText());
token = null;
}
}
}
}
Aggregations