Search in sources :

Example 1 with ASTPrinter

use of de.be4.eventbalg.core.parser.analysis.ASTPrinter in project probparsers by bendisposto.

the class DefinitionsErrorsTest method getTreeAsString.

private String getTreeAsString(final String testMachine) throws BCompoundException {
    // System.out.println("Parsing: \"" + testMachine + "\":");
    final BParser parser = new BParser("testcase");
    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();
    return string;
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) Ast2String(util.Ast2String) Ast2String(util.Ast2String)

Example 2 with ASTPrinter

use of de.be4.eventbalg.core.parser.analysis.ASTPrinter in project probparsers by bendisposto.

the class FilePragmaTest 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;
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) Ast2String(util.Ast2String) Ast2String(util.Ast2String)

Example 3 with ASTPrinter

use of de.be4.eventbalg.core.parser.analysis.ASTPrinter in project probparsers by bendisposto.

the class ErrorMessagesTest 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;
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) Ast2String(util.Ast2String) Ast2String(util.Ast2String)

Example 4 with ASTPrinter

use of de.be4.eventbalg.core.parser.analysis.ASTPrinter in project probparsers by bendisposto.

the class ExploreSourcePositionTest method test.

@Test
public void test() throws BCompoundException, IOException {
    final BParser parser = new BParser("m");
    Start parse = parser.parseFile(new File("src/test/resources/LabelTest.mch"), false);
    parse.apply(new ASTPrinter());
    assertTrue(true);
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) ASTPrinter(de.be4.classicalb.core.parser.visualisation.ASTPrinter) File(java.io.File) Test(org.junit.Test)

Example 5 with ASTPrinter

use of de.be4.eventbalg.core.parser.analysis.ASTPrinter 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));
}
Also used : BLexer(de.be4.classicalb.core.parser.BLexer) Start(de.be4.classicalb.core.parser.node.Start) ASTPrinter(de.be4.classicalb.core.parser.visualisation.ASTPrinter) StringReader(java.io.StringReader) Token(de.be4.classicalb.core.parser.node.Token) BParser(de.be4.classicalb.core.parser.BParser) Helpers.getTreeAsString(util.Helpers.getTreeAsString) EOF(de.be4.classicalb.core.parser.node.EOF) PushbackReader(java.io.PushbackReader) Test(org.junit.Test)

Aggregations

Start (de.be4.classicalb.core.parser.node.Start)14 BParser (de.be4.classicalb.core.parser.BParser)8 Ast2String (util.Ast2String)7 ASTPrinter (de.be4.classicalb.core.parser.visualisation.ASTPrinter)6 Test (org.junit.Test)5 BLexer (de.be4.classicalb.core.parser.BLexer)3 EOF (de.be4.classicalb.core.parser.node.EOF)3 Token (de.be4.classicalb.core.parser.node.Token)3 File (java.io.File)3 IOException (java.io.IOException)3 PushbackReader (java.io.PushbackReader)3 StringReader (java.io.StringReader)3 ASTPrinter (de.be4.eventbalg.core.parser.analysis.ASTPrinter)2 Start (de.be4.eventbalg.core.parser.node.Start)2 Helpers.getTreeAsString (util.Helpers.getTreeAsString)2 LexerException (de.be4.classicalb.core.parser.lexer.LexerException)1 ParserException (de.be4.classicalb.core.parser.parser.ParserException)1 ASTDisplay (de.be4.classicalb.core.parser.visualisation.ASTDisplay)1 ASTDisplay (de.be4.eventb.core.parser.analysis.ASTDisplay)1 ASTPrinter (de.be4.eventb.core.parser.analysis.ASTPrinter)1