Class RpclCondensedProbabilityDistributionParser
java.lang.Object
org.tweetyproject.logics.rpcl.parser.rpclcondensedprobabilitydistributionparser.RpclCondensedProbabilityDistributionParser
- All Implemented Interfaces:
RpclCondensedProbabilityDistributionParserConstants
public class RpclCondensedProbabilityDistributionParser
extends Object
implements RpclCondensedProbabilityDistributionParserConstants
This class implements a parser for condensed relational probability distributions. The BNF for
condensed relational probability distributions is given by (start symbol is DISTRIBUTION)
DISTRIBUTION ::== (PROBABILITYASSIGNMENT)*
PROBABILITYASSIGNMENT ::== INTERPRETATION "=" PROBABILITY
INTERPRETATION ::== "{" (INSTANCEASSIGNMENT ("," INSTANCEASSIGNMENT)*)? "}"
INSTANCEASSIGNMENT ::== "<" PREDICATE "," "{" (CONSTANTSET "=" MULTIPLICATOR ("," CONSTANTSET "=" MULTIPLICATOR)*)? "}" ">"
CONSTANTSET ::== "{" CONSTANT ("," CONSTANT)* "}"
PREDICATE is a sequence of symbols from {a,...,z,A,...,Z,0,...,9} with a lowercase letter at the beginning.
CONSTANT is a sequence of symbols from {a,...,z,A,...,Z,0,...,9} with a lowercase letter at the beginning.
MULTIPLICATOR is a natural number.
DISTRIBUTION ::== (PROBABILITYASSIGNMENT)*
PROBABILITYASSIGNMENT ::== INTERPRETATION "=" PROBABILITY
INTERPRETATION ::== "{" (INSTANCEASSIGNMENT ("," INSTANCEASSIGNMENT)*)? "}"
INSTANCEASSIGNMENT ::== "<" PREDICATE "," "{" (CONSTANTSET "=" MULTIPLICATOR ("," CONSTANTSET "=" MULTIPLICATOR)*)? "}" ">"
CONSTANTSET ::== "{" CONSTANT ("," CONSTANT)* "}"
PREDICATE is a sequence of symbols from {a,...,z,A,...,Z,0,...,9} with a lowercase letter at the beginning.
CONSTANT is a sequence of symbols from {a,...,z,A,...,Z,0,...,9} with a lowercase letter at the beginning.
MULTIPLICATOR is a natural number.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic TokenNext token.static TokenCurrent token.Generated Token Manager.Fields inherited from interface org.tweetyproject.logics.rpcl.parser.rpclcondensedprobabilitydistributionparser.RpclCondensedProbabilityDistributionParserConstants
DEFAULT, EOF, MULTIPLICATOR, PROBABILITY, STRUCTURENAME, tokenImage -
Constructor Summary
ConstructorsConstructorDescriptionCnnstructorConstructor forRpclCondensedProbabilityDistributionParserthat takes anInputStreamas input.RpclCondensedProbabilityDistributionParser(InputStream stream, String encoding) Constructs a newRpclCondensedProbabilityDistributionParserusing the specified input stream and character encoding.Constructor.RpclCondensedProbabilityDistributionParser(RpclCondensedProbabilityDistributionParserTokenManager tm) Constructor with generated Token Manager.ConstructorRpclCondensedProbabilityDistributionParser(RpclSemantics semantics, FolSignature signature) Constructor -
Method Summary
Modifier and TypeMethodDescriptionConstantSet(FolSignature signature) Parses a set of constants from the input and adds them to the specifiedFolSignature.static final voidDisable tracing.static final CondensedProbabilityDistributionDistribution(RpclSemantics semantics, FolSignature signature) Create a distributionstatic final voidEnable tracing.static ParseExceptionGenerate ParseException.static final TokenRetrieves the next token from the input stream.static final TokengetToken(int index) Get the specific Token.static final InstanceAssignmentInstanceAssignment(FolSignature signature) Parses anInstanceAssignmentfrom the input stream.static final ReferenceWorldInterpretation(FolSignature signature) Parses anInterpretation(specifically, aReferenceWorld) from the input streamReturn parsed CondensedProbabilityDistributionstatic final Pair<ReferenceWorld, Probability> ProbabilityAssignment(FolSignature signature) Parses a probability assignment from the input stream.static voidReInit(InputStream stream) Reinitializes the parser with a new input stream using the default character encoding.static voidReInit(InputStream stream, String encoding) Reinitializes the parser with a new input stream and character encoding.static voidReinitialisevoidReinitialise.voidsetSemantics(RpclSemantics semantics) setter semanticsvoidsetSignature(FolSignature signature) setter signature
-
Field Details
-
token_source
Generated Token Manager. -
token
Current token. -
jj_nt
Next token.
-
-
Constructor Details
-
RpclCondensedProbabilityDistributionParser
public RpclCondensedProbabilityDistributionParser()Cnnstructor -
RpclCondensedProbabilityDistributionParser
Constructor- Parameters:
semantics- a semantics
-
RpclCondensedProbabilityDistributionParser
Constructor- Parameters:
semantics- a semanticssignature- a signature
-
RpclCondensedProbabilityDistributionParser
Constructor forRpclCondensedProbabilityDistributionParserthat takes anInputStreamas input.- Parameters:
stream- The input stream to be parsed.
-
RpclCondensedProbabilityDistributionParser
Constructs a newRpclCondensedProbabilityDistributionParserusing the specified input stream and character encoding.- Parameters:
stream- The input stream to be parsed.encoding- The character encoding to be used for reading the input stream.- Throws:
RuntimeException- If the specified encoding is unsupported.Error- If this constructor is called more than once when the JavaCCSTATICoption is enabled.
-
RpclCondensedProbabilityDistributionParser
Constructor.- Parameters:
stream- the reader
-
RpclCondensedProbabilityDistributionParser
public RpclCondensedProbabilityDistributionParser(RpclCondensedProbabilityDistributionParserTokenManager tm) Constructor with generated Token Manager.- Parameters:
tm- the tokenmanager
-
-
Method Details
-
setSemantics
setter semantics- Parameters:
semantics- the semantics
-
setSignature
setter signature- Parameters:
signature- the signature
-
parseCondensedProbabilityDistribution
public CondensedProbabilityDistribution parseCondensedProbabilityDistribution(Reader reader) throws ParserException Return parsed CondensedProbabilityDistribution- Parameters:
reader- the reader- Returns:
- parsed CondensedProbabilityDistribution
- Throws:
ParserException- parse exception
-
Distribution
public static final CondensedProbabilityDistribution Distribution(RpclSemantics semantics, FolSignature signature) throws ParseException Create a distribution- Parameters:
semantics- the semanticssignature- the signiture- Returns:
- a distribution
- Throws:
ParseException- error
-
ProbabilityAssignment
public static final Pair<ReferenceWorld, Probability> ProbabilityAssignment(FolSignature signature) throws ParseException Parses a probability assignment from the input stream.This method processes a
ReferenceWorldfollowed by a probability value (which could either be a probability or a multiplicator). The method combines the parsedReferenceWorldwith the probability and returns them as aPair.- Parameters:
signature- TheFolSignatureto which the constants in theReferenceWorldbelong. If a constant is not found in the signature, it is added to it.- Returns:
- A
Paircontaining the parsedReferenceWorldand its associatedProbability. - Throws:
ParseException- If there is an error during the parsing process.
-
Interpretation
Parses anInterpretation(specifically, aReferenceWorld) from the input stream- Parameters:
signature- TheFolSignatureto which the parsed constants and predicates belong. If a constant or predicate is not found in the signature, it is added to it.- Returns:
- A
ReferenceWorldthat contains the predicates and their instance assignments. - Throws:
ParseException- If there is an error during the parsing process.
-
InstanceAssignment
public static final InstanceAssignment InstanceAssignment(FolSignature signature) throws ParseException Parses anInstanceAssignmentfrom the input stream.This method processes the predicate, constants, and multiplicators, and constructs an
InstanceAssignment. The predicate is either retrieved from the givenFolSignatureif it exists, or a new one is created and added to the signature. The method then parses multiple sets of constants and their associated multiplicators, adding them to theInstanceAssignment.- Parameters:
signature- TheFolSignatureto which the constants and predicates belong. If a constant or predicate is not found in the signature, it is added to it.- Returns:
- An
InstanceAssignmentcontaining the parsed predicate and associated constants with their multiplicators. - Throws:
ParseException- If there is an error during the parsing process.
-
ConstantSet
Parses a set of constants from the input and adds them to the specifiedFolSignature.- Parameters:
signature- TheFolSignatureto which the constants belong. If a constant is not found in the signature, it is added to it.- Returns:
- A
SetofConstantobjects that were parsed from the input. - Throws:
ParseException- If there is an error during the parsing process.
-
ReInit
Reinitializes the parser with a new input stream using the default character encoding.- Parameters:
stream- The new input stream for the parser.- See Also:
-
ReInit
Reinitializes the parser with a new input stream and character encoding.- Parameters:
stream- The new input stream for the parser.encoding- The character encoding of the input stream.- Throws:
RuntimeException- If the specified encoding is not supported.
-
ReInit
-
ReInit
Reinitialise.- Parameters:
tm- the tokenmanager
-
getNextToken
-
getToken
Get the specific Token.- Parameters:
index- the index- Returns:
- the token
-
generateParseException
Generate ParseException.- Returns:
- a ParseException
-
enable_tracing
public static final void enable_tracing()Enable tracing. -
disable_tracing
public static final void disable_tracing()Disable tracing.
-