example::Parser Class Reference

A Bison parser. More...

#include <parser.h>

List of all members.

Public Types

typedef location location_type
 Symbol locations.
typedef token::yytokentype token_type
 Token type.
typedef int debug_level_type
 Type for debugging levels.

Public Member Functions

 Parser (class Driver &driver_yyarg)
 Build a parser object.
virtual ~Parser ()
virtual int parse ()
 Parse.
std::ostream & debug_stream () const
 The current debugging stream.
void set_debug_stream (std::ostream &)
 Set the current debugging stream.
debug_level_type debug_level () const
 The current debugging level.
void set_debug_level (debug_level_type l)
 Set the current debugging level.

Private Types

typedef int state_type
 State numbers.
typedef stack< state_typestate_stack_type
 State stack type.
typedef stack< semantic_typesemantic_stack_type
 Semantic value stack type.
typedef stack< location_typelocation_stack_type
 location stack type.
typedef unsigned char token_number_type
 Internal symbol numbers.
typedef signed char rhs_number_type
 A type to store symbol numbers and -1.

Private Member Functions

virtual void error (const location_type &loc, const std::string &msg)
 Report a syntax error.
virtual std::string yysyntax_error_ (int yystate, int tok)
 Generate an error message.
virtual void yy_symbol_value_print_ (int yytype, const semantic_type *yyvaluep, const location_type *yylocationp)
 Report a symbol value on the debug stream.
virtual void yy_symbol_print_ (int yytype, const semantic_type *yyvaluep, const location_type *yylocationp)
 Report a symbol on the debug stream.
virtual std::string yytnamerr_ (const char *n)
 Convert the symbol name n to a form suitable for a diagnostic.
virtual void yy_reduce_print_ (int r)
 Report on the debug stream that the rule r is going to be reduced.
virtual void yystack_print_ ()
 Print the state stack on the debug stream.
token_number_type yytranslate_ (int t)
 Convert a scanner token number t to a symbol number.
void yydestruct_ (const char *yymsg, int yytype, semantic_type *yyvaluep, location_type *yylocationp)
 Reclaim the memory associated to a symbol.
void yypop_ (unsigned int n=1)
 Pop n symbols the three stacks.

Private Attributes

state_stack_type yystate_stack_
 The state stack.
semantic_stack_type yysemantic_stack_
 The semantic value stack.
location_stack_type yylocation_stack_
 The location stack.
int yydebug_
std::ostream * yycdebug_
class Driverdriver

Static Private Attributes

static const signed char yypact_ []
 For a state, the index in yytable_ of its portion.
static const signed char yypact_ninf_ = -15
static const unsigned char yydefact_ []
 For a state, default rule to reduce.
static const signed char yypgoto_ []
static const signed char yydefgoto_ []
static const unsigned char yytable_ []
 What to do in a state.
static const signed char yytable_ninf_ = -1
static const signed char yycheck_ []
static const unsigned char yystos_ []
 For a state, its accessing symbol.
static const unsigned char yyr1_ []
 For a rule, its LHS.
static const unsigned char yyr2_ []
 For a rule, its RHS length.
static const char *const yytname_ []
 For a symbol, its name in clear.
static const rhs_number_type yyrhs_ []
 A `-1'-separated list of the rules' RHS.
static const unsigned char yyprhs_ []
 For each rule, the index of the first RHS symbol in yyrhs_.
static const unsigned char yyrline_ []
 For each rule, its source line number.
static const unsigned short int yytoken_number_ []
 For each scanner token number, its symbol number.
static const int yyeof_ = 0
static const int yylast_ = 44
static const int yynnts_ = 11
static const int yyempty_ = -2
static const int yyfinal_ = 2
static const int yyterror_ = 1
static const int yyerrcode_ = 256
static const int yyntokens_ = 17
static const unsigned int yyuser_token_number_max_ = 261
static const token_number_type yyundef_token_ = 2

Classes

union  semantic_type
 Symbol semantic values. More...
struct  token
 Tokens. More...


Detailed Description

A Bison parser.

Definition at line 108 of file parser.h.


Member Typedef Documentation

Symbol locations.

Definition at line 128 of file parser.h.

Token type.

Definition at line 143 of file parser.h.

Type for debugging levels.

Definition at line 159 of file parser.h.

typedef int example::Parser::state_type [private]

State numbers.

Definition at line 195 of file parser.h.

State stack type.

Definition at line 197 of file parser.h.

Semantic value stack type.

Definition at line 199 of file parser.h.

location stack type.

Definition at line 201 of file parser.h.

typedef unsigned char example::Parser::token_number_type [private]

Internal symbol numbers.

Definition at line 211 of file parser.h.

typedef signed char example::Parser::rhs_number_type [private]

A type to store symbol numbers and -1.

Definition at line 255 of file parser.h.


Constructor & Destructor Documentation

example::Parser::Parser ( class Driver driver_yyarg  ) 

Build a parser object.

Definition at line 159 of file parser.cc.

example::Parser::~Parser (  )  [virtual]

Definition at line 166 of file parser.cc.


Member Function Documentation

int example::Parser::parse (  )  [virtual]

std::ostream & example::Parser::debug_stream (  )  const

The current debugging stream.

Definition at line 273 of file parser.cc.

References yycdebug_.

void example::Parser::set_debug_stream ( std::ostream &  o  ) 

Set the current debugging stream.

Definition at line 279 of file parser.cc.

References yycdebug_.

Parser::debug_level_type example::Parser::debug_level (  )  const

The current debugging level.

Definition at line 286 of file parser.cc.

References yydebug_.

void example::Parser::set_debug_level ( debug_level_type  l  ) 

Set the current debugging level.

Definition at line 292 of file parser.cc.

References yydebug_.

Referenced by example::Driver::parse_stream().

void example::Parser::error ( const location_type loc,
const std::string &  msg 
) [private, virtual]

Report a syntax error.

Parameters:
loc where the syntax error is found.
msg a description of the syntax error.

Definition at line 1083 of file parser.cc.

References driver, and example::Driver::error().

Referenced by parse().

std::string example::Parser::yysyntax_error_ ( int  yystate,
int  tok 
) [private, virtual]

Generate an error message.

Parameters:
state the state where the error occurred.
tok the look-ahead token.

Definition at line 785 of file parser.cc.

References YY_, yycheck_, yylast_, yyntokens_, yypact_, yypact_ninf_, yyterror_, yytname_, yytnamerr_(), and YYUSE.

Referenced by parse().

virtual void example::Parser::yy_symbol_value_print_ ( int  yytype,
const semantic_type yyvaluep,
const location_type yylocationp 
) [private, virtual]

Report a symbol value on the debug stream.

Parameters:
yytype The token type.
yyvaluep Its semantic value.
yylocationp Its location.

virtual void example::Parser::yy_symbol_print_ ( int  yytype,
const semantic_type yyvaluep,
const location_type yylocationp 
) [private, virtual]

Report a symbol on the debug stream.

Parameters:
yytype The token type.
yyvaluep Its semantic value.
yylocationp Its location.

virtual std::string example::Parser::yytnamerr_ ( const char *  n  )  [private, virtual]

Convert the symbol name n to a form suitable for a diagnostic.

Referenced by yysyntax_error_().

virtual void example::Parser::yy_reduce_print_ ( int  r  )  [private, virtual]

Report on the debug stream that the rule r is going to be reduced.

virtual void example::Parser::yystack_print_ (  )  [private, virtual]

Print the state stack on the debug stream.

Parser::token_number_type example::Parser::yytranslate_ ( int  t  )  [private]

Convert a scanner token number t to a symbol number.

Definition at line 1026 of file parser.cc.

References yyundef_token_, and yyuser_token_number_max_.

Referenced by parse().

void example::Parser::yydestruct_ ( const char *  yymsg,
int  yytype,
semantic_type yyvaluep,
location_type yylocationp 
) [inline, private]

Reclaim the memory associated to a symbol.

Parameters:
yymsg Why this token is reclaimed.
yytype The symbol type.
yyvaluep Its semantic value.
yylocationp Its location.

Definition at line 202 of file parser.cc.

References example::Parser::semantic_type::calcnode, example::Parser::semantic_type::stringVal, YY_SYMBOL_PRINT, and YYUSE.

Referenced by parse().

void example::Parser::yypop_ ( unsigned int  n = 1  )  [inline, private]

Pop n symbols the three stacks.

Definition at line 265 of file parser.cc.

References example::stack< T, S >::pop(), yylocation_stack_, yysemantic_stack_, and yystate_stack_.

Referenced by parse().


Member Data Documentation

The state stack.

Definition at line 204 of file parser.h.

Referenced by parse(), and yypop_().

The semantic value stack.

Definition at line 206 of file parser.h.

Referenced by parse(), and yypop_().

The location stack.

Definition at line 208 of file parser.h.

Referenced by parse(), and yypop_().

const signed char example::Parser::yypact_ [static, private]

Initial value:

  {
       -15,     0,   -15,   -15,   -15,   -15,   -14,    16,    27,    27,
     -15,   -15,   -15,   -15,    -1,   -15,    23,     8,     9,    14,
      16,   -15,     5,    -1,    -1,    27,    16,    16,    16,    16,
      16,   -15,   -15,   -15,   -15,   -15,   -15,   -15,   -15,   -15,
     -15,   -15,   -15,    23,    23
  }
For a state, the index in yytable_ of its portion.

Definition at line 214 of file parser.h.

Referenced by parse(), and yysyntax_error_().

const signed char example::Parser::yypact_ninf_ = -15 [static, private]

Definition at line 215 of file parser.h.

Referenced by parse(), and yysyntax_error_().

const unsigned char example::Parser::yydefact_ [static, private]

Initial value:

  {
        22,     0,     1,    24,     2,     3,     4,     0,     0,     0,
      23,     5,     6,     8,    10,    13,    17,    20,     0,     0,
       0,     4,     0,    11,    12,     0,     0,     0,     0,     0,
       0,    30,    29,    28,    27,    26,    25,    21,     7,     9,
      14,    15,    16,    18,    19
  }
For a state, default rule to reduce.

Unlessyytable_ specifies something else to do. Zero means the default is an error.

Definition at line 220 of file parser.h.

Referenced by parse().

const signed char example::Parser::yypgoto_ [static, private]

Initial value:

  {
       -15,   -15,   -15,    19,    20,    12,    13,   -15,    -5,   -15,
     -15
  }

Definition at line 222 of file parser.h.

Referenced by parse().

const signed char example::Parser::yydefgoto_ [static, private]

Initial value:

  {
        -1,    11,    12,    13,    14,    15,    16,    17,    18,    19,
       1
  }

Definition at line 223 of file parser.h.

Referenced by parse().

const unsigned char example::Parser::yytable_ [static, private]

Initial value:

  {
         2,    20,    22,     3,     4,     5,     6,     7,    25,    31,
       8,     9,    32,    38,    34,    37,    10,    35,    29,    30,
       4,     5,    21,     7,     0,    33,     8,     9,    23,    24,
      36,     4,     5,    21,     7,    26,    27,    28,    40,    41,
      42,     0,    43,    44,    39
  }
What to do in a state.

yytable_[yypact_[s]]: what to do in state s.

  • if positive, shift that token.
  • if negative, reduce the rule which number is the opposite.
  • if zero, do what YYDEFACT says.

Definition at line 230 of file parser.h.

Referenced by parse().

const signed char example::Parser::yytable_ninf_ = -1 [static, private]

Definition at line 231 of file parser.h.

Referenced by parse().

const signed char example::Parser::yycheck_ [static, private]

Initial value:

  {
         0,    15,     7,     3,     4,     5,     6,     7,     9,     0,
      10,    11,     3,     8,     0,    20,    16,     3,    10,    11,
       4,     5,     6,     7,    -1,    16,    10,    11,     8,     9,
      16,     4,     5,     6,     7,    12,    13,    14,    26,    27,
      28,    -1,    29,    30,    25
  }

Definition at line 233 of file parser.h.

Referenced by parse(), and yysyntax_error_().

const unsigned char example::Parser::yystos_ [static, private]

Initial value:

  {
         0,    27,     0,     3,     4,     5,     6,     7,    10,    11,
      16,    18,    19,    20,    21,    22,    23,    24,    25,    26,
      15,     6,    25,    21,    21,     9,    12,    13,    14,    10,
      11,     0,     3,    16,     0,     3,    16,    25,     8,    20,
      22,    22,    22,    23,    23
  }
For a state, its accessing symbol.

Definition at line 236 of file parser.h.

Referenced by parse().

const unsigned char example::Parser::yyr1_ [static, private]

Initial value:

  {
         0,    17,    18,    18,    19,    20,    20,    20,    21,    21,
      22,    22,    22,    23,    23,    23,    23,    24,    24,    24,
      25,    26,    27,    27,    27,    27,    27,    27,    27,    27,
      27
  }
For a rule, its LHS.

Definition at line 239 of file parser.h.

Referenced by parse().

const unsigned char example::Parser::yyr2_ [static, private]

Initial value:

  {
         0,     2,     1,     1,     1,     1,     1,     3,     1,     3,
       1,     2,     2,     1,     3,     3,     3,     1,     3,     3,
       1,     3,     0,     2,     2,     3,     3,     3,     3,     3,
       3
  }
For a rule, its RHS length.

Definition at line 241 of file parser.h.

Referenced by parse().

const char* const example::Parser::yytname_[] [static, private]

For a symbol, its name in clear.

Definition at line 245 of file parser.h.

Referenced by yysyntax_error_().

const rhs_number_type example::Parser::yyrhs_[] [static, private]

A `-1'-separated list of the rules' RHS.

Definition at line 257 of file parser.h.

const unsigned char example::Parser::yyprhs_[] [static, private]

For each rule, the index of the first RHS symbol in yyrhs_.

Definition at line 259 of file parser.h.

const unsigned char example::Parser::yyrline_[] [static, private]

For each rule, its source line number.

Definition at line 261 of file parser.h.

const unsigned short int example::Parser::yytoken_number_[] [static, private]

For each scanner token number, its symbol number.

Definition at line 263 of file parser.h.

const int example::Parser::yyeof_ = 0 [static, private]

Definition at line 287 of file parser.h.

Referenced by parse().

const int example::Parser::yylast_ = 44 [static, private]

Definition at line 289 of file parser.h.

Referenced by parse(), and yysyntax_error_().

const int example::Parser::yynnts_ = 11 [static, private]

Definition at line 290 of file parser.h.

const int example::Parser::yyempty_ = -2 [static, private]

Definition at line 291 of file parser.h.

Referenced by parse().

const int example::Parser::yyfinal_ = 2 [static, private]

Definition at line 292 of file parser.h.

Referenced by parse().

const int example::Parser::yyterror_ = 1 [static, private]

Definition at line 293 of file parser.h.

Referenced by parse(), and yysyntax_error_().

const int example::Parser::yyerrcode_ = 256 [static, private]

Definition at line 294 of file parser.h.

const int example::Parser::yyntokens_ = 17 [static, private]

Definition at line 295 of file parser.h.

Referenced by parse(), and yysyntax_error_().

const unsigned int example::Parser::yyuser_token_number_max_ = 261 [static, private]

Definition at line 296 of file parser.h.

Referenced by yytranslate_().

Definition at line 297 of file parser.h.

Referenced by yytranslate_().

Definition at line 300 of file parser.h.

Referenced by debug_level(), and set_debug_level().

std::ostream* example::Parser::yycdebug_ [private]

Definition at line 301 of file parser.h.

Referenced by debug_stream(), and set_debug_stream().

class Driver& example::Parser::driver [private]

Definition at line 305 of file parser.h.

Referenced by error(), and parse().


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

Generated on Thu Oct 23 11:13:54 2008 for Flex Bison C++ Example by  doxygen 1.5.6