Gaudi Framework, version v20r4

Generated: 8 Jan 2009

Gaudi::Parsers::ParserGrammar Class Reference

#include <ParserGrammar.h>

List of all members.


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


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 &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

Parserm_parser

Classes

struct  definition

Constructor & Destructor Documentation

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

Constructor.

Parameters:
parser Pointer to parser

Definition at line 480 of file ParserGrammar.h.

00480 {m_parser=parser;}

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

Definition at line 481 of file ParserGrammar.h.

00481 {}


Member Function Documentation

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

Get pointer to parser.

Definition at line 484 of file ParserGrammar.h.

00484 {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 490 of file ParserGrammar.h.

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

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 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->matchUnits(fileName,pos);
00504       }

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

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

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

00563                                                           {
00564         bool iswin = Gaudi::Parsers::Utils::isWin();
00565         if(directive=="endif" || (directive=="ifdef" && iswin)
00566           || (directive=="ifndef" && !iswin)){
00567           attrs().get<0>() = true;
00568         } else {
00569           attrs().get<0>() = !attrs().get<0>();
00570         }
00571       }

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

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

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

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

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

00597                                                                               {
00598         if(!doActions()) return;
00599         attrs().get<1>() = value.get<0>();
00600         attrs().get<2>() = value.get<1>();
00601       }

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

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


Member Data Documentation

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

Definition at line 734 of file ParserGrammar.h.


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

Generated at Thu Jan 8 17:53:46 2009 for Gaudi Framework, version v20r4 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004