dlvhex  2.5.0
MLPSyntaxChecker Class Reference

The complete class to perform syntactic checking on the modular logic programs. More...

#include <include/dlvhex2/MLPSyntaxChecker.h>

Collaboration diagram for MLPSyntaxChecker:

Public Member Functions

 MLPSyntaxChecker (ProgramCtx &ctx1)
 Constructor.
bool verifySyntax ()
 Overall validation.

Private Member Functions

int getArity (std::string predName)
 Detects the arity of a predicate.
int getArity (ID idp)
 Detects the arity of a predicate.
std::string getStringBeforeSeparator (const std::string &s)
 Extracts the module prefix from a string.
std::string getStringAfterSeparator (const std::string &s)
 Strips off the module prefix from a string.
bool verifyPredInputsArityModuleCall (ID module, Tuple tuple)
 Checks the input arities of modules.
bool verifyPredOutputArityModuleCall (ID module, ID outputpredicate)
 Checks the output arities of modules.
bool verifyAllModuleCalls ()
 Overall validation.

Private Attributes

ProgramCtx ctx
 ProgramCtx.

Detailed Description

The complete class to perform syntactic checking on the modular logic programs.

Definition at line 30 of file MLPSyntaxChecker.h.


Constructor & Destructor Documentation

Constructor.

Parameters:
ctx1ProgramCtx.

Definition at line 43 of file MLPSyntaxChecker.cpp.

References ctx.


Member Function Documentation

int MLPSyntaxChecker::getArity ( std::string  predName) [private]

Detects the arity of a predicate.

Parameters:
predNamePredicate name.
Returns:
Arity of predName.

Definition at line 50 of file MLPSyntaxChecker.cpp.

References ctx, and ProgramCtx::registry().

Referenced by verifyPredInputsArityModuleCall(), and verifyPredOutputArityModuleCall().

int MLPSyntaxChecker::getArity ( ID  idp) [private]

Detects the arity of a predicate.

Parameters:
predNamePredicate ID.
Returns:
Arity of predName.

Definition at line 57 of file MLPSyntaxChecker.cpp.

References ctx, ID::isTerm(), and ProgramCtx::registry().

std::string MLPSyntaxChecker::getStringAfterSeparator ( const std::string &  s) [private]

Strips off the module prefix from a string.

Parameters:
sString.
Returns:
String s without module prefix.

Definition at line 75 of file MLPSyntaxChecker.cpp.

References MODULEPREFIXSEPARATOR.

Referenced by verifyPredInputsArityModuleCall(), and verifyPredOutputArityModuleCall().

std::string MLPSyntaxChecker::getStringBeforeSeparator ( const std::string &  s) [private]

Extracts the module prefix from a string.

Parameters:
sString.
Returns:
Module prefix of s.

Definition at line 67 of file MLPSyntaxChecker.cpp.

References MODULEPREFIXSEPARATOR.

Referenced by verifyPredInputsArityModuleCall(), and verifyPredOutputArityModuleCall().

Overall validation.

Returns:
True if the modular program is syntactically valid.

Definition at line 166 of file MLPSyntaxChecker.cpp.

References ctx, DBGLOG, ModuleAtom::inputs, ModuleAtom::outputAtom, ModuleAtom::predicate, ProgramCtx::registry(), verifyPredInputsArityModuleCall(), and verifyPredOutputArityModuleCall().

Referenced by verifySyntax().

bool MLPSyntaxChecker::verifyPredInputsArityModuleCall ( ID  module,
Tuple  tuple 
) [private]

Checks the input arities of modules.

Parameters:
moduleProgram module.
tupleInput tuple.
Returns:
True if tuple is a valid input to module and false otherwise.

Definition at line 87 of file MLPSyntaxChecker.cpp.

References ctx, DBGLOG, getArity(), getStringAfterSeparator(), getStringBeforeSeparator(), Module::inputList, MODULE_FAIL(), and ProgramCtx::registry().

Referenced by verifyAllModuleCalls().

bool MLPSyntaxChecker::verifyPredOutputArityModuleCall ( ID  module,
ID  outputpredicate 
) [private]

Checks the output arities of modules.

Parameters:
moduleProgram module.
outputpredicateOutput predicate.
Returns:
True if outputpredicate is a output from module and false otherwise.

Definition at line 138 of file MLPSyntaxChecker.cpp.

References ctx, DBGLOG, getArity(), getStringAfterSeparator(), getStringBeforeSeparator(), MODULEPREFIXSEPARATOR, ProgramCtx::registry(), and Atom::tuple.

Referenced by verifyAllModuleCalls().


Field Documentation


The documentation for this class was generated from the following files: