2008-01-26 04:33:34 +00:00
|
|
|
/* $Id: parser.h 565 2006-06-05 22:07:13Z helly $ */
|
2006-02-24 04:48:15 +00:00
|
|
|
#ifndef _parser_h
|
|
|
|
#define _parser_h
|
|
|
|
|
|
|
|
#include "scanner.h"
|
|
|
|
#include "re.h"
|
|
|
|
#include <iosfwd>
|
2006-05-25 04:32:20 +00:00
|
|
|
#include <map>
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
namespace re2c
|
|
|
|
{
|
|
|
|
|
|
|
|
class Symbol
|
|
|
|
{
|
2006-02-24 04:48:15 +00:00
|
|
|
public:
|
2006-05-25 04:32:20 +00:00
|
|
|
|
|
|
|
RegExp* re;
|
|
|
|
|
|
|
|
static Symbol *find(const SubStr&);
|
|
|
|
static void ClearTable();
|
|
|
|
|
|
|
|
typedef std::map<std::string, Symbol*> SymbolTable;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
Symbol(const SubStr& str)
|
|
|
|
: re(NULL)
|
|
|
|
, name(str)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
static SymbolTable symbol_table;
|
|
|
|
|
|
|
|
Str name;
|
|
|
|
|
|
|
|
#if PEDANTIC
|
|
|
|
Symbol(const Symbol& oth)
|
|
|
|
: re(oth.re)
|
|
|
|
, name(oth.name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
Symbol& operator = (const Symbol& oth)
|
|
|
|
{
|
|
|
|
new(this) Symbol(oth);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
#endif
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
void parse(Scanner&, std::ostream&);
|
|
|
|
|
|
|
|
} // end namespace re2c
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
#endif
|