Package gavo :: Package grammars :: Module directgrammar
[frames] | no frames]

Module directgrammar

source code

A grammar supporting C language boosters (or possibly other mechanisms bypassing internal dbtable).

These actually bypass most of our machinery and should only be used if performance is paramount. Otherwise, CustomGrammars play much nicer with the rest of the DC software.

Currently, only one kind of DirectGrammar is supported: C boosters.

Classes
  CBooster
is a wrapper for an import booster written in C using the DC booster infrastructure.
  DirectGrammar
A user-defined external grammar.
  ColCodeGenerator
  SplitCodeGenerator
a code generator for parsing files with lineas and separators.
  BinCodeGenerator
a code generator for reading fixed-length binary records.
  FITSCodeGenerator
A code generator for reading from FITS binary tables.
Functions
 
getNameForItem(item) source code
 
getCodeGen(grammar, tableDef)
returns the code generator suitable for making code for grammar.
source code
 
getEnum(td, grammar) source code
 
getGetTuple(td, codeGen) source code
 
indent(stringList, indentChar) source code
 
buildSource(grammar, td)
returns (possibly incomplete) C source for a booster to read into td.
source code
 
getGrammarAndTable(grammarId)
returns a pair of directGrammar and table being fed for a cross-rd reference.
source code
 
parseCmdLine() source code
 
getSource(grammarId)
returns a bytestring containing C source to parse grammarId.
source code
 
main() source code
Variables
  COMMON_MAIN_HEADER = '\n/* Common main header */\nvoid createD...
  NONSEEK_MAIN_INTRO = '\n\tFILE *inF;\n\n\t/* seekable main int...
  COMMON_MAIN_INTRO = '\n\t/* common main intro */\n\twriteHeade...
  LOOP_BODY_INTRO = '\n\t\tField *tuple;\n\t\tcontext = inputLin...
  LOOP_BODY_FOOT = '\n\t\t\tif (!tuple) {\n\t\t\t\thandleBadReco...
  COMMON_MAIN_FOOT = '\n\twriteEndMarker(destination);\n\tfprint...
  __package__ = 'gavo.grammars'
Variables Details

COMMON_MAIN_HEADER

Value:
'''
/* Common main header */
void createDumpfile(int argc, char **argv)
{
\tFILE *destination=stdout;
\tchar inputLine[INPUT_LINE_MAX];
\tint recCount = 0;
/* /Common main header */
...

NONSEEK_MAIN_INTRO

Value:
'''
\tFILE *inF;

\t/* seekable main intro */
\tif (argc>2) {
\t\tdie(USAGE);
\t}
\tif (argc==2) {
...

COMMON_MAIN_INTRO

Value:
'''
\t/* common main intro */
\twriteHeader(destination);
\t/* /common main intro */
'''

LOOP_BODY_INTRO

Value:
'''
\t\tField *tuple;
\t\tcontext = inputLine;
\t\tif (!setjmp(ignoreRecord)) {
'''

LOOP_BODY_FOOT

Value:
'''
\t\t\tif (!tuple) {
\t\t\t\thandleBadRecord("Bad input line at record %d", recCount);
\t\t\t}
\t\t\twriteTuple(tuple, QUERY_N_PARS, destination);
\t\t\tcontext = NULL;
\t\t\trecCount ++;
\t\t\tif (!(recCount%1000)) {
...

COMMON_MAIN_FOOT

Value:
'''
\twriteEndMarker(destination);
\tfprintf(stderr, "%08d records done.\\n", recCount);
}
'''