Search in sources :

Example 11 with NodeIdAssignment

use of de.be4.classicalb.core.parser.analysis.prolog.NodeIdAssignment in project probparsers by bendisposto.

the class RulesProject method printProjectAsPrologTerm.

public void printProjectAsPrologTerm(final IPrologTermOutput pout) {
    // parser version
    pout.openTerm("parser_version");
    pout.printAtom(BParser.getBuildRevision());
    pout.closeTerm();
    pout.fullstop();
    // machine
    pout.openTerm("classical_b");
    pout.printAtom(MAIN_MACHINE_NAME);
    pout.openList();
    for (IModel iModel : bModels) {
        pout.printAtom(iModel.getPath());
    }
    pout.closeList();
    pout.closeTerm();
    pout.fullstop();
    NodeIdAssignment tempNodeIdAssignment = parsingBehaviour.isAddLineNumbers() ? this.nodeIdAssignment : new NodeIdAssignment();
    for (IModel iModel : bModels) {
        iModel.printAsProlog(pout, tempNodeIdAssignment);
    }
}
Also used : NodeIdAssignment(de.be4.classicalb.core.parser.analysis.prolog.NodeIdAssignment)

Example 12 with NodeIdAssignment

use of de.be4.classicalb.core.parser.analysis.prolog.NodeIdAssignment in project probparsers by bendisposto.

the class RulesParseUnit method printAsProlog.

@Override
public void printAsProlog(final IPrologTermOutput pout, NodeIdAssignment nodeIdMapping) {
    assert start != null;
    final ClassicalPositionPrinter pprinter = new ClassicalPositionPrinter(nodeIdMapping);
    pprinter.printSourcePositions(parsingBehaviour.isAddLineNumbers());
    final ASTProlog prolog = new ASTProlog(pout, pprinter);
    pout.openTerm("machine");
    start.apply(prolog);
    pout.closeTerm();
    pout.fullstop();
}
Also used : ClassicalPositionPrinter(de.be4.classicalb.core.parser.analysis.prolog.ClassicalPositionPrinter) ASTProlog(de.be4.classicalb.core.parser.analysis.prolog.ASTProlog)

Example 13 with NodeIdAssignment

use of de.be4.classicalb.core.parser.analysis.prolog.NodeIdAssignment in project probparsers by bendisposto.

the class ClassicalBParser method printAst.

private void printAst(final IPrologTermOutput pto, Start ast, final boolean wrap, final String wrapper) {
    NodeIdAssignment na = new NodeIdAssignment();
    ast.apply(na);
    ClassicalPositionPrinter pprinter = new ClassicalPositionPrinter(na, -1, 0);
    final ASTProlog prologPrinter = new ASTProlog(pto, pprinter);
    if (wrap) {
        pto.openTerm(wrapper);
    }
    ast.apply(prologPrinter);
    if (wrap) {
        pto.closeTerm();
    }
}
Also used : ClassicalPositionPrinter(de.be4.classicalb.core.parser.analysis.prolog.ClassicalPositionPrinter) ASTProlog(de.be4.classicalb.core.parser.analysis.prolog.ASTProlog) NodeIdAssignment(de.be4.classicalb.core.parser.analysis.prolog.NodeIdAssignment)

Aggregations

ASTProlog (de.be4.classicalb.core.parser.analysis.prolog.ASTProlog)10 ClassicalPositionPrinter (de.be4.classicalb.core.parser.analysis.prolog.ClassicalPositionPrinter)10 NodeIdAssignment (de.be4.classicalb.core.parser.analysis.prolog.NodeIdAssignment)10 IPrologTermOutput (de.prob.prolog.output.IPrologTermOutput)5 PrologTermOutput (de.prob.prolog.output.PrologTermOutput)5 PrintWriter (java.io.PrintWriter)5 PositionPrinter (de.be4.classicalb.core.parser.analysis.prolog.PositionPrinter)4 StringWriter (java.io.StringWriter)4 BParser (de.be4.classicalb.core.parser.BParser)2 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)2 Start (de.be4.classicalb.core.parser.node.Start)2 PrologTermStringOutput (de.prob.prolog.output.PrologTermStringOutput)2 LexerException (de.be4.classicalb.core.parser.lexer.LexerException)1 AConstructorFreetypeConstructor (de.be4.classicalb.core.parser.node.AConstructorFreetypeConstructor)1 AFreetype (de.be4.classicalb.core.parser.node.AFreetype)1 AFreetypesMachineClause (de.be4.classicalb.core.parser.node.AFreetypesMachineClause)1 AIntegerSetExpression (de.be4.classicalb.core.parser.node.AIntegerSetExpression)1 APowSubsetExpression (de.be4.classicalb.core.parser.node.APowSubsetExpression)1 PDefinition (de.be4.classicalb.core.parser.node.PDefinition)1 TIdentifierLiteral (de.be4.classicalb.core.parser.node.TIdentifierLiteral)1