Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright The Sett Ltd, 2005 to 2014.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.thesett.aima.logic.fol.wam.printer;
LabelPrinter prints labels for any bytecode instructions that are labelled.

CRC Card
Responsibilities Collaborations
Print any labels on the bytecode instructions.

Author(s):
Rupert Smith
public class LabelPrinter extends BasePrinter
{
    
Creates a printer.

Parameters:
interner The name interner.
symbolTable The compiler symbol table.
traverser The positional context traverser.
column The column to print to.
table The table to inform of cell sizes and positions.
    public LabelPrinter(VariableAndFunctorInterner internerSymbolTable<IntegerStringObjectsymbolTable,
        PositionalTermTraverser traverserint columnTextTableModel table)
    {
        super(internersymbolTabletraversercolumntable);
    }

    
    protected void enterClause(Clause clause)
    {
        if (clause instanceof WAMCompiledQuery)
        {
            WAMCompiledQuery query = (WAMCompiledQueryclause;
            for (WAMInstruction instruction : query.getInstructions())
            {
                WAMLabel label = instruction.getLabel();
                addLineToRow((label != null) ? (label.toPrettyString() + ":") : "");
                nextRow();
            }
        }
    }

    
    protected void enterPredicate(Predicate predicate)
    {
        if (predicate instanceof WAMCompiledPredicate)
        {
            WAMCompiledPredicate compiledPredicate = (WAMCompiledPredicatepredicate;
            for (WAMInstruction instruction : compiledPredicate.getInstructions())
            {
                WAMLabel label = instruction.getLabel();
                addLineToRow((label != null) ? (label.toPrettyString() + ":") : "");
                nextRow();
            }
        }
    }
New to GrepCode? Check out our FAQ X