use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class StringLiteralNotClosedTest method testStringLiteralNotClosedShortString.
@Test
public void testStringLiteralNotClosedShortString() {
final String testMachine = "MACHINE Test CONSTANTS the_string PROPERTIES the_string = \"not closed END";
try {
getTreeAsString(testMachine);
fail("Exception did not occur");
} catch (BCompoundException e) {
assertEquals("[1,59] Unknown token: \"not closed END", e.getMessage());
}
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class StringLiteralNotClosedTest method getTreeAsString.
private String getTreeAsString(final String testMachine) throws BCompoundException {
// System.out.println("Parsing \"" + testMachine + "\"");
final BParser parser = new BParser("testcase");
parser.getOptions().setGrammar(RulesGrammar.getInstance());
final Start startNode = parser.parse(testMachine, false);
// startNode.apply(new ASTPrinter());
final Ast2String ast2String = new Ast2String();
startNode.apply(ast2String);
final String string = ast2String.toString();
// System.out.println(string);
return string;
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class SatProblem method getTreeAsString.
private String getTreeAsString(final String testMachine) throws BCompoundException, LexerException, IOException {
final BParser parser = new BParser("testcase");
Start ast = parser.eparse(testMachine, new Definitions());
final Ast2String ast2String = new Ast2String();
ast.apply(ast2String);
final String string = ast2String.toString();
return string;
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class Test1002 method file2.
@Test
public void file2() throws BCompoundException {
String source = " clients : STRING +-> STRING & balances : STRING +-> NATURAL & owners : STRING <-> STRING & u : STRING & n : STRING & m : NATURAL & m > balances(n) & m < 100000";
Start result = BParser.parse(BParser.FORMULA_PREFIX + "" + source);
assertNotNull(result);
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class Test1002 method file3.
@Test
public void file3() throws BCompoundException {
String source = "srv : {\"HS\",\"SC\",\"COM\",\"VOM\",\"SDA\",\"RDA\",\"TD\",\"RA\",\"GMR\",\"LDM\",\"EP\",\"MSP\"} & om : {\"SAFETY\",\"NOM\",\"DIAG\"} & acquiring : {TRUE,FALSE} & prepData : {TRUE,FALSE} & prepDataType : {\"SD\",\"HD\",\"MD\"} & page : NATURAL & ia : NATURAL & fa : NATURAL & lpck : seq(STRING) & lpckDT : {\"CR\",\"CD\",\"OM\",\"ND\",\"ASD\",\"AMD\",\"MSE\",\"ICS\",\"LS\"} & csrs : {\"SD\",\"HD\",\"MD\"} --> NATURAL & totCSR : {\"SD\",\"HD\",\"MD\"} --> NATURAL & csc : NATURAL & mem : 1 .. 1024 --> STRING & modMem : POW(NATURAL) & sdwp : NATURAL & sparam : {\"HGT\",\"ILP\",\"AICST\"} --> NATURAL & time : NATURAL & processingCmd : {TRUE,FALSE} & iain : NATURAL & data : seq(STRING) & c : NATURAL & processingCmd = TRUE & srv = \"LDM\" & om = \"NOM\" & csc > 0 & c = csc - 1 & sparam(\"ILP\") <= iain & iain + card(data) : 0 .. 32 & {x | x-iain:dom(data)} /\\ modMem = { } & {x | x-iain:dom(data)} /= { } & modMem = { }";
Start result = BParser.parse(BParser.FORMULA_PREFIX + "" + source);
assertNotNull(result);
}
Aggregations