LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
parse::Tweast Class Reference

TWEAST stands for ``Text With Embedded Abstract Syntax Trees''. More...

#include <tweast.hh>

Inheritance diagram for parse::Tweast:
Collaboration diagram for parse::Tweast:

Public Member Functions

 Tweast ()
 Tweast (const std::string &str)
virtual ~Tweast ()
template<typename T >
Tweastoperator<< (const T &t)
 Stream manipulator.
template<typename T >
T * take (unsigned s)
 Metavariables manipulator.
void flatten ()
std::string input_get () const
 Get the current input string.
std::ostream & dump (std::ostream &ostr) const
 Print the table.
std::string show (unsigned key)
std::string show (unsigned key)
std::string show (unsigned key)
std::string show (unsigned key)
std::string show (unsigned key)

Protected Types

typedef misc::map< unsigned,
ast::Exp * > 
map_type
 Metavariables.
typedef misc::map< unsigned,
ast::Var * > 
map_type
 Metavariables.
typedef misc::map< unsigned,
ast::NameTy * > 
map_type
 Metavariables.
typedef misc::map< unsigned,
ast::DecsList * > 
map_type
 Metavariables.
typedef misc::map< unsigned,
parse::Tweast * > 
map_type
 Metavariables.

Protected Member Functions

template<typename T >
T & append_ (unsigned &, T &data) const
 Fake append (default case, i.e. when data is not a metavariable).
template<typename T >
void move_metavars_ (Tweast &tweast, std::string &input)
virtual std::string append_ (unsigned &key, ast::Exp *data)
 Append a metavariable to the map.
virtual ast::Exptake_ (unsigned key)
 Extract a metavariable.
virtual std::string append_ (unsigned &key, ast::Var *data)
 Append a metavariable to the map.
virtual ast::Var * take_ (unsigned key)
 Extract a metavariable.
virtual std::string append_ (unsigned &key, ast::NameTy *data)
 Append a metavariable to the map.
virtual ast::NameTytake_ (unsigned key)
 Extract a metavariable.
virtual std::string append_ (unsigned &key, ast::DecsList *data)
 Append a metavariable to the map.
virtual ast::DecsListtake_ (unsigned key)
 Extract a metavariable.
virtual std::string append_ (unsigned &key, parse::Tweast *data)
 Append a metavariable to the map.
virtual parse::Tweasttake_ (unsigned key)
 Extract a metavariable.

Protected Attributes

std::stringstream input_
 The string to parse.
const std::string name_
 Name of the kind of variable.
map_type map_
const std::string name_
 Name of the kind of variable.
map_type map_
const std::string name_
 Name of the kind of variable.
map_type map_
const std::string name_
 Name of the kind of variable.
map_type map_
const std::string name_
 Name of the kind of variable.
map_type map_

Static Protected Attributes

static unsigned count_ = 0
 The next identifier suffix to create.

Detailed Description

TWEAST stands for ``Text With Embedded Abstract Syntax Trees''.

Aggregate string to parse and tables of metavariables.

Member Typedef Documentation

typedef misc::map<unsigned, ast::Exp *> parse::MetavarMap< ast::Exp >::map_type
protectedinherited

Metavariables.

typedef misc::map<unsigned, parse::Tweast *> parse::MetavarMap< parse::Tweast >::map_type
protectedinherited

Metavariables.

typedef misc::map<unsigned, ast::DecsList *> parse::MetavarMap< ast::DecsList >::map_type
protectedinherited

Metavariables.

typedef misc::map<unsigned, ast::NameTy *> parse::MetavarMap< ast::NameTy >::map_type
protectedinherited

Metavariables.

typedef misc::map<unsigned, ast::Var *> parse::MetavarMap< ast::Var >::map_type
protectedinherited

Metavariables.

Constructor & Destructor Documentation

parse::Tweast::Tweast ( )
parse::Tweast::Tweast ( const std::string &  str)
parse::Tweast::~Tweast ( )
virtual

Member Function Documentation

virtual std::string parse::MetavarMap< ast::Exp >::append_ ( unsigned &  key,
ast::Exp data 
)
protectedvirtualinherited

Append a metavariable to the map.

virtual std::string parse::MetavarMap< ast::DecsList >::append_ ( unsigned &  key,
ast::DecsList data 
)
protectedvirtualinherited

Append a metavariable to the map.

virtual std::string parse::MetavarMap< parse::Tweast >::append_ ( unsigned &  key,
parse::Tweast data 
)
protectedvirtualinherited

Append a metavariable to the map.

virtual std::string parse::MetavarMap< ast::Var >::append_ ( unsigned &  key,
ast::Var *  data 
)
protectedvirtualinherited

Append a metavariable to the map.

virtual std::string parse::MetavarMap< ast::NameTy >::append_ ( unsigned &  key,
ast::NameTy data 
)
protectedvirtualinherited

Append a metavariable to the map.

template<typename T >
T & parse::Tweast::append_ ( unsigned &  ,
T &  data 
) const
protected

Fake append (default case, i.e. when data is not a metavariable).

Referenced by operator<<().

std::ostream & parse::Tweast::dump ( std::ostream &  ostr) const

Print the table.

References misc::decendl(), misc::incendl(), and input_.

Referenced by parse::operator<<().

void parse::Tweast::flatten ( )

Move the contents of all aggregated Tweast metavariables into the current Tweast.

References input_, input_get(), and parse::MetavarMap< ast::Exp >::show().

Referenced by parse::TigerParser::parse_input().

std::string parse::Tweast::input_get ( ) const

Get the current input string.

References input_.

Referenced by flatten().

template<typename T >
void parse::Tweast::move_metavars_ ( Tweast tweast,
std::string &  input 
)
protected
template<typename T >
Tweast & parse::Tweast::operator<< ( const T &  t)

Stream manipulator.

Append Tiger expressions to the string to parse.

References append_(), count_, and input_.

std::string parse::MetavarMap< ast::DecsList >::show ( unsigned  key)
inherited

Generate a (concrete syntax) Tiger statement for metavariable number key (of kind Data).

std::string parse::MetavarMap< ast::Var >::show ( unsigned  key)
inherited

Generate a (concrete syntax) Tiger statement for metavariable number key (of kind Data).

std::string parse::MetavarMap< ast::Exp >::show ( unsigned  key)
inherited

Generate a (concrete syntax) Tiger statement for metavariable number key (of kind Data).

Referenced by flatten(), and move_metavars_().

std::string parse::MetavarMap< parse::Tweast >::show ( unsigned  key)
inherited

Generate a (concrete syntax) Tiger statement for metavariable number key (of kind Data).

std::string parse::MetavarMap< ast::NameTy >::show ( unsigned  key)
inherited

Generate a (concrete syntax) Tiger statement for metavariable number key (of kind Data).

template<typename T >
T * parse::Tweast::take ( unsigned  s)

Metavariables manipulator.

References parse::MetavarMap< ast::Exp >::take_().

virtual parse::Tweast * parse::MetavarMap< parse::Tweast >::take_ ( unsigned  key)
protectedvirtualinherited

Extract a metavariable.

virtual ast::NameTy * parse::MetavarMap< ast::NameTy >::take_ ( unsigned  key)
protectedvirtualinherited

Extract a metavariable.

virtual ast::Exp * parse::MetavarMap< ast::Exp >::take_ ( unsigned  key)
protectedvirtualinherited

Extract a metavariable.

Referenced by take().

virtual ast::DecsList * parse::MetavarMap< ast::DecsList >::take_ ( unsigned  key)
protectedvirtualinherited

Extract a metavariable.

virtual ast::Var * parse::MetavarMap< ast::Var >::take_ ( unsigned  key)
protectedvirtualinherited

Extract a metavariable.

Member Data Documentation

unsigned parse::Tweast::count_ = 0
staticprotected

The next identifier suffix to create.

Referenced by move_metavars_(), and operator<<().

std::stringstream parse::Tweast::input_
protected

The string to parse.

Referenced by dump(), flatten(), input_get(), and operator<<().

map_type parse::MetavarMap< ast::Exp >::map_
protectedinherited
map_type parse::MetavarMap< ast::NameTy >::map_
protectedinherited
map_type parse::MetavarMap< ast::DecsList >::map_
protectedinherited
map_type parse::MetavarMap< ast::Var >::map_
protectedinherited
map_type parse::MetavarMap< parse::Tweast >::map_
protectedinherited
const std::string parse::MetavarMap< ast::Exp >::name_
protectedinherited

Name of the kind of variable.

const std::string parse::MetavarMap< ast::Var >::name_
protectedinherited

Name of the kind of variable.

const std::string parse::MetavarMap< parse::Tweast >::name_
protectedinherited

Name of the kind of variable.

const std::string parse::MetavarMap< ast::NameTy >::name_
protectedinherited

Name of the kind of variable.

const std::string parse::MetavarMap< ast::DecsList >::name_
protectedinherited

Name of the kind of variable.


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