Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Parser Class Reference

parser for command files. More...

#include <parser.h>

List of all members.

Public Methods

 Parser (const char *_fname)
 ~Parser ()
void error (int errnum, const char *args, ...)
void print (const char *args, ...)
void printcurtok (void)
void gentoken (void)
bool eatOpen (bool force)
bool eatClose (bool force)
int eatNumber (void)
bool eatSNumber (int &)

Public Attributes

int curtok
char tok_text [MAX_TOK_LENGTH]

Private Methods

int gchar (void)
void push (void)
int type (int)
void skipwhite (void)
void vprint (const char *args, va_list ap)

Private Attributes

char* fname
FILE* f
int lineno
int curch


Detailed Description

parser for command files.


Constructor & Destructor Documentation

Parser::Parser ( const char * _fname )
 

constructor

opens _fname for reading and initializes data

Parser::~Parser ( void )
 

destructor

closes command file


Member Function Documentation

bool Parser::eatClose ( bool force )
 

eats a closing bracket ')'.

if force is

  • false, the bracket is optional.
  • true, a error is printed if there is no bracket
Returns:
true if there was a bracket

int Parser::eatNumber ( void )
 

eats a positive integer

Returns:
  • >=0 if there was a number
  • -1 if there was no number

bool Parser::eatOpen ( bool force )
 

eats a opening bracket '('.

if force is

  • false, the bracket is optional.
  • true, a error is printed if there is no bracket
Returns:
true if there was a bracket

bool Parser::eatSNumber ( int & res )
 

eats a integer

writes it into the argument

Returns:
  • true if there was a number
  • false if there was no number

void Parser::error ( int errnum,
const char * args,
... )
 

prints an error

errnum is one of the ERROR_ or WARNING_ constants from errdesc.h

calls describe_error

$$ is replaced by current token

int Parser::gchar ( void ) [private]
 

void Parser::gentoken ( void )
 

drop current token and read next from input file

void Parser::print ( const char * args,
... )
 

replaces "$$" by current token, including ''

void Parser::printcurtok ( void )
 

prints current token to screen. Used for $$ replacements

void Parser::push ( void ) [private]
 

void Parser::skipwhite ( void ) [private]
 

int Parser::type ( int ch ) [private]
 

void Parser::vprint ( const char * args,
va_list ap ) [private]
 

similar to vprintf()

replaces $$ by current token


Member Data Documentation

int Parser::curch [private]
 

int Parser::curtok
 

current token type. Value is one of the PT_ defines.

class ensures that calling functions never get PT_CBEGIN, PT_CEND and PT_LINECOM.

FILE * Parser::f [private]
 

char * Parser::fname [private]
 

int Parser::lineno [private]
 

char Parser::tok_text[MAX_TOK_LENGTH]
 

string with the current token if curtok is PT_TEXT


The documentation for this class was generated from the following files:
Generated at Fri Jul 26 09:34:00 2002 for rvtmod/rvglue by doxygen1.2.0 written by Dimitri van Heesch, © 1997-2000