/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

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:
Inheritance graph
[legend]
Collaboration diagram for Gaudi::Parsers::ParserGrammar:
Collaboration graph
[legend]

List of all members.

Classes

struct  definition

Public Member Functions

 ParserGrammar (Parser *parser)
 Constructor.
virtual ~ParserGrammar ()
Parserparser () const
 Get pointer to parser.
void matchInclude (const std::string &fileName) const
 Action called when include statement matched.
void matchUnits (const std::string &) 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

Parserm_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

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 380 of file ParserGrammar.h.


Constructor & Destructor Documentation

Gaudi::Parsers::ParserGrammar::ParserGrammar ( Parser parser) [inline]

Constructor.

Parameters:
parserPointer to parser

Definition at line 387 of file ParserGrammar.h.

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

Definition at line 388 of file ParserGrammar.h.

{}

Member Function Documentation

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

Get pointer to parser.

Definition at line 391 of file ParserGrammar.h.

{return m_parser;}
void Gaudi::Parsers::ParserGrammar::matchInclude ( const std::string &  fileName) const [inline]

Action called when include statement matched.

Parameters:
fileNameName of file in include statement

Definition at line 397 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::matchUnits ( const std::string &  ) const [inline]

Action called when units statement matched.

Parameters:
fileNameName of file in units statement

Definition at line 406 of file ParserGrammar.h.

                                               {
      }
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 415 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::matchPlatform ( const std::string &  directive) const [inline]

Action called when platform dependency statement matched.

Parameters:
directive- name of directive

Definition at line 466 of file ParserGrammar.h.

                                                          {
        if(directive=="endif" || directive=="ifndef"){
          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:
ontrue - printing is on, false - printing is off

Definition at line 478 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:
ontrue - printing is on, false - printing is off

Definition at line 488 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::matchValue ( boost::tuple< std::string, std::vector< std::string > >  value) const [inline]

Action called when value in assign statement matched.

Parameters:
valueTuple of string and vector representation of value

Definition at line 498 of file ParserGrammar.h.

                                                                              {
        if(!doActions()) return;
        attrs().get<1>() = value.get<0>();
        attrs().get<2>() = value.get<1>();
      }
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 507 of file ParserGrammar.h.

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

Member Data Documentation

Definition at line 635 of file ParserGrammar.h.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:50:18 for LafKernel by doxygen 1.7.4