LLOOP Index | GSP Language | GSP Library | Framework Classes | Component Classes

SIniFile Class Reference

#include "ini__SIniFile.h"

SIniFile non-terminal symbol class. More...


Inherited Class(es)


Public Functions

SIniFile ( ) 
~SIniFile ( ) 
SectionListRef ( ) 
  • bool 
backtrace ( std::ostream & os 
  • bool 
expand ( std::ostream & os , bool bRestoreWS = true ) 
expand ( bool bTrimFirstWhitespaces = true , bool bRestoreWS = true ) 
getRightByIndex ( unsigned long uIndex 
getSectionList ( ) 
getSymbolName ( ) const 
  • bool 
isNonTerminal ( ) const 
  • bool 
isToken ( ) const 
  • bool 
parse ( std::istream & is , std::ostream & os gsp::Symbol * pParent = NULL , bool bExpectEOF = false , bool bDeactivatePreprocessing = false ) 
  • bool 
parse ( std::istream & is gsp::Symbol * pParent = NULL , bool bExpectEOF = false , bool bDeactivatePreprocessing = false ) 
  • bool 
parseRoot ( ini::Parser & parser SIniFile * & pReturnSymbol gsp::Symbol * pParent = NULL , bool bBreakOff = true ) 
  • bool 
parseSymbol gsp::LLParser & parser gsp::Symbol * & rpReturnSymbol gsp::Symbol * pParent = NULL ) 
  • bool 
parseSymbol ( ini::Parser & parser SIniFile * & rpReturnSymbol gsp::Symbol * pParent = NULL ) 
  • void 
reset ( ) 
  • void 
setSectionList SectionList * pSectionList 
  • bool 
test ( std::ostream & os , bool bVerbose = false ) 
  • bool 
visit gsp::Visitor & visitor gsp::Symbol * & pReturnSymbol 

Protected Functions

  • void 
initRule ( ) 
reduce ( ini::Parser & parser 
reduce ( const long lRuleRank , ini::Parser & parser 

Private Functions

  • const unsigned long * 
getFirstsDescriptions ( ) const 
  • unsigned long 
getNbRules ( ) const 
  • unsigned long 
getNbSymbolsInRule ( long lRuleRank ) const 
  • unsigned long 
getSymbolDescription ( long lRuleRank , long lSymbolRank ) const 

Public Static Functions

factory ( ) 
  • bool 
is_a gsp::Symbol * pSymbol 
  • int 
maxOccurrences ( ) 
  • void 
maxOccurrences ( int iMaxOcc 
  • int 
minOccurrences ( ) 
  • void 
minOccurrences ( int iMinOcc 
  • void 
setFactory SIniFileFactory * pNewFactory 

Protected Variables

  • unsigned char 
m_cWsFlag [ 2 + 1 ] [ 20 ] 
  • unsigned short 
m_uNbWs [ 2 + 1 ] 

Private Variables

  • bool 
m_bOption1_0Parsed 
m_pSectionList 

Protected Static Variables

  • int 
m_iMaxOccurrences 
  • int 
m_iMinOccurrences 
ms_factory 

Private Static Variables

  • unsigned long 
FIRSTS [ 1 + 1 ] 
  • unsigned long 
NB_FIRSTS 
  • unsigned long 
NB_RULES 
  • unsigned long 
RULES [ 1 ] [ 2 ] 

Friends

  • class 
SIniFileFactory 

Detailed Description

SIniFile non-terminal symbol class.

This class provides the generated parse and expand code for a non-terminal.

It also contains the coded description of the rules defined for this non-terminal.


Files Included

#include <stdarg.h>
#include "gsp__Symbol.h"

Functions Documentation

int maxOccurrences ( )   [  static  ] 

Returns the maximum allowed number of occurrences of this symbol or -1 if there is no limit.

See also:

Back to index

int minOccurrences ( )   [  static  ] 

Returns the minimum required number of occurrences of this symbol or -1 if there is no limit.

See also:

Back to index

void maxOccurrences ( int iMaxOcc   [  static  ] 

Sets the maximum allowed number of occurrences of this symbol. -1 if there is no limit.

See also:

Back to index

void minOccurrences ( int iMinOcc   [  static  ] 

Sets the minimum required number of occurrences of this symbol. -1 if there is no limit.

See also:

Back to index

SIniFile ( ) 

Non-terminal symbol class constructor.

See also:

Back to index

~SIniFile ( )   [  virtual  ] 

Non-terminal symbol class destructor.

See also:

Back to index

bool isToken ( ) const   [  virtual  ] 

Tells whether the symbol is token.

See also:

Back to index

bool isNonTerminal ( ) const   [  virtual  ] 

Tells whether the symbol is a non-terminal.

See also:

Back to index

unsigned long getNbRules ( ) const   [  private  ] 

Please refer to the matching overriden method description in base class.

See also:

virtual unsigned long gsp::Symbol::getNbRules ( ) const 
Back to index

unsigned long getNbSymbolsInRule ( long lRuleRank ) const   [  private  ] 

Please refer to the matching overriden method description in base class.

See also:

virtual unsigned long gsp::Symbol::getNbSymbolsInRule ( long lRuleRank ) const 
Back to index

unsigned long getSymbolDescription ( long lRuleRank , long lSymbolRank ) const   [  private  ] 

Please refer to the matching overriden method description in base class.

See also:

virtual unsigned long gsp::Symbol::getNbSymbolsInRule ( long lRuleRank ) const 
Back to index

const unsigned long * getFirstsDescriptions ( ) const   [  private  ]   [  virtual  ] 

Please refer to the matching overriden method description in base class.

See also:

virtual const unsigned long * gsp::Symbol::getFirstsDescriptions ( ) const 
Back to index

bool visit gsp::Visitor & visitor gsp::Symbol * & pReturnSymbol   [  virtual  ] 

Visits the symbol with visitor and returns in pReturnSymbol a pointer to a replacing symbol (if any).

Returns true if the visit was accepted and successful.

See also:

virtual bool gsp::Symbol::visit gsp::Visitor & visitor Symbol * & pReturnSymbol ) = 0 
bool gsp::Symbol::visit gsp::Visitor & visitor ) = 0 
Back to index

bool parseSymbol gsp::LLParser & parser gsp::Symbol * & rpReturnSymbol gsp::Symbol * pParent   [  virtual  ] 

Please refer to the matching overriden method description in base class.

See also:

virtual bool gsp::Symbol::parseSymbol LLParser & parser Symbol * & rpReturnSymbol Symbol * pParent ) = 0 
bool SIniFile::parseSymbol ( ini::Parser & parser SIniFile * & rpReturnSymbol gsp::Symbol * pParent 
Back to index

bool parseSymbol ( ini::Parser & parser SIniFile * & rpReturnSymbol gsp::Symbol * pParent 

Used internally by the generated code to carry out the parsing of the symbol.

See also:

virtual bool gsp::Symbol::parseSymbol LLParser & parser Symbol * & rpReturnSymbol Symbol * pParent ) = 0 
Back to index

bool parseRoot ( ini::Parser & parser SIniFile * & pReturnSymbol gsp::Symbol * pParent , bool bBreakOff 

This function attempts to carry out a raw parsing of this symbol using parser, without pre-processing the input stream before.

The symbol is parsed as the root symbol would be, i.e. the line numbering in stream starts counting from zero and it is checked that the end of the stream is encountered if a stream break-off was expected.

pReturnSymbol is the symbol pointer returned by the parsing.

pParent gives the initial parent for the symbol parent to parse. By default it is null, i.e. the symbol is the root and has no parent.

bBreakOff tells whether a stream break-off is expected at the end of the parsing (true by default).

Returns true when the symbol could be successfully parsed, regardless of whether user errors were raised from reduction code. For that purpose, the return value of fail() should also always be checked in parallel to handle these errors.

See also:

virtual bool parse ( std::istream & is , std::ostream & os gsp::Symbol * pParent = NULL , bool bExpectEOF = false , bool bDeactivatePreprocessing = false ) 
virtual bool parse ( std::istream & is gsp::Symbol * pParent = NULL , bool bExpectEOF = false , bool bDeactivatePreprocessing = false ) 
bool gsp::Symbol::fail ( ) const 
void gsp::Symbol::error ( std::ostream & os , unsigned long uErrorLineNo , const char * pszFormattedMsg , ... ) 
void gsp::Symbol::error ( std::streampos errorOffset , unsigned int uErrorLineNo 
void gsp::Symbol::fatal ( const char * pszFormattedMsg , ... ) 
Back to index

bool parse ( std::istream & is , std::ostream & os gsp::Symbol * pParent , bool bExpectEOF , bool bDeactivatePreprocessing   [  virtual  ] 

This function attempts to parse this symbol in a input stream is and error messages are re-directed to output stream os.

pParent gives the initial parent for the symbol parent to parse. By default it is null, i.e. the symbol is the root and has no parent.

bDeactivatePreprocessing tells whether preprocessing should be deactivated before the actual parsing takes place. This argument is optional and is set to false by default.

The symbol is parsed as the root symbol would be, i.e. the line numbering in stream starts counting from zero.

bExpectEOF tells whether to expect an end-of-stream at the end of parsing. This parameter is optional and set to false by default.

This function is useful when the users don't want to parse a stream starting from the root symbol of the grammar, but from whatever else symbol, without having to create by himself the parser object and output possible error messages.

With this function there is no way to get the symbol returned by the reduction code.

Basically, calling this method is equivalent to:

Example:

  ...Parser parser(is);
  ...parser.deactivatePreprocessing(bDeactivatePreprocessing);
  ...parser.preprocess();
  ...parseRoot();

See also:

bool parseRoot ( ini::Parser & parser SIniFile * & pReturnSymbol gsp::Symbol * pParent = NULL , bool bBreakOff = true ) 
Back to index

bool parse ( std::istream & is gsp::Symbol * pParent , bool bExpectEOF , bool bDeactivatePreprocessing   [  virtual  ] 

This overloaded function is provided for convenience and behaves like the above function, except that error messages are forced to be output on the standard error output cerr.

Therefore, it is strictly equivalent to calling:

parse(is, cerr, pParent, bDeactivatePreprocessing)

See also:

virtual bool parse ( std::istream & is , std::ostream & os gsp::Symbol * pParent = NULL , bool bExpectEOF = false , bool bDeactivatePreprocessing = false ) 
virtual bool parse ( std::istream & is gsp::Symbol * pParent = NULL , bool bExpectEOF = false , bool bDeactivatePreprocessing = false ) 
Back to index

bool expand ( std::ostream & os , bool bRestoreWS   [  virtual  ] 

Expands the non-terminal. See documentation of overriden method referred to below.

This method ensures the following:

- If the default/normal expanding was ok and it is the root, the original trailing whitespaces are restored.

- If the non-terminal is a composite, the expanding will result of the expanding of all components.

- Return true on success only.

NO end-of-stream char ('\0') is appended to the result string.

See also:

virtual bool gsp::Symbol::expand ( std::ostream & os , bool bRestoreWS = true ) 
Back to index

universal::String expand ( bool bTrimFirstWhitespaces , bool bRestoreWS 

This function is provided for convenience and behaves like the other expand() function, except that :

on failure an empty string is returned;

the first leading whitespaces are removed by default. This can be switched off by setting bTrimFirstWhitespaces to false.

bRestoreWS is also optional and tells whether to restore all whitespaces. This is the case by default. If not so, the value of bTrimFirstWhitespaces is actually overriden and ignored.

See also:

universal::String gsp::Symbol::expand ( bool bTrimFirstWhitespaces = true , bool bRestoreWS = true ) 
Back to index

bool backtrace ( std::ostream & os   [  virtual  ] 

Backtraces the non-terminal.

See also:

virtual bool gsp::Symbol::backtrace ( std::ostream & os ) = 0 
Back to index

bool test ( std::ostream & os , bool bVerbose   [  virtual  ] 

Tests the symbol according to the test cases specified along the symbol definition.

For further information please see the test() function of the base symbol class.

See also:

bool gsp::Symbol::test ( std::ostream & os , unsigned long uNbTestCases , universal::String * pasTestCaseNames , universal::String * pasTestCaseInputs , universal::String * pasTestCaseOutputs , bool * pabResults , bool bVerbose 
virtual bool gsp::Symbol::backtrace ( std::ostream & os ) = 0 
void LLParser::outputFailureContext ( std::ostream & os , unsigned long uNbLinesAround = 1 ) 
Back to index

SIniFileFactory & factory ( )   [  static  ] 

Returns the factory object for such non-terminal.

See also:

Back to index

void setFactory SIniFileFactory * pNewFactory   [  static  ] 

Sets pNewFactory as the new factory object for such non-terminal.

The previous factory is not destroyed.

See also:

Back to index

bool is_a gsp::Symbol * pSymbol   [  static  ] 

Tells whether the passed symbol pointer narrows to a symbol pointer of this type.

See also:

Back to index

SectionList * getSectionList ( ) 

Self-explanatory.

See also:

Back to index

SectionList & SectionListRef ( ) 

Self-explanatory. If the object is null or was not parsed, fatal() is called. This raises an exception which is normally caught by the parser object during parsing.

See also:

void Symbol::fatal ( const char * pszFormattedMsg , ... ) 
Back to index

void setSectionList SectionList * pSectionList 

Self-explanatory.

See also:

Back to index

universal::String getSymbolName ( ) const 

Returns the name of this non-terminal symbol class.

See also:

Back to index

SIniFile * reduce ( ini::Parser & parser   [  protected  ] 

Executes the reduction code for the non-terminal. It includes the reduction code written for this non-terminal in the grammar.

Returns the pointer to the symbol returned by the reduction code. If the user does not specify another return symbol, it'll be a pointer to the symbol object itself.

See also:

Back to index

SIniFile * reduce ( const long lRuleRank , ini::Parser & parser   [  protected  ] 

Executes the reduction code for the rule of rank lRuleRank.

See also:

SIniFile * reduce Parser & parser 
Back to index

gsp::Symbol & getRightByIndex ( unsigned long uIndex   [  virtual  ] 

Please refer to the matching overriden method description in base class.

See also:

virtual Symbol & gsp::Symbol::getRightByIndex ( unsigned long uIndex 
Back to index

void reset ( )   [  virtual  ] 

Please refer to the matching overriden method description in base class.

If a rule was reduced for this symbol, all the right symbols appearing in that rule are destroyed/recycled using their respective factory.

If this is a composite symbol, the components are destroyed.

See also:

void gsp::Symbol::reset ( ) 
Back to index

void initRule ( )   [  protected  ] 

Initializes the symbol for parsing any of its rule.

See also:

Back to index


This file is part of the LLOOP Reversible Object-Oriented Parser Generator. Copyright (c) 2005-2006 Michel MEHL, France. All rights reserved. LLOOP is distributed by the company ERSA SaRL.


Copyright (c) 2005-2006 Michel MEHL, Haguenau, France
LLOOP version 1.1


Generated with makedoc.