|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlp.parse.LpParser
lp.parse.EvolpParser
public class EvolpParser
Inherits the basic behaviour from LpParser
and overrides some parts
in order to parse the input according to this grammar:
Rule ---> (Literal | InnerRule) DOT InnerRule ---> NormalRule | Constraint OrdinaryRule ---> Literal RULE_ARROW (Literal (COMMA Literal)*)? Constraint ---> RULE_ARROW Literal (COMMA Literal)* Literal ---> 'not'? Atom Atom ---> PredicateName Arguments? PredicateName ---> LOWERCASE_WORD Arguments ---> LEFT_PAREN Term (COMMA Term)* RIGHT_PAREN Term ---> LEFT_PAREN Term RIGHT_PAREN | Constant | Variable | CompoundTerm | InnerRule Constant ---> LOWERCASE_WORD Variable ---> UPPERCASE_WORD CompoundTerm ---> FunctionName Arguments FunctionName ---> LOWERCASE_WORDIn this grammar
LpTokenType
parseEvolp()
that parses
the given input as an EVOLP input, i.e. a sequence of logic program separated
from each other by "newEvents." facts. The first program in the sequence is
the base program an the others are events. For example on this input:
a. newEvents. not a. newEvents. a <- not b.it would produce an EVOLP program with this the base program
a.and these two events:
not a.
a <- not b.
LpLexer
,
LpParser
Field Summary | |
---|---|
static LpRule |
SEP_RULE
The fact "newEvents." for separating parts of the EVOLP input. |
Constructor Summary | |
---|---|
EvolpParser()
Creates a new EvolpParser instance that uses a new
LpLexer instance to tokenize the character input before parsing. |
|
EvolpParser(LpLexer lexer)
Creates a new EvolpParser instance that uses lexer to
tokenize the character input before parsing. |
Method Summary | |
---|---|
EvolpProgram |
parseEvolp()
Parses the given input as an EVOLP program , i.e. a sequence of logic programs separated from each other by "newEvents." facts. |
LpTerm |
parseTerm()
Corresponds to the non-terminal Term from the class description. |
Methods inherited from class lp.parse.LpParser |
---|
close, expect, getLexer, hasMoreTokens, match, nextToken, parseAllRules, parseAllRules, parseArguments, parseAtom, parseLiteral, parseOnlyRule, parseRule, parseRuleBody, setInput, setInput, setInput |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final LpRule SEP_RULE
Constructor Detail |
---|
public EvolpParser()
EvolpParser
instance that uses a new
LpLexer
instance to tokenize the character input before parsing.
public EvolpParser(LpLexer lexer)
EvolpParser
instance that uses lexer
to
tokenize the character input before parsing.
lexer
- the LpLexer
instance used to tokenize the
character input before parsingMethod Detail |
---|
public EvolpProgram parseEvolp()
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)LpParser.parseRule()
public LpTerm parseTerm()
LpTerm
interface—an object model of the
parsed term.
parseTerm
in class LpParser
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |