lp.parse
Class DlpParser

java.lang.Object
  extended by lp.parse.LpParser
      extended by lp.parse.DlpParser
All Implemented Interfaces:
Closeable

public class DlpParser
extends LpParser

This parser inherits all behaviour from LpParser. In addition, it offers the static method parseDlp() that parses the given input as a dynamic logic program, i.e. a sequence of logic program separated from each other by "newProgram." facts. These facts are not contained in any of the parsed programs. For example on this input:

a.
newProgram.
not a.
newProgram.
a <- not b.
it would produce a dynamic logic program consisting of 3 logic programs, each containing 1 rule:
a.
not a.
a <- not b.

Version:
1.0.0
Author:
Martin Slota
See Also:
LpParser

Field Summary
static LpRule SEP_RULE
          The fact "newProgram." for separating programs in a dynamic logic programs.
 
Constructor Summary
DlpParser()
          Creates a new DlpParser instance that uses a new LpLexer instance to tokenize the character input before parsing.
DlpParser(LpLexer lexer)
          Creates a new DlpParser instance that uses lexer to tokenize the character input before parsing.
 
Method Summary
 DynamicLogicProgram parseDlp()
          Parses the given input as a dynamic logic program, i.e. as a sequence of logic program separated from each other by "newProgram." facts.
 
Methods inherited from class lp.parse.LpParser
close, expect, getLexer, hasMoreTokens, match, nextToken, parseAllRules, parseAllRules, parseArguments, parseAtom, parseLiteral, parseOnlyRule, parseRule, parseRuleBody, parseTerm, setInput, setInput, setInput
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEP_RULE

public static final LpRule SEP_RULE
The fact "newProgram." for separating programs in a dynamic logic programs.

Constructor Detail

DlpParser

public DlpParser()
Creates a new DlpParser instance that uses a new LpLexer instance to tokenize the character input before parsing.


DlpParser

public DlpParser(LpLexer lexer)
Creates a new DlpParser instance that uses lexer to tokenize the character input before parsing.

Parameters:
lexer - the DlpLexer instance used to tokenize the character input before parsing
Method Detail

parseDlp

public DynamicLogicProgram parseDlp()
Parses the given input as a dynamic logic program, i.e. as a sequence of logic program separated from each other by "newProgram." facts. These facts are not contained in any of the parsed programs.

Returns:
the parsed dynamic logic program
Throws:
IOException - (wrapped in an ExceptionAdapter) in case an I/O error occurs while tokenizing the input
LpParserException - if the input doesn't match the expression (Rule* EOF) (Rule is a non-terminal from the grammar in class description)
See Also:
LpParser.parseRule()