yy::parser Class Reference

A Bison parser. More...

#include <parser.hh>

Collaboration diagram for yy::parser:
Collaboration graph
[legend]

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 (driver &theDriver_yyarg)
 Build a parser object.
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_
drivertheDriver

Static Private Attributes

static const signed char yypact_ []
 For a state, the index in yytable_ of its portion.
static const signed char yypact_ninf_ = -48
static const unsigned char yydefact_ []
 For a state, default rule to reduce. Unlessyytable_ specifies something else to do. Zero means the default is an error.
static const signed char yypgoto_ []
static const signed char yydefgoto_ []
static const unsigned char yytable_ []
 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.

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 short int 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_ = 49
static const int yynnts_ = 17
static const int yyempty_ = -2
static const int yyfinal_ = 7
static const int yyterror_ = 1
static const int yyerrcode_ = 256
static const int yyntokens_ = 14
static const unsigned int yyuser_token_number_max_ = 260
static const token_number_type yyundef_token_ = 2

Detailed Description

A Bison parser.

The parser for the input file format.

This parser reads tokens from a yy::lexer one at a time, parses them according to the grammar specified in parser.yy and passes it on to an instance of class driver. The lexer object is not directly passed to the parser, but wrapped inside driver::scan.

Definition at line 142 of file parser.hh.


Member Function Documentation

void yy::parser::error ( const location_type loc,
const std::string &  message 
) [private, virtual]

Report a syntax error.

Pass error messages on to the driver.

Parameters:
loc where the syntax error is found.
msg a description of the syntax error.
location the position in the input file where the error occurred.
message a textual description of the error.

Definition at line 1314 of file parser.cc.

References driver::error().

Referenced by parse().

int yy::parser::parse (  )  [virtual]

Parse.

Returns:
0 iff parsing succeeded.

Lookahead and lookahead in internal form.

Semantic value of the lookahead.

Location of the lookahead.

The locations where the error started and ended.

$$.

$.

Definition at line 477 of file parser.cc.

References append(), driver::checked_field(), error(), driver::file, yy::location::initialize(), driver::result(), driver::set_constraints(), driver::set_fields(), driver::set_names(), singleton(), yydefact_, yydestruct_(), yylocation_stack_, yypact_, yypop_(), yyr1_, yyr2_, yysemantic_stack_, yystate_stack_, yystos_, yysyntax_error_(), yytable_, and yytranslate_().

Referenced by driver::parse().

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

Definition at line 313 of file parser.cc.

References yy_symbol_value_print_(), and yytname_.

void yy::parser::yy_symbol_value_print_ ( int  yytype,
const semantic_type yyvaluep,
const location_type yylocationp 
) [inline, private, virtual]

Report a symbol value on the debug stream.

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

Definition at line 227 of file parser.cc.

References debug_stream().

Referenced by yy_symbol_print_().

void yy::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 325 of file parser.cc.

Referenced by parse().

std::string yy::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 995 of file parser.cc.

References yypact_, yytname_, and yytnamerr_().

Referenced by parse().


Member Data Documentation

const signed char yy::parser::yycheck_ [static, private]
Initial value:
  {
         0,    48,     3,     4,     7,     8,     1,     1,     0,    10,
      57,     6,     6,    10,    11,    12,     7,     8,     7,     8,
       7,     8,    22,     6,     9,     6,     8,     7,     6,     5,
       7,     6,     5,     7,    34,     7,     7,     5,    44,     8,
      -1,    27,    -1,    13,    -1,    -1,    -1,    -1,    -1,    16
  }

Definition at line 278 of file parser.hh.

const unsigned char yy::parser::yydefact_ [static, private]
Initial value:
  {
         4,     5,     6,     7,     0,     0,     0,     1,     0,     3,
       0,     0,    11,     0,    10,     0,     0,     8,     0,     0,
       9,    16,     0,     0,    14,     0,     0,     0,    12,     0,
       0,    28,    13,    21,     0,     0,    19,     2,    25,    26,
      27,     0,     0,     0,     0,    17,     0,    30,    28,    18,
       0,     0,    24,     0,    23,    15,    29,    28,    20,    22
  }

For a state, default rule to reduce. Unlessyytable_ specifies something else to do. Zero means the default is an error.

Definition at line 265 of file parser.hh.

Referenced by parse().

const signed char yy::parser::yydefgoto_ [static, private]
Initial value:
  {
        -1,     4,     5,    12,    11,    13,    14,    19,    23,    24,
      30,    35,    36,    53,    41,    42,    52
  }

Definition at line 268 of file parser.hh.

const signed char yy::parser::yypact_ [static, private]
Initial value:
  {
        -1,   -48,   -48,   -48,     8,    17,    15,   -48,    19,   -48,
      -1,    20,   -48,    -3,   -48,    22,    -1,   -48,     5,    23,
     -48,   -48,    -1,     9,   -48,    25,    26,     5,   -48,     6,
      18,     3,   -48,   -48,    -1,    11,   -48,   -48,   -48,   -48,
     -48,    28,    24,    29,     6,   -48,    27,    30,     3,   -48,
      31,    32,   -48,    13,   -48,   -48,   -48,     3,   -48,   -48
  }

For a state, the index in yytable_ of its portion.

Definition at line 259 of file parser.hh.

Referenced by parse(), and yysyntax_error_().

const signed char yy::parser::yypgoto_ [static, private]
Initial value:
  {
       -48,   -48,   -48,     0,   -48,   -48,    33,   -48,   -48,    14,
     -48,   -48,    -6,   -48,   -47,   -48,   -48
  }

Definition at line 267 of file parser.hh.

const unsigned char yy::parser::yyprhs_ [static, private]
Initial value:
  {
         0,     0,     3,    12,    15,    16,    18,    20,    22,    26,
      30,    32,    34,    38,    42,    44,    52,    54,    58,    62,
      64,    70,    72,    76,    78,    82,    84,    86,    88,    89,
      92
  }

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

Definition at line 304 of file parser.hh.

Referenced by yy_reduce_print_().

const unsigned char yy::parser::yyr1_ [static, private]
Initial value:
  {
         0,    14,    15,    16,    16,    17,    17,    17,    18,    19,
      19,    20,    21,    22,    22,    23,    23,    24,    25,    25,
      26,    26,    27,    27,    28,    28,    29,    29,    29,    30,
      30
  }

For a rule, its LHS.

Definition at line 284 of file parser.hh.

Referenced by parse().

const unsigned char yy::parser::yyr2_ [static, private]
Initial value:
  {
         0,     2,     8,     2,     0,     1,     1,     1,     3,     3,
       1,     1,     3,     3,     1,     7,     1,     3,     3,     1,
       5,     1,     3,     1,     3,     1,     1,     1,     0,     2,
       0
  }

For a rule, its RHS length.

Definition at line 286 of file parser.hh.

Referenced by parse(), and yy_reduce_print_().

Initial value:
  {
        15,     0,    -1,    16,     6,    18,     7,    21,     7,    24,
       8,    -1,    17,     9,    -1,    -1,     3,    -1,     4,    -1,
      10,    -1,     6,    19,     8,    -1,    19,     7,    20,    -1,
      20,    -1,    17,    -1,     6,    22,     8,    -1,    22,     7,
      23,    -1,    23,    -1,     6,    17,     7,    28,     7,     5,
       8,    -1,     1,    -1,     6,    25,     8,    -1,    25,     7,
      26,    -1,    26,    -1,     6,    17,     7,    27,     8,    -1,
       1,    -1,    27,     7,    28,    -1,    28,    -1,    29,     5,
      30,    -1,    10,    -1,    11,    -1,    12,    -1,    -1,    13,
       5,    -1,    -1
  }

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

Definition at line 302 of file parser.hh.

Referenced by yy_reduce_print_().

const unsigned short int yy::parser::yyrline_ [static, private]
Initial value:
  {
         0,   192,   192,   195,   196,   199,   200,   201,   206,   209,
     210,   213,   218,   221,   222,   225,   228,   233,   236,   237,
     240,   241,   246,   247,   250,   251,   254,   255,   256,   259,
     260
  }

For each rule, its source line number.

Definition at line 306 of file parser.hh.

Referenced by yy_reduce_print_().

const unsigned char yy::parser::yystos_ [static, private]
Initial value:
  {
         0,     3,     4,    10,    15,    16,    17,     0,     6,     9,
       6,    18,    17,    19,    20,     7,     7,     8,     6,    21,
      20,     1,     6,    22,    23,     7,    17,     7,     8,     6,
      24,     7,    23,     1,     6,    25,    26,     8,    10,    11,
      12,    28,    29,    17,     7,     8,     7,     5,     7,    26,
       5,    13,    30,    27,    28,     8,     5,     7,     8,    28
  }

For a state, its accessing symbol.

Definition at line 281 of file parser.hh.

Referenced by parse().

const unsigned char yy::parser::yytable_ [static, private]
Initial value:
  {
         6,    54,     1,     2,    16,    17,    21,    33,     7,     3,
      59,    22,    34,    38,    39,    40,    27,    28,    44,    45,
      57,    58,    26,     8,     9,    10,    37,    15,    18,    47,
      25,    29,    50,    31,    43,    46,    48,    56,    49,    55,
       0,    32,     0,    51,     0,     0,     0,     0,     0,    20
  }

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 275 of file parser.hh.

Referenced by parse().

const char *const yy::parser::yytname_ [static, private]
Initial value:
  {
    "\"end of file\"", "error", "$undefined", "\"word\"",
  "\"quoted string\"", "\"integer\"", "'{'", "','", "'}'", "'='", "'*'",
  "'+'", "'-'", "'/'", "$accept", "instance", "name", "string", "qns",
  "qnl", "qn", "css", "csl", "cs", "vcs", "vcl", "vc", "rationals",
  "rational", "sign", "denom", 0
  }

For a symbol, its name in clear.

Definition at line 290 of file parser.hh.

Referenced by yy_symbol_print_(), and yysyntax_error_().

const unsigned short int yy::parser::yytoken_number_ [static, private]
Initial value:
  {
         0,   256,   257,   258,   259,   260,   123,    44,   125,    61,
      42,    43,    45,    47
  }

For each scanner token number, its symbol number.

Definition at line 308 of file parser.hh.


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

Generated on Fri Aug 21 08:15:08 2009 for mqn2mps by  doxygen 1.6.0