OpenMD  2.5
Molecular Dynamics in the Open
OpenMD::SelectionCompiler Class Reference

compile a selection script to tokens More...

#include "selection/SelectionCompiler.hpp"

Public Member Functions

bool compile (const std::string &filename, const std::string &script)
 
std::vector< int > getLineNumbers ()
 
std::vector< int > getLineIndices ()
 
std::vector< std::vector< Token > > getAatokenCompiled ()
 
std::string getErrorMessage ()
 

Private Member Functions

bool internalCompile ()
 
bool lookingAtLeadingWhitespace ()
 
bool lookingAtEndOfLine ()
 
bool lookingAtEndOfStatement ()
 
bool lookingAtString ()
 
bool lookingAtDecimal (bool allowNegative)
 
bool lookingAtInteger (bool allowNegative)
 
bool lookingAtLookupToken ()
 
bool lookingAtSpecialString ()
 
std::string getUnescapedStringLiteral ()
 
int getHexitValue (char ch)
 
bool compileCommand (const std::vector< Token > &ltoken)
 
bool compileExpression ()
 
bool compileExpression (int itoken)
 
bool clauseOr ()
 
bool clauseAnd ()
 
bool clauseNot ()
 
bool clausePrimitive ()
 
bool clauseWithin ()
 
bool clauseComparator ()
 
bool clauseChemObjName ()
 
bool clauseIndex ()
 
Token tokenNext ()
 
boost::any valuePeek ()
 
int tokPeek ()
 
bool addTokenToPostfix (const Token &token)
 
bool isNameValid (const std::string &name)
 
bool compileError (const std::string &errorMsg)
 
bool commandExpected ()
 
bool invalidExpressionToken (const std::string &ident)
 
bool unrecognizedToken ()
 
bool badArgumentCount ()
 
bool endOfExpressionExpected ()
 
bool leftParenthesisExpected ()
 
bool rightParenthesisExpected ()
 
bool commaExpected ()
 
bool unrecognizedExpressionToken ()
 
bool comparisonOperatorExpected ()
 
bool numberExpected ()
 
bool numberOrKeywordExpected ()
 

Private Attributes

std::string filename
 
std::string script
 
std::vector< int > lineNumbers
 
std::vector< int > lineIndices
 
std::vector< std::vector< Token > > aatokenCompiled
 
bool error
 
std::string errorMessage
 
std::string errorLine
 
int cchScript
 
short lineCurrent
 
int ichToken
 
int cchToken
 
std::vector< TokenatokenCommand
 
int ichCurrentCommand
 
std::vector< TokenltokenPostfix
 
std::vector< TokenatokenInfix
 
std::size_t itokenInfix
 

Detailed Description

compile a selection script to tokens

Todo:
document
expression       :: = clauseOr
clauseOr         ::= clauseAnd {OR clauseAnd}*
clauseAnd        ::= clauseNot {AND clauseNot}*
clauseNot        ::= NOT clauseNot | clausePrimitive
clausePrimitive  ::= clauseComparator |
clauseWithin |
clauseName |
none | all |
( clauseOr )
clauseComparator ::= atomproperty comparatorop integer
clauseWithin     ::= WITHIN ( clauseDistance , expression )
clauseDistance   ::= integer | decimal
clauseName::= *|string{.string{.string}}
  

Definition at line 87 of file SelectionCompiler.hpp.

Member Function Documentation

◆ addTokenToPostfix()

bool OpenMD::SelectionCompiler::addTokenToPostfix ( const Token token)
private

◆ badArgumentCount()

bool OpenMD::SelectionCompiler::badArgumentCount ( )
inlineprivate

Definition at line 178 of file SelectionCompiler.hpp.

References compileError().

◆ clauseAnd()

bool OpenMD::SelectionCompiler::clauseAnd ( )
private

◆ clauseChemObjName()

◆ clauseComparator()

◆ clauseIndex()

◆ clauseNot()

bool OpenMD::SelectionCompiler::clauseNot ( )
private

◆ clauseOr()

bool OpenMD::SelectionCompiler::clauseOr ( )
private

◆ clausePrimitive()

◆ clauseWithin()

◆ commaExpected()

bool OpenMD::SelectionCompiler::commaExpected ( )
inlineprivate

Definition at line 194 of file SelectionCompiler.hpp.

References compileError().

Referenced by clauseWithin().

◆ commandExpected()

bool OpenMD::SelectionCompiler::commandExpected ( )
inlineprivate

Definition at line 166 of file SelectionCompiler.hpp.

References compileError().

Referenced by internalCompile().

◆ comparisonOperatorExpected()

bool OpenMD::SelectionCompiler::comparisonOperatorExpected ( )
inlineprivate

Definition at line 211 of file SelectionCompiler.hpp.

References compileError().

Referenced by clauseComparator().

◆ compile()

bool OpenMD::SelectionCompiler::compile ( const std::string &  filename,
const std::string &  script 
)

◆ compileCommand()

bool OpenMD::SelectionCompiler::compileCommand ( const std::vector< Token > &  ltoken)
private

◆ compileError()

◆ compileExpression() [1/2]

bool OpenMD::SelectionCompiler::compileExpression ( )
private

◆ compileExpression() [2/2]

bool OpenMD::SelectionCompiler::compileExpression ( int  itoken)
private

◆ endOfExpressionExpected()

bool OpenMD::SelectionCompiler::endOfExpressionExpected ( )
inlineprivate

Definition at line 182 of file SelectionCompiler.hpp.

References compileError().

Referenced by compileExpression().

◆ getAatokenCompiled()

std::vector<std::vector<Token> > OpenMD::SelectionCompiler::getAatokenCompiled ( )
inline

◆ getErrorMessage()

◆ getHexitValue()

int OpenMD::SelectionCompiler::getHexitValue ( char  ch)
private

Definition at line 306 of file SelectionCompiler.cpp.

Referenced by getErrorMessage(), and getUnescapedStringLiteral().

◆ getLineIndices()

std::vector<int> OpenMD::SelectionCompiler::getLineIndices ( )
inline

Definition at line 96 of file SelectionCompiler.hpp.

References lineIndices.

Referenced by OpenMD::SelectionEvaluator::loadScript().

◆ getLineNumbers()

std::vector<int> OpenMD::SelectionCompiler::getLineNumbers ( )
inline

Definition at line 92 of file SelectionCompiler.hpp.

References lineNumbers.

Referenced by OpenMD::SelectionEvaluator::loadScript().

◆ getUnescapedStringLiteral()

std::string OpenMD::SelectionCompiler::getUnescapedStringLiteral ( )
private
Todo:

Definition at line 254 of file SelectionCompiler.cpp.

References cchToken, getHexitValue(), ichToken, and script.

Referenced by getErrorMessage(), and internalCompile().

◆ internalCompile()

◆ invalidExpressionToken()

bool OpenMD::SelectionCompiler::invalidExpressionToken ( const std::string &  ident)
inlineprivate

Definition at line 170 of file SelectionCompiler.hpp.

References compileError().

Referenced by internalCompile().

◆ isNameValid()

bool OpenMD::SelectionCompiler::isNameValid ( const std::string &  name)
private

Definition at line 668 of file SelectionCompiler.cpp.

Referenced by clauseChemObjName(), and getErrorMessage().

◆ leftParenthesisExpected()

bool OpenMD::SelectionCompiler::leftParenthesisExpected ( )
inlineprivate

Definition at line 186 of file SelectionCompiler.hpp.

References compileError().

Referenced by clauseWithin().

◆ lookingAtDecimal()

bool OpenMD::SelectionCompiler::lookingAtDecimal ( bool  allowNegative)
private

Definition at line 327 of file SelectionCompiler.cpp.

References cchScript, cchToken, ichToken, and script.

Referenced by getErrorMessage(), and internalCompile().

◆ lookingAtEndOfLine()

bool OpenMD::SelectionCompiler::lookingAtEndOfLine ( )
private

Definition at line 203 of file SelectionCompiler.cpp.

References cchScript, cchToken, ichToken, and script.

Referenced by getErrorMessage(), and internalCompile().

◆ lookingAtEndOfStatement()

bool OpenMD::SelectionCompiler::lookingAtEndOfStatement ( )
private

Definition at line 221 of file SelectionCompiler.cpp.

References cchScript, cchToken, ichToken, and script.

Referenced by getErrorMessage(), and internalCompile().

◆ lookingAtInteger()

bool OpenMD::SelectionCompiler::lookingAtInteger ( bool  allowNegative)
private

Definition at line 361 of file SelectionCompiler.cpp.

References cchScript, cchToken, ichToken, OpenMD::isInteger(), and script.

Referenced by getErrorMessage(), and internalCompile().

◆ lookingAtLeadingWhitespace()

bool OpenMD::SelectionCompiler::lookingAtLeadingWhitespace ( )
private

Definition at line 193 of file SelectionCompiler.cpp.

References cchScript, cchToken, ichToken, and script.

Referenced by getErrorMessage(), and internalCompile().

◆ lookingAtLookupToken()

bool OpenMD::SelectionCompiler::lookingAtLookupToken ( )
private

Definition at line 380 of file SelectionCompiler.cpp.

References cchScript, cchToken, ichToken, and script.

Referenced by getErrorMessage(), and internalCompile().

◆ lookingAtSpecialString()

bool OpenMD::SelectionCompiler::lookingAtSpecialString ( )
private

Definition at line 317 of file SelectionCompiler.cpp.

References cchScript, cchToken, ichToken, and script.

Referenced by getErrorMessage().

◆ lookingAtString()

bool OpenMD::SelectionCompiler::lookingAtString ( )
private

Definition at line 228 of file SelectionCompiler.cpp.

References cchScript, cchToken, ichToken, and script.

Referenced by getErrorMessage(), and internalCompile().

◆ numberExpected()

bool OpenMD::SelectionCompiler::numberExpected ( )
inlineprivate

Definition at line 215 of file SelectionCompiler.hpp.

References compileError().

Referenced by clauseComparator(), and clauseIndex().

◆ numberOrKeywordExpected()

bool OpenMD::SelectionCompiler::numberOrKeywordExpected ( )
inlineprivate

Definition at line 219 of file SelectionCompiler.hpp.

References compileError().

Referenced by clauseWithin().

◆ rightParenthesisExpected()

bool OpenMD::SelectionCompiler::rightParenthesisExpected ( )
inlineprivate

Definition at line 190 of file SelectionCompiler.hpp.

References compileError().

Referenced by clausePrimitive(), and clauseWithin().

◆ tokenNext()

Token OpenMD::SelectionCompiler::tokenNext ( )
private

◆ tokPeek()

int OpenMD::SelectionCompiler::tokPeek ( )
private

◆ unrecognizedExpressionToken()

bool OpenMD::SelectionCompiler::unrecognizedExpressionToken ( )
inlineprivate

Definition at line 198 of file SelectionCompiler.hpp.

References boost::any_cast(), compileError(), and valuePeek().

Referenced by clausePrimitive().

◆ unrecognizedToken()

bool OpenMD::SelectionCompiler::unrecognizedToken ( )
inlineprivate

Definition at line 174 of file SelectionCompiler.hpp.

References compileError().

Referenced by internalCompile().

◆ valuePeek()

boost::any OpenMD::SelectionCompiler::valuePeek ( )
private

Definition at line 499 of file SelectionCompiler.cpp.

References atokenInfix, and itokenInfix.

Referenced by getErrorMessage(), and unrecognizedExpressionToken().

Member Data Documentation

◆ aatokenCompiled

std::vector<std::vector<Token> > OpenMD::SelectionCompiler::aatokenCompiled
private

Definition at line 228 of file SelectionCompiler.hpp.

Referenced by compile(), getAatokenCompiled(), and internalCompile().

◆ atokenCommand

std::vector<Token> OpenMD::SelectionCompiler::atokenCommand
private

Definition at line 239 of file SelectionCompiler.hpp.

Referenced by compileCommand(), compileExpression(), and internalCompile().

◆ atokenInfix

std::vector<Token> OpenMD::SelectionCompiler::atokenInfix
private

Definition at line 244 of file SelectionCompiler.hpp.

Referenced by compileExpression(), tokenNext(), tokPeek(), and valuePeek().

◆ cchScript

◆ cchToken

◆ error

bool OpenMD::SelectionCompiler::error
private

Definition at line 230 of file SelectionCompiler.hpp.

Referenced by compileError(), and internalCompile().

◆ errorLine

std::string OpenMD::SelectionCompiler::errorLine
private

Definition at line 232 of file SelectionCompiler.hpp.

Referenced by compile(), and getErrorMessage().

◆ errorMessage

std::string OpenMD::SelectionCompiler::errorMessage
private

Definition at line 231 of file SelectionCompiler.hpp.

Referenced by compileError(), and getErrorMessage().

◆ filename

std::string OpenMD::SelectionCompiler::filename
private

Definition at line 223 of file SelectionCompiler.hpp.

Referenced by compile(), and getErrorMessage().

◆ ichCurrentCommand

int OpenMD::SelectionCompiler::ichCurrentCommand
private

Definition at line 241 of file SelectionCompiler.hpp.

Referenced by compile(), and internalCompile().

◆ ichToken

◆ itokenInfix

std::size_t OpenMD::SelectionCompiler::itokenInfix
private

Definition at line 245 of file SelectionCompiler.hpp.

Referenced by compileExpression(), tokenNext(), tokPeek(), and valuePeek().

◆ lineCurrent

short OpenMD::SelectionCompiler::lineCurrent
private

Definition at line 235 of file SelectionCompiler.hpp.

Referenced by internalCompile().

◆ lineIndices

std::vector<int> OpenMD::SelectionCompiler::lineIndices
private

Definition at line 227 of file SelectionCompiler.hpp.

Referenced by compile(), getLineIndices(), and internalCompile().

◆ lineNumbers

std::vector<int> OpenMD::SelectionCompiler::lineNumbers
private

Definition at line 226 of file SelectionCompiler.hpp.

Referenced by compile(), getLineNumbers(), and internalCompile().

◆ ltokenPostfix

std::vector<Token> OpenMD::SelectionCompiler::ltokenPostfix
private

Definition at line 243 of file SelectionCompiler.hpp.

Referenced by addTokenToPostfix(), and compileExpression().

◆ script


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