Search in sources :

Example 6 with NodeIdAssignment

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

the class PragmaTest method printAST.

private String printAST(final Node node) {
    final StringWriter swriter = new StringWriter();
    NodeIdAssignment nodeids = new NodeIdAssignment();
    node.apply(nodeids);
    IPrologTermOutput pout = new PrologTermOutput(new PrintWriter(swriter), false);
    PositionPrinter pprinter = new ClassicalPositionPrinter(nodeids);
    ASTProlog prolog = new ASTProlog(pout, pprinter);
    node.apply(prolog);
    swriter.flush();
    return swriter.toString();
}
Also used : ClassicalPositionPrinter(de.be4.classicalb.core.parser.analysis.prolog.ClassicalPositionPrinter) ASTProlog(de.be4.classicalb.core.parser.analysis.prolog.ASTProlog) StringWriter(java.io.StringWriter) PrologTermOutput(de.prob.prolog.output.PrologTermOutput) IPrologTermOutput(de.prob.prolog.output.IPrologTermOutput) PositionPrinter(de.be4.classicalb.core.parser.analysis.prolog.PositionPrinter) ClassicalPositionPrinter(de.be4.classicalb.core.parser.analysis.prolog.ClassicalPositionPrinter) NodeIdAssignment(de.be4.classicalb.core.parser.analysis.prolog.NodeIdAssignment) IPrologTermOutput(de.prob.prolog.output.IPrologTermOutput) PrintWriter(java.io.PrintWriter)

Example 7 with NodeIdAssignment

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

the class Definitions method assignIdsToNodes.

@Override
public void assignIdsToNodes(NodeIdAssignment nodeIdMapping, List<File> machineFilesLoaded) {
    if (file != null) {
        machineFilesLoaded.add(file);
        final int fileNumber = machineFilesLoaded.indexOf(file) + 1;
        for (PDefinition def : definitionsMap.values()) {
            nodeIdMapping.assignIdentifiers(fileNumber, def);
        }
    }
    for (IDefinitions defintions : super.referencedDefinitions) {
        defintions.assignIdsToNodes(nodeIdMapping, machineFilesLoaded);
    }
}
Also used : PDefinition(de.be4.classicalb.core.parser.node.PDefinition)

Example 8 with NodeIdAssignment

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

the class Helpers method printAsProlog.

public static void printAsProlog(final Start start, final IPrologTermOutput pout) {
    final NodeIdAssignment nodeIds = new NodeIdAssignment();
    nodeIds.assignIdentifiers(1, start);
    final ClassicalPositionPrinter pprinter = new ClassicalPositionPrinter(nodeIds);
    final ASTProlog prolog = new ASTProlog(pout, pprinter);
    pout.openTerm("machine");
    start.apply(prolog);
    pout.closeTerm();
    pout.fullstop();
    pout.flush();
}
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)

Example 9 with NodeIdAssignment

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

the class UnitPragmaTest method printAST.

private String printAST(final Node node) {
    final StringWriter swriter = new StringWriter();
    NodeIdAssignment nodeids = new NodeIdAssignment();
    node.apply(nodeids);
    IPrologTermOutput pout = new PrologTermOutput(new PrintWriter(swriter), false);
    PositionPrinter pprinter = new ClassicalPositionPrinter(nodeids);
    ASTProlog prolog = new ASTProlog(pout, pprinter);
    node.apply(prolog);
    swriter.flush();
    return swriter.toString();
}
Also used : ClassicalPositionPrinter(de.be4.classicalb.core.parser.analysis.prolog.ClassicalPositionPrinter) ASTProlog(de.be4.classicalb.core.parser.analysis.prolog.ASTProlog) StringWriter(java.io.StringWriter) PrologTermOutput(de.prob.prolog.output.PrologTermOutput) IPrologTermOutput(de.prob.prolog.output.IPrologTermOutput) PositionPrinter(de.be4.classicalb.core.parser.analysis.prolog.PositionPrinter) ClassicalPositionPrinter(de.be4.classicalb.core.parser.analysis.prolog.ClassicalPositionPrinter) NodeIdAssignment(de.be4.classicalb.core.parser.analysis.prolog.NodeIdAssignment) IPrologTermOutput(de.prob.prolog.output.IPrologTermOutput) PrintWriter(java.io.PrintWriter)

Example 10 with NodeIdAssignment

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

the class BMachine method printAsProlog.

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");
    // if (parsingBehaviour.isAddLineNumbers()) {
    // pprinter.setSourcePositions(
    // new SourcePositions(new ArrayList<IToken>(), new HashMap<PositionedNode, SourcecodeRange>()));
    // }
    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)

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