| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

Classes | Public Member Functions | Private Attributes

# Gaudi::Parsers::ParserGrammar Class Reference

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

`#include <ParserGrammar.h>`

Inheritance diagram for Gaudi::Parsers::ParserGrammar:
[legend]
Collaboration diagram for Gaudi::Parsers::ParserGrammar:
[legend]

List of all members.

## Classes
struct | definition
## 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

## 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.

    {m_parser=parser;}

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

Definition at line 490 of file ParserGrammar.h.

    {}

## Member Function Documentation

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.

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

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.

                                                             {
            if(!doActions()) return;

            // position where statement appears
            file_position fpos = val().get_position();
            Position pos(fpos.file,fpos.line,fpos.column);

            // get value representation. It's two modes string and vector of strings
            std::string value = attrs().get<1>();
            std::vector<std::string> vectorValues = attrs().get<2>();

            // check if value is vector
            bool isVector = false;
            if(vectorValues.size()>0 || value=="[]"){
              isVector = true;
            }else{
              vectorValues.push_back(value);
            }

            // extract object, option name and sign
            std::string objectName;
            std::string delim;
            std::vector< std::string >::const_iterator cur;
            for ( cur  = params.begin();
                  *(cur+1) != "#"; cur++ ){
              objectName += delim + *cur;
              delim = ".";
            }

            std::string optionName = *cur;
            std::string sign = *(cur+2);

            Parser::Sign oper;
            if(sign == "+="){
              oper = Parser::S_PLUSASSIGN;
            }else if(sign == "-="){
              oper = Parser::S_MINUSASSIGN;
            }else{
              oper = Parser::S_ASSIGN;
            }

            m_parser->matchAssign
              (objectName, optionName, oper,
               vectorValues,pos,isVector);
            vectorValues.clear();
          }

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.

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

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.

                                                              {
            bool iswin = Gaudi::Parsers::Utils::isWin();
            if(directive=="endif" || (directive=="ifdef" && iswin)
              || (directive=="ifndef" && !iswin)){
              attrs().get<0>() = true;
            } else {
              attrs().get<0>() = !attrs().get<0>();
            }
          }

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.

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

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.

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

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.

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

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.

                                                                                  {
            if(!doActions()) return;
            attrs().get<1>() = value.get<0>();
            attrs().get<2>() = value.get<1>();
          }

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

Get pointer to parser.

Definition at line 493 of file ParserGrammar.h.

    {return m_parser;}

## 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_v22r2/GaudiSvc/src/JobOptionsSvc/ParserGrammar.h

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines