lp.trans
Class DlpGrounder.DlpDetagger

java.lang.Object
  extended by lp.parse.LpParser
      extended by lp.trans.DlpGrounder.DlpDetagger
All Implemented Interfaces:
Closeable
Enclosing class:
DlpGrounder

private static class DlpGrounder.DlpDetagger
extends LpParser

A special parser for parsing the grounded and tagged program. It filters out all tagging literals, both in rule bodies and in facts. It also eliminates the "p_" and "n_" prefixes from predicate names.

Version:
1.0.0
Author:
Martin Slota

Field Summary
private static LpLiteral TAG
          An internally used literal that indicates that a tag has been parsed.
private  int tagNumber
          The tag number of the last rule.
 
Constructor Summary
DlpGrounder.DlpDetagger()
          Creates a new instance of TaggedDlpParser.
 
Method Summary
 int getTagNumber()
          Returns the tag number of the last rule.
 LpLiteral parseLiteral()
          Parses and returns the next literal on input.
 LpRule parseRule()
          Parses and returns the next rule on input.
 void setInput(CharSequence input)
          Sets the character input of this LpParser to the given CharSequence.
 
Methods inherited from class lp.parse.LpParser
close, expect, getLexer, hasMoreTokens, match, nextToken, parseAllRules, parseAllRules, parseArguments, parseAtom, parseOnlyRule, parseRuleBody, parseTerm, setInput, setInput
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG

private static final LpLiteral TAG
An internally used literal that indicates that a tag has been parsed. It is returned by parseLiteral() and processed by parseRule().


tagNumber

private int tagNumber
The tag number of the last rule.

Constructor Detail

DlpGrounder.DlpDetagger

public DlpGrounder.DlpDetagger()
Creates a new instance of TaggedDlpParser.

Method Detail

setInput

public void setInput(CharSequence input)
Sets the character input of this LpParser to the given CharSequence.

Overrides:
setInput in class LpParser
Parameters:
input - the character sequence to be parsed
See Also:
LpLexer.setInput(CharSequence)

getTagNumber

public int getTagNumber()
Returns the tag number of the last rule.


parseRule

public LpRule parseRule()
Parses and returns the next rule on input. Applies the changes described in class description.

Overrides:
parseRule in class LpParser
Returns:
the parsed rule or null if no more rules follow
Throws:
IOException - (wrapped in an ExceptionAdapter) in case an I/O error occurs while tokenizing the input
LpParserException - if the input is not parseable

parseLiteral

public LpLiteral parseLiteral()
Parses and returns the next literal on input. Applies the changes described in class description.

Overrides:
parseLiteral in class LpParser
Returns:
the parsed literal or null if it was a tagging literal
Throws:
IOException - (wrapped in an ExceptionAdapter) in case an I/O error occurs while tokenizing the input
LpParserException - if the input is not parseable