| # Gaudi Framework, version v21r7 |

Home |  | Generated: 22 Jan 2010

# Gaudi::Parsers::ParserGrammar Class Reference

Grammar recognize job options file `Grammar's EBNF: `job_options_file ::= (platform_statement | platform_dependency)*.`` More...

`#include <ParserGrammar.h>`

List of all members.

## Public Member Functions
| ParserGrammar (Parser *parser)
| Constructor.
virtual | ~ParserGrammar ()
Parser * | parser () const
| Get pointer to parser.
void | matchInclude (const std::string &fileName) const
| Action called when include statement matched.
void | matchUnits (const std::string &fileName) const
| Action called when units statement matched.
void | matchAssign (std::vector< std::string > params) const
| Match assign statement.
void | matchPlatform (const std::string &directive) const
| Action called when platform dependency statement matched.
void | matchPrint (bool on) const
| Action called when print pragma matched.
void | matchPrintOptions (bool on) const
| Action called when printOptions.
void | matchValue (boost::tuple< std::string, std::vector< std::string > > value) const
| Action called when value in assign statement matched.
bool | doActions () const
| Check if we can execute platform statements.
## Private Attributes
Parser * | m_parser
## Classes
struct | definition

## Detailed Description

Grammar recognize job options file `Grammar's EBNF: `job_options_file ::= (platform_statement | platform_dependency)*.``

platform_statement ::= assertable_statement | pragma_statement. assertable_statement ::= include_statement | units_statement | assign_statement. platform_dependency ::= ("#ifdef" | "#ifndef") "WIN32" platform_statement* ("#else" platform_statement*)? "endif. include_statement ::= "#include" string_grammar. units_statement ::= "#units" string_grammar. pragma_statement ::= pragma | printopt_statement; printopt_statement ::= "#printOptions" "full". pragma ::= "#pragma" "print" ("on" | "ON" | "off" | "OFF"). assign_statement ::= identifier_grammar ('.' identifier_grammar)+ ('='|'+='|'-=') value_grammar ';'.

Grammar has two attributes

- IteratorT current parser position.
- boost::tuple<bool,string,vector<string> > 0 element - true if we can process platform statements, false - if we can't process. 1 element - string representation of value on the right side of '=' 2 element - vector representation of value on the right side of '=' (if it's vector)

See also:
  Gaudi::Parsers::ValueGrammar for value_grammar

  Gaudi::Parsers::StringGrammar for string_grammar

  Gaudi::Parsers::IdentifierGrammar for identifier_grammar

Author:
  Alexander MAZUROV Alexander.Mazurov@gmail.com

  Vanya BELYAEV ibelyaev@physics.syr.edu

Date:
  2006-05-14

Definition at line 482 of file ParserGrammar.h.

## Constructor & Destructor Documentation

Gaudi::Parsers::ParserGrammar::ParserGrammar | ( | Parser * | parser | ) | `[inline]`

Constructor.

Parameters:

  | parser | Pointer to parser

Definition at line 489 of file ParserGrammar.h.

    00489 {m_parser=parser;}

virtual Gaudi::Parsers::ParserGrammar::~ParserGrammar | ( |  | ) | `[inline, virtual]`

Definition at line 490 of file ParserGrammar.h.

    00490 {}

## Member Function Documentation

Parser* Gaudi::Parsers::ParserGrammar::parser | ( |  | ) | const`[inline]`

Get pointer to parser.

Definition at line 493 of file ParserGrammar.h.

    00493 {return m_parser;}

void Gaudi::Parsers::ParserGrammar::matchInclude | ( | const std::string & | fileName | ) | const`[inline]`

Action called when include statement matched.

Parameters:

  | fileName | Name of file in include statement

Definition at line 499 of file ParserGrammar.h.

    00499                                                         {
    00500         if(!doActions()) return;
    00501         file_position fpos = this->val().get_position();
    00502         Position pos(fpos.file,fpos.line,fpos.column);
    00503         m_parser->matchInclude(fileName,pos);
    00504       }

void Gaudi::Parsers::ParserGrammar::matchUnits | ( | const std::string & | fileName | ) | const`[inline]`

Action called when units statement matched.

Parameters:

  | fileName | Name of file in units statement

Definition at line 508 of file ParserGrammar.h.

    00508                                                       {
    00509         if(!doActions()) return;
    00510         file_position fpos = this->val().get_position();
    00511         Position pos(fpos.file,fpos.line,fpos.column);
    00512         m_parser->matchUnits(fileName,pos);
    00513       }

void Gaudi::Parsers::ParserGrammar::matchAssign | ( | std::vector< std::string > | params | ) | const`[inline]`

Match assign statement.

Parameters:

  | params[0]-params[N-3] | Name of object
  | params[N-2] | Delimiter
  | params[N-1] | Option name
  | params[N] | Operation

Definition at line 521 of file ParserGrammar.h.

    00521                                                          {
    00522         if(!doActions()) return;
    00523
    00524         // position where statement appears
    00525         file_position fpos = val().get_position();
    00526         Position pos(fpos.file,fpos.line,fpos.column);
    00527
    00528         // get value representation. It's two modes string and vector of strings
    00529         std::string value = attrs().get<1>();
    00530         std::vector<std::string> vectorValues = attrs().get<2>();
    00531
    00532         // check if value is vector
    00533         bool isVector = false;
    00534         if(vectorValues.size()>0 || value=="[]"){
    00535           isVector = true;
    00536         }else{
    00537           vectorValues.push_back(value);
    00538         }
    00539
    00540         // extract object, option name and sign
    00541         std::string objectName;
    00542         std::string delim;
    00543         std::vector< std::string >::const_iterator cur;
    00544         for ( cur  = params.begin();
    00545               *(cur+1) != "#"; cur++ ){
    00546           objectName += delim + *cur;
    00547           delim = ".";
    00548         }
    00549
    00550         std::string optionName = *cur;
    00551         std::string sign = *(cur+2);
    00552
    00553         Parser::Sign oper;
    00554         if(sign == "+="){
    00555           oper = Parser::S_PLUSASSIGN;
    00556         }else if(sign == "-="){
    00557           oper = Parser::S_MINUSASSIGN;
    00558         }else{
    00559           oper = Parser::S_ASSIGN;
    00560         }
    00561
    00562         m_parser->matchAssign
    00563           (objectName, optionName, oper,
    00564            vectorValues,pos,isVector);
    00565         vectorValues.clear();
    00566       }

void Gaudi::Parsers::ParserGrammar::matchPlatform | ( | const std::string & | directive | ) | const`[inline]`

Action called when platform dependency statement matched.

Parameters:

  | directive | - name of directive

Definition at line 572 of file ParserGrammar.h.

    00572                                                           {
    00573         bool iswin = Gaudi::Parsers::Utils::isWin();
    00574         if(directive=="endif" || (directive=="ifdef" && iswin)
    00575           || (directive=="ifndef" && !iswin)){
    00576           attrs().get<0>() = true;
    00577         } else {
    00578           attrs().get<0>() = !attrs().get<0>();
    00579         }
    00580       }

void Gaudi::Parsers::ParserGrammar::matchPrint | ( | bool | on | ) | const`[inline]`

Action called when print pragma matched.

Parameters:

  | on | true - printing is on, false - printing is off

Definition at line 586 of file ParserGrammar.h.

    00586                                     {
    00587         file_position fpos = this->val().get_position();
    00588         Position pos(fpos.file,fpos.line,fpos.column);
    00589         m_parser->setIsPrint(on,pos);
    00590       }

void Gaudi::Parsers::ParserGrammar::matchPrintOptions | ( | bool | on | ) | const`[inline]`

Action called when printOptions.

Parameters:

  | on | true - printing is on, false - printing is off

Definition at line 596 of file ParserGrammar.h.

    00596                                            {
    00597         file_position fpos = this->val().get_position();
    00598         Position pos(fpos.file,fpos.line,fpos.column);
    00599         m_parser->setIsPrintOptions(on,pos);
    00600       }

void Gaudi::Parsers::ParserGrammar::matchValue | ( | boost::tuple< std::string, std::vector< std::string > > | value | ) | const`[inline]`

Action called when value in assign statement matched.

Parameters:

  | value | Tuple of string and vector representation of value

Definition at line 606 of file ParserGrammar.h.

    00606                                                                               {
    00607         if(!doActions()) return;
    00608         attrs().get<1>() = value.get<0>();
    00609         attrs().get<2>() = value.get<1>();
    00610       }

bool Gaudi::Parsers::ParserGrammar::doActions | ( |  | ) | const`[inline]`

Check if we can execute platform statements.

Returns:
  true - we can execute platform statements, false - we can't.

Definition at line 615 of file ParserGrammar.h.

    00615 { return  attrs().get<0>();}

## Member Data Documentation

Parser* Gaudi::Parsers::ParserGrammar::m_parser`[private]`

Definition at line 743 of file ParserGrammar.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r7/GaudiSvc/src/JobOptionsSvc/ParserGrammar.h