example::Parser Class Reference

A Bison parser. More...

#include <parser.h>

List of all members.

Classes

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

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_ = -9
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 unsigned 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_ = 42
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


Detailed Description

A Bison parser.

Definition at line 114 of file parser.h.


Member Typedef Documentation

Type for debugging levels.

Definition at line 171 of file parser.h.

location stack type.

Definition at line 214 of file parser.h.

Symbol locations.

Definition at line 139 of file parser.h.

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

A type to store symbol numbers and -1.

Definition at line 268 of file parser.h.

Semantic value stack type.

Definition at line 212 of file parser.h.

State stack type.

Definition at line 210 of file parser.h.

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

State numbers.

Definition at line 208 of file parser.h.

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

Internal symbol numbers.

Definition at line 224 of file parser.h.

Token type.

Definition at line 154 of file parser.h.


Constructor & Destructor Documentation

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

Build a parser object.

Definition at line 188 of file parser.cc.

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

Definition at line 198 of file parser.cc.


Member Function Documentation

debug_level_type example::Parser::debug_level (  )  const

The current debugging level.

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

The current debugging 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 1210 of file parser.cc.

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

Referenced by parse().

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

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

Set the current debugging level.

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

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

Set the current debugging stream.

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::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 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.

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 234 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 333 of file parser.cc.

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

Referenced by parse().

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

Print the state stack on the debug stream.

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 lookahead token.

Definition at line 903 of file parser.cc.

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

Referenced by parse().

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_().

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

Convert a scanner token number t to a symbol number.

Definition at line 1144 of file parser.cc.

References yyundef_token_, and yyuser_token_number_max_.

Referenced by parse().


Member Data Documentation

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

Definition at line 317 of file parser.h.

Referenced by error(), and parse().

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

Definition at line 284 of file parser.h.

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

Initial value:

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

Definition at line 246 of file parser.h.

Referenced by parse(), and yysyntax_error_().

Definition at line 283 of file parser.h.

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 233 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 236 of file parser.h.

Referenced by parse().

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

Definition at line 308 of file parser.h.

Referenced by parse().

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

Definition at line 304 of file parser.h.

Referenced by parse().

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

Definition at line 311 of file parser.h.

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

Definition at line 309 of file parser.h.

Referenced by parse().

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

Definition at line 306 of file parser.h.

Referenced by parse(), and yysyntax_error_().

The location stack.

Definition at line 221 of file parser.h.

Referenced by parse(), and yypop_().

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

Definition at line 307 of file parser.h.

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

Definition at line 312 of file parser.h.

Referenced by parse(), and yysyntax_error_().

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

Initial value:

  {
        -9,     2,    -9,    -9,    -9,    -9,     0,    24,    32,    32,
      -9,    -9,    -9,    31,    -9,    -9,     8,    -7,    11,    16,
      24,    -9,    25,    -9,    -9,    32,    24,    24,    24,    24,
      24,    -9,    -9,    -9,    -9,    -9,    -9,    -9,    -9,    -9,
      -9,    -9,    -9,     8,     8
  }
For a state, the index in yytable_ of its portion.

Definition at line 227 of file parser.h.

Referenced by parse(), and yysyntax_error_().

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

Definition at line 228 of file parser.h.

Referenced by parse(), and yysyntax_error_().

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

Initial value:

  {
        -9,    -9,    -9,    -9,    -8,    -2,    12,    -9,     3,    -9,
      -9
  }

Definition at line 235 of file parser.h.

Referenced by parse().

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

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

Definition at line 272 of file parser.h.

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 252 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 254 of file parser.h.

Referenced by parse().

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

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

Definition at line 270 of file parser.h.

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

For each rule, its source line number.

Definition at line 274 of file parser.h.

The semantic value stack.

Definition at line 219 of file parser.h.

Referenced by parse(), and yypop_().

The state stack.

Definition at line 217 of file parser.h.

Referenced by parse(), and yypop_().

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,    21,
      22,    22,    22,    23,    23
  }
For a state, its accessing symbol.

Definition at line 249 of file parser.h.

Referenced by parse().

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

Initial value:

  {
        23,    24,     2,    29,    30,     3,     4,     5,     6,     7,
      22,    31,     8,     9,    32,    20,    34,    39,    10,    35,
      26,    27,    28,    37,    40,    41,    42,    33,     4,     5,
      21,     7,    36,    38,     8,     9,     4,     5,    21,     7,
      25,    43,    44
  }
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 243 of file parser.h.

Referenced by parse().

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

Definition at line 244 of file parser.h.

Referenced by parse().

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

Definition at line 310 of file parser.h.

Referenced by parse(), and yysyntax_error_().

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

For a symbol, its name in clear.

Definition at line 258 of file parser.h.

Referenced by yysyntax_error_().

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

For each scanner token number, its symbol number.

Definition at line 276 of file parser.h.

Definition at line 314 of file parser.h.

Referenced by yytranslate_().

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

Definition at line 313 of file parser.h.

Referenced by yytranslate_().


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

Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by  doxygen 1.5.9