lxr Class Reference
[Lexical analysis]

#include <lxr.hh>

List of all members.

Public Types

enum  select_type { kChar, kGroup, kDefault, kEOF }
enum  flag_bits { kUnget, kNoSave, kReturn }
typedef int state_type
typedef char char_type
typedef int token_type
typedef std::vector< transitiontrans_list

Public Member Functions

 lxr (int N)
void check (bool warn) const
void dump (void) const
const transitionfind (int state, char c) const
token_type token (std::istream &in, std::string &tkn) const
int push_state (void)
void addTransition (int state, select_type sel, char_type sel_id, int flags, int next)
void setState0 (int state)
void setTable (const Translate< char > &table)

Classes

class  transition


Detailed Description

This class takes in a stream of characters and uses them to build an output string. Each character read in is optionally stored into the output string and is used to calculate a new state. When the end of a token is detected, the analysis method (token()) returns the token string and ID as specified by the state tables. Lexographic analysis is based on a state table and a character translation table provided by the user. brief Table driven state machine lexographic analysis.
Author:
J. Zweizig
Version:
1.1; Last modified March 3, 2008

Member Typedef Documentation

typedef int lxr::state_type

State data type

typedef char lxr::char_type

Character data type

typedef int lxr::token_type

Token data type

typedef std::vector<transition> lxr::trans_list

Define transition list data type.


Member Enumeration Documentation

enum lxr::select_type

Enumerate selection type

enum lxr::flag_bits

Enumerate flag bits.


Constructor & Destructor Documentation

lxr::lxr ( int  N  ) 

Construct a lxr object. Allocate tables for the specified number of states.


Member Function Documentation

void lxr::check ( bool  warn  )  const

Check the state table for undefined states and for ambiguously defined transitions. If an undefined state or ambiguous transition is found, it is reported and an invlid state table exception is thrown. If the warn argument is true, check will also report missing EOF and Default values.

void lxr::dump ( void   )  const

Dump out the state transition table.

const transition& lxr::find ( int  state,
char  c 
) const

Find the state transition entry

token_type lxr::token ( std::istream &  in,
std::string &  tkn 
) const

Get the next token. The token type is return as the function value, and the token string is returned to the second argument value.

int lxr::push_state ( void   ) 

Allocate a new state. No transition entries are added.

void lxr::addTransition ( int  state,
select_type  sel,
char_type  sel_id,
int  flags,
int  next 
)

Add a transition entry to the table for the specified state.

void lxr::setState0 ( int  state  ) 

Set the initial state number. By default, state 0 is the initial state.

void lxr::setTable ( const Translate< char > &  table  ) 

Set a translation table that defines the group ID for each character.


The documentation for this class was generated from the following file:
Generated on Sun Mar 8 19:21:11 2009 for dmt by  doxygen 1.5.4