EnglishFrenchGermanSpainItalianDutchPortugueseRussianKoreanJapaneseArabic Chinese Simplified

Sunday, June 26, 2011

OOP Recursive Decent Parsing II

#include <istream>
#include <deque>
#include <locale>

#include "Parser.h"

/**
* static functions
*/

//protptype the functions so compiler wont complain
static void ignoreSpace(std::istream& in);
static char getChar(std::istream& in);

/**
* $1 - an input stream
* pre - none
* post - all spaces up to the next non space char are removed
*/
static void ignoreSpace(std::istream& in) {
 while(isspace(in.peek())) {
  in.get();
 }
}

/**
* $1 - an input stream
* pre - none
* post - all  preceding and following space is removed. 1 non-space char is removed
*/
static char getChar(std::istream& in) {
 ignoreSpace(in); //remove all preceding space
 char ret = in.get();
 ignoreSpace(in); //remove all following space
 return ret;
}

/**
* Production
*/

//dose nothing, if we don't need to override it we don't want to
Production::~Production() {}

///ParseError

const char* ParseError::what() const throw() {
 return "a parsing error occured";
}

Artikel Terkait:

Comments :

0 comments to “OOP Recursive Decent Parsing II”

Post a Comment

 

Copyright © 2009 by Learn Technology

Template by Blogger Templates | Powered by Blogger