1 #ifndef GUI_OBJUTILS___MACRO_PARSER__HPP
2 #define GUI_OBJUTILS___MACRO_PARSER__HPP
63 static const int MAX_STRING_LEXEM_LENGTH = 4094;
120 SLocation(
Int4 pos,
int line,
int col) : m_Pos(pos), m_Line(line), m_Column(col) {}
122 void Reset() { m_Pos = -1; m_Line = 0; m_Column = 0; }
123 void IncLine() { m_Pos++; m_Line++; m_Column = 1; }
140 char m_Str[MAX_STRING_LEXEM_LENGTH + 1];
165 case eTokenBOOLCONST:
168 case eTokenINTNUMBER:
171 case eTokenFLOATNUMBER:
183 CScanner(
const char* sMacroText) : m_StrMacro(sMacroText)
188 void Reset(
const char* sMacroText) { m_StrMacro = sMacroText; x_InitScanner(); }
192 int Next(
bool parseComment =
false);
195 int NextASNSelector();
198 int NextNamedAnnot();
212 void x_InitScanner();
216 int x_GetQuotedString();
219 void x_InitForNextLexem();
272 void SetFunctionNames(
const TFunctionNamesList& wh_funcs,
const TFunctionNamesList& do_funcs);
283 { m_StrMacro = sMacroText; x_InitParser(); m_Scanner.Next(); }
345 void x_ParseScript();
348 void x_ParseVariables();
351 void x_ParseChoice();
357 void x_ParseThreadCount();
366 void x_ParseFunctionWhere();
374 void x_ParseMetaData();
379 void x_ParseNumericVarValue(
const string& var_name,
int sign);
382 void x_ParseNumericChoiceValue(
int sign);
388 bool x_IsFunction(
const string& name)
const;
391 void x_GetWhereClause(
Int4 istart,
Int4 iend,
string&
result)
const;
395 CQueryParseTree* x_QParseWhere(
const string&
str,
unsigned line,
unsigned linePos)
const;
405 void x_UpdateErrorLocation();
407 string x_GetErrorLocation()
const;
Class provides macro language interface for bulk bio-editing.
Class for parsed macro representation.
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Query execution environment holds the function registry and the execution context.
Query tree and associated utility methods.
Class for lexical tokens extraction from macro string.
definition of a Culling tree
Include a standard set of the NCBI C++ Toolkit most basic headers.
static const char * str(char *buf, int n)
CMacroParser(const CMacroParser &)
Prohibit copy constructor and assignment operator.
static const char * sm_Automatic
const SLexem & GetLexemInfo() const
void SetSource(const char *sMacroText)
Reset the parser and sets macro text to be parsed.
SLocation GetErrorLocation() const
CMacroRep * m_MacroRep
binary representation of macro while parsing
CMacroRep * DetachMacroRep()
Detach macro representation for futher processing Caller is responsible for deletion of returned obje...
TFunctionNamesList m_DoFunctionsList
list of functions available for Do clause
void SetErrLocReportType(EParsingErrReportType type)
Get the error location from the most recent parsing.
CScanner(const char *sMacroText)
const TFunctionNamesList & GetWhereFunctions() const
get list of where functions
CQueryParseTree::TFunctionNames TFunctionNamesList
Type for the list of functions in Where/Do clauses.
CScanner & operator=(const CScanner &)
CScanner::SLocation m_ErrorLocation
error location
const TFunctionNamesList & GetDoFunctions() const
get list of do functions
string GetStringRepr() const
set< string > m_RTVars
list of run-time variables met in the left side of assignment in DO clause
CScanner(const CScanner &)
Prohibit copy constructor and assignment operator.
CMacroParser & operator=(const CMacroParser &)
CScanner m_Scanner
scanner for extracting tokens and meta info
SLocation(Int4 pos, int line, int col)
CMacroParser()
Constructor.
EParsingErrReportType m_ErrorReportType
Specifies the type of error reporting.
virtual ~CMacroParser()
Destructor.
TFunctionNamesList m_WhereFunctionsList
list of functions available for Where clause
void Reset(const char *sMacroText)
const char * m_StrMacro
string to be parsed
char m_Str[MAX_STRING_LEXEM_LENGTH+1]
@ eErrorLineAndColumn
Report the line and column for the error (default)
@ eTokenKWDONE
Keyword done.
@ eTokenKWVARS
Keyword var or vars.
@ eTokenKWDOPARL
Keyword do_p(arallel)
@ eTokenKWPARLAUTO
Keyword auto used with do_p keyword.
@ eTokenNOTEQUAL
'<>' token
@ eTokenRIGHTPAREN
')' token
@ eTokenKWEACH
Keyword each as a part of for each.
@ eTokenKWCHOICE
Keyword choice.
@ eTokenNOTLESS
'>=' token
@ eTokenASNSELECTOR
ASN selector.
@ eTokenLEFTPAREN
'(' token
@ eTokenKWMACRO
Keyword macro.
@ eTokenBOOLCONST
Boolean const value.
@ eTokenLEFTBRACE
'{' token
@ eTokenLEFTBRACKET
'[' token
@ eTokenFLOATNUMBER
Floating point number.
@ eTokenKWWHERE
Keyword where.
@ eTokenASSIGNMENT
'=' token
@ eTokenNOTGREATER
'<=' token
@ eTokenINTNUMBER
Integer number.
@ eTokenKWFROM
Keyword from for specifying named annotation.
@ eTokenSTRING
String in double quotes.
@ eTokenFUNCTION
Built-in function.
@ eTokenKWRANGE
Keyword range.
@ eTokenASK
String enclosed in % symbols.
@ eTokenRIGHTBRACE
'}' token
@ eTokenRIGHTBRACKET
']' token
@ eTokenSEMICOLON
';' token
@ eTokenKWFOR
Keyword for as a part of for each.
@ eTokenNAMEDANNOT
Named annotation.
int32_t Int4
4-byte (32-bit) signed integer
vector< string > TFunctionNames
List of keywords recognised as functions.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
#define NCBI_GUIOBJUTILS_EXPORT
Defines to provide correct exporting from DLLs in Windows.
The NCBI C++/STL use hints.
Query parser execution implementations.
Source location (points to the position in the original src) All positions are 0 based.