Yacc
YACC TOOL
 
Yacc & Lex
Документация
Программы
Литератуа
Ссылки
Примеры
 
Solotony
Автор
Читальня
Хостинг
 


TopListValid HTML 4.01!

ABRAXAS SOFTWARE - YACC TOOL


 Welcome to use ytool TOOL
 This file describes how to use YACC TOOL briefly. This tool is 
 writen in MS C,if you want to use Turbo C,you can simply replace
 "#include " with "#include ",then compile with
 TURBO C.The project file for TURBO C is as next:
    ytool.c
    token.c
    param.h

YACC TOOL offers you next functions:
     a. Create GRAMMAR FOREST from ytool source file
     b. Create GRAMMAR FOREST with rule & line number (1)
     c. Create GRAMMAR FOREST with rule & line number (2)
     d. Create GRAMMAR FOREST with rule & line number (3)
     e. Cross Reference Table of the rule in the rule appearing order
     f. Cross Reference Table of the rule in the order of alpha
     g. Cross Reference Table of the rule in nonterminal appearing order
     h. Grammar Description File with line number
The results of these functions just like next:

a. Create GRAMMAR FOREST from ytool source file
Command line: ytool cpp.y a >temp
The content of temp is:

--------------------------------------------------------------------------------
                             Grammar Forest
--------------------------------------------------------------------------------
program         : .program
                | .program extdefs
;
.program        :
;
extdefs         : extdef
                | extdefs extdef
;
extdef          : fndef
                | datadef
                | overloaddef
                | ASM '(' string ')' ';'
                | extern_lang_string '{' extdefs '}'
                | extern_lang_string '{' '}'
                | extern_lang_string fndef
                | extern_lang_string datadef
;
extern_lang_string: EXTERN_LANG_STRING
;
overloaddef     : OVERLOAD ov_identifiers ';'
;

 .
 .
 .


b. Create GRAMMAR FOREST with rule & line number (1)
Command line: ytool cpp.y b >temp
The content of temp is:
--------------------------------------------------------------------------------
              Grammar Forest With Rule Number & Line Number (FORM 1)
--------------------------------------------------------------------------------
.................................................
.+-----The rule number                          . <== This comment is
.|                                              .     added by W.H.Wang
.|                                              .
.|    +-- The line number of this rule in GDF's .
.|    |                                         .
.|    |                                         .
.V    V                                         .
.................................................
[1  ,223 ]
program         : .program
                | .program extdefs
;
[3  ,228 ]
.program        :
;   
[4  ,238 ]
extdefs         : extdef
                | extdefs extdef
;
[6  ,243 ]
extdef          : fndef
                | datadef
                | overloaddef
                | ASM '(' string ')' ';'
                | extern_lang_string '{' extdefs '}'
                | extern_lang_string '{' '}'
                | extern_lang_string fndef
                | extern_lang_string datadef
;
[14 ,266 ]
extern_lang_string: EXTERN_LANG_STRING
;
[15 ,271 ]
overloaddef     : OVERLOAD ov_identifiers ';'
;
   .
   .
   .

c. Create GRAMMAR FOREST with rule & line number (2)
Command line: ytool cpp.y c >temp
The content of temp is:

--------------------------------------------------------------------------------
              Grammar Forest With Rule Number & Line Number (FORM 2)
--------------------------------------------------------------------------------
.................................................
.                                               .
.+-----The rule number                          .
.|                                              .
.|                                              .
.|    +-- The line number of this rule in GDF's .
.|    |                                         .
.|    |                                         .
.V    V                                         .
.................................................
[1  ,223 ]
program         : .program
[2  ]           | .program extdefs
.................................................
.^                                              .
.|                                              .
.|                                              .
.+----The rule number                           .
.................................................
;

[3  ,228 ]
.program        :
;

[4  ,238 ]
extdefs         : extdef
[5  ]           | extdefs extdef
;

[6  ,243 ]
extdef          : fndef
[7  ]           | datadef
[8  ]           | overloaddef
[9  ]           | ASM '(' string ')' ';'
[10 ]           | extern_lang_string '{' extdefs '}'
[11 ]           | extern_lang_string '{' '}'
[12 ]           | extern_lang_string fndef
[13 ]           | extern_lang_string datadef
;

[14 ,266 ]
extern_lang_string: EXTERN_LANG_STRING
;

[15 ,271 ]
overloaddef     : OVERLOAD ov_identifiers ';'
;

[16 ,274 ]
ov_identifiers  : IDENTIFIER
[17 ]           | ov_identifiers ',' IDENTIFIER
;
    .
    .
    .

d. Create GRAMMAR FOREST with rule & line number (3)
Command line: ytool cpp.y d >temp
The content of temp is:

--------------------------------------------------------------------------------
              Grammar Forest With Rule Number & Line Number (FORM 3)
--------------------------------------------------------------------------------

.................................................
.+-----The rule number                          .
.|                                              .
.|                                              .
.|    +-- The line number of this rule in GDF's .
.|    |                                         .
.|    |                                         .
.V    V                                         .
.................................................
[1  ,223 ]
program         : .program[*3]
[2  ]           | .program[*3] extdefs[*4]
.................................................
.^                         ^           ^        .
.|                         |           |        .
.|                         |           |        .
.+---- The rule number  ---+-----------+        .
.................................................
;

[3  ,228 ]
.program        :
;

[4  ,238 ]
extdefs         : extdef[*6]
[5  ]           | extdefs[*4] extdef[*6]
;

[6  ,243 ]
extdef          : fndef[*29]
[7  ]           | datadef[*19]
[8  ]           | overloaddef[*15]
[9  ]           | ASM '(' string[*179] ')' ';'
[10 ]           | extern_lang_string[*14] '{' extdefs[*4] '}'
[11 ]           | extern_lang_string[*14] '{' '}'
[12 ]           | extern_lang_string[*14] fndef[*29]
[13 ]           | extern_lang_string[*14] datadef[*19]
;

[14 ,266 ]
extern_lang_string: EXTERN_LANG_STRING
;

[15 ,271 ]
overloaddef     : OVERLOAD ov_identifiers[*16] ';'
;

[16 ,274 ]
ov_identifiers  : IDENTIFIER
[17 ]           | ov_identifiers[*16] ',' IDENTIFIER
;
       .
       .
       .

e. Cross Reference Table of the rule in the rule appearing order
Command line: ytool cpp.y e >temp
The content of temp is:

   ===========  CROSS REFERENCE TABLE (1) ===========
         RUEL_No.| LINE_No.| SYMBOL
   --------------------------------------------------
         1       | 223     | program
         3       | 228     | .program
         4       | 238     | extdefs
         6       | 243     | extdef
         29      | 323     | fndef
         19      | 284     | datadef
         15      | 271     | overloaddef
         179     | 1183    | string
         14      | 266     | extern_lang_string
         16      | 274     | ov_identifiers
         18      | 280     | dummy_decl
         225     | 1378    | notype_initdecls
         200     | 1296    | declmods
         190     | 1260    | declarator
         192     | 1269    | typed_declspecs
         223     | 1373    | initdecls
         37      | 362     | fn.def1
         54      | 498     | base_init
         418     | 2112    | compstmt_or_error
         51      | 457     | return_init
         181     | 1189    | nodecls
         367     | 1962    | notype_declarator
         502     | 2834    | maybe_raises
         481     | 2728    | parmlist
         337     | 1877    | type_quals
         43      | 389     | fn.def2
         50      | 449     | return_id
         500     | 2827    | opt.init
         87      | 683     | nonnull_exprlist
         55      | 507     | .set_base_init
         56      | 536     | member_init_list
         60      | 547     | member_init
         66      | 618     | identifier
         390     | 2028    | scoped_identifier
         68      | 623     | identifier_or_opname
         513     | 2866    | operator_name
         77      | 644     | wrapper
         80      | 652     | unop
         85      | 664     | expr
         110     | 834     | expr_no_commas
         90      | 692     | unary_expr
         134     | 891     | primary
         107     | 812     | cast_expr
         331     | 1857    | typename
         175     | 1166    | .scope
         171     | 1156    | new
         218     | 1356    | x_typespec
         244     | 1479    | init
         177     | 1173    | delete
         249     | 1498    | initlist
         259     | 1562    | maybecomma
         471     | 2690    | xexpr
         182     | 1198    | object
         161     | 1120    | primary_no_id
         420     | 2118    | compstmt
         184     | 1223    | decl
         340     | 1894    | after_type_declarator
         210     | 1336    | typespec
         196     | 1280    | reserved_declspecs
         215     | 1351    | typespecqual_reserved
         204     | 1314    | typed_typespecs
         335     | 1870    | nonempty_type_quals
         208     | 1325    | reserved_typespecquals
         251     | 1505    | structsp
         229     | 1394    | initdcl0
         231     | 1411    | initdcl
         233     | 1422    | notype_initdcl0
         227     | 1383    | maybeasm
         235     | 1441    | maybe_attribute
         237     | 1448    | attribute_list
         239     | 1453    | attrib
         242     | 1472    | identifiers
         327     | 1844    | enumlist
         261     | 1567    | maybecomma_warn
         270     | 1592    | class_head
         285     | 1653    | LC
         286     | 1666    | opt.component_decl_list
         263     | 1573    | aggr
         275     | 1606    | base_class_list
         279     | 1625    | base_class_visibility_list
         294     | 1682    | component_decl_list
         297     | 1693    | component_decl
         316     | 1799    | components
         319     | 1814    | component_declarator0
         323     | 1829    | component_declarator
         329     | 1850    | enumerator
         333     | 1864    | absdcl
         393     | 2035    | absdcl1
         339     | 1888    | nonmomentary_expr
         355     | 1929    | after_type_declarator_no_typename
         496     | 2805    | see_typename
         413     | 2087    | stmts
         424     | 2144    | stmt
         416     | 2093    | errstmt
         417     | 2100    | .pushlevel
         423     | 2135    | simple_if
         462     | 2657    | forhead.1
         465     | 2666    | forhead.2
         469     | 2679    | maybe_type_qual
         474     | 2700    | asm_operands
         479     | 2716    | asm_clobbers
         504     | 2841    | raise_identifier
         455     | 2565    | try
         459     | 2581    | except_stmts
         511     | 2857    | raise_identifiers
         458     | 2579    | try_head
         476     | 2705    | nonnull_asm_operands
         478     | 2711    | asm_operand
         489     | 2779    | parms
         492     | 2790    | parm
         498     | 2813    | bad_parm
         497     | 2809    | dont_see_typename
   --------------------------------------------------


f. Cross Reference Table of the rule in the order of alpha
Command line: ytool cpp.y f >temp
The content of temp is:

   ===========  CROSS REFERENCE TABLE (2) ===========
         RUEL_No.| LINE_No.| SYMBOL
   --------------------------------------------------
         3       | 228     | .program
         417     | 2100    | .pushlevel
         175     | 1166    | .scope
         55      | 507     | .set_base_init
         285     | 1653    | LC
         333     | 1864    | absdcl
         393     | 2035    | absdcl1
         340     | 1894    | after_type_declarator
         355     | 1929    | after_type_declarator_no_typename
         263     | 1573    | aggr
         479     | 2716    | asm_clobbers
         478     | 2711    | asm_operand
         474     | 2700    | asm_operands
         239     | 1453    | attrib
         237     | 1448    | attribute_list
         498     | 2813    | bad_parm
         275     | 1606    | base_class_list
         279     | 1625    | base_class_visibility_list
         54      | 498     | base_init
         107     | 812     | cast_expr
         270     | 1592    | class_head
         297     | 1693    | component_decl
         294     | 1682    | component_decl_list
         323     | 1829    | component_declarator
         319     | 1814    | component_declarator0
         316     | 1799    | components
         420     | 2118    | compstmt
         418     | 2112    | compstmt_or_error
         19      | 284     | datadef
         184     | 1223    | decl
         190     | 1260    | declarator
         200     | 1296    | declmods
         177     | 1173    | delete
         497     | 2809    | dont_see_typename
         18      | 280     | dummy_decl
         329     | 1850    | enumerator
         327     | 1844    | enumlist
         416     | 2093    | errstmt
         459     | 2581    | except_stmts
         85      | 664     | expr
         110     | 834     | expr_no_commas
         6       | 243     | extdef
         4       | 238     | extdefs
         14      | 266     | extern_lang_string
         37      | 362     | fn.def1
         43      | 389     | fn.def2
         29      | 323     | fndef
         462     | 2657    | forhead.1
         465     | 2666    | forhead.2
         66      | 618     | identifier
         68      | 623     | identifier_or_opname
         242     | 1472    | identifiers
         244     | 1479    | init
         231     | 1411    | initdcl
         229     | 1394    | initdcl0
         223     | 1373    | initdecls
         249     | 1498    | initlist
         235     | 1441    | maybe_attribute
         502     | 2834    | maybe_raises
         469     | 2679    | maybe_type_qual
         227     | 1383    | maybeasm
         259     | 1562    | maybecomma
         261     | 1567    | maybecomma_warn
         60      | 547     | member_init
         56      | 536     | member_init_list
         171     | 1156    | new
         181     | 1189    | nodecls
         335     | 1870    | nonempty_type_quals
         339     | 1888    | nonmomentary_expr
         476     | 2705    | nonnull_asm_operands
         87      | 683     | nonnull_exprlist
         367     | 1962    | notype_declarator
         233     | 1422    | notype_initdcl0
         225     | 1378    | notype_initdecls
         182     | 1198    | object
         513     | 2866    | operator_name
         286     | 1666    | opt.component_decl_list
         500     | 2827    | opt.init
         16      | 274     | ov_identifiers
         15      | 271     | overloaddef
         492     | 2790    | parm
         481     | 2728    | parmlist
         489     | 2779    | parms
         134     | 891     | primary
         161     | 1120    | primary_no_id
         1       | 223     | program
         504     | 2841    | raise_identifier
         511     | 2857    | raise_identifiers
         196     | 1280    | reserved_declspecs
         208     | 1325    | reserved_typespecquals
         50      | 449     | return_id
         51      | 457     | return_init
         390     | 2028    | scoped_identifier
         496     | 2805    | see_typename
         423     | 2135    | simple_if
         424     | 2144    | stmt
         413     | 2087    | stmts
         179     | 1183    | string
         251     | 1505    | structsp
         455     | 2565    | try
         458     | 2579    | try_head
         337     | 1877    | type_quals
         192     | 1269    | typed_declspecs
         204     | 1314    | typed_typespecs
         331     | 1857    | typename
         210     | 1336    | typespec
         215     | 1351    | typespecqual_reserved
         90      | 692     | unary_expr
         80      | 652     | unop
         77      | 644     | wrapper
         218     | 1356    | x_typespec
         471     | 2690    | xexpr
   --------------------------------------------------


g. Cross Reference Table of the rule in nonterminal appearing order
Command line: ytool cpp.y g >temp
The content of temp is:

   ===========  CROSS REFERENCE TABLE (3) ===========
         RUEL_No.| LINE_No.| SYMBOL
   --------------------------------------------------
         1       | 223     | program
         3       | 228     | .program
         4       | 238     | extdefs
         6       | 243     | extdef
         14      | 266     | extern_lang_string
         15      | 271     | overloaddef
         16      | 274     | ov_identifiers
         18      | 280     | dummy_decl
         19      | 284     | datadef
         29      | 323     | fndef
         37      | 362     | fn.def1
         43      | 389     | fn.def2
         50      | 449     | return_id
         51      | 457     | return_init
         54      | 498     | base_init
         55      | 507     | .set_base_init
         56      | 536     | member_init_list
         60      | 547     | member_init
         66      | 618     | identifier
         68      | 623     | identifier_or_opname
         77      | 644     | wrapper
         80      | 652     | unop
         85      | 664     | expr
         87      | 683     | nonnull_exprlist
         90      | 692     | unary_expr
         107     | 812     | cast_expr
         110     | 834     | expr_no_commas
         134     | 891     | primary
         161     | 1120    | primary_no_id
         171     | 1156    | new
         175     | 1166    | .scope
         177     | 1173    | delete
         179     | 1183    | string
         181     | 1189    | nodecls
         182     | 1198    | object
         184     | 1223    | decl
         190     | 1260    | declarator
         192     | 1269    | typed_declspecs
         196     | 1280    | reserved_declspecs
         200     | 1296    | declmods
         204     | 1314    | typed_typespecs
         208     | 1325    | reserved_typespecquals
         210     | 1336    | typespec
         215     | 1351    | typespecqual_reserved
         218     | 1356    | x_typespec
         223     | 1373    | initdecls
         225     | 1378    | notype_initdecls
         227     | 1383    | maybeasm
         229     | 1394    | initdcl0
         231     | 1411    | initdcl
         233     | 1422    | notype_initdcl0
         235     | 1441    | maybe_attribute
         237     | 1448    | attribute_list
         239     | 1453    | attrib
         242     | 1472    | identifiers
         244     | 1479    | init
         249     | 1498    | initlist
         251     | 1505    | structsp
         259     | 1562    | maybecomma
         261     | 1567    | maybecomma_warn
         263     | 1573    | aggr
         270     | 1592    | class_head
         275     | 1606    | base_class_list
         279     | 1625    | base_class_visibility_list
         285     | 1653    | LC
         286     | 1666    | opt.component_decl_list
         294     | 1682    | component_decl_list
         297     | 1693    | component_decl
         316     | 1799    | components
         319     | 1814    | component_declarator0
         323     | 1829    | component_declarator
         327     | 1844    | enumlist
         329     | 1850    | enumerator
         331     | 1857    | typename
         333     | 1864    | absdcl
         335     | 1870    | nonempty_type_quals
         337     | 1877    | type_quals
         339     | 1888    | nonmomentary_expr
         340     | 1894    | after_type_declarator
         355     | 1929    | after_type_declarator_no_typename
         367     | 1962    | notype_declarator
         390     | 2028    | scoped_identifier
         393     | 2035    | absdcl1
         413     | 2087    | stmts
         416     | 2093    | errstmt
         417     | 2100    | .pushlevel
         418     | 2112    | compstmt_or_error
         420     | 2118    | compstmt
         423     | 2135    | simple_if
         424     | 2144    | stmt
         455     | 2565    | try
         458     | 2579    | try_head
         459     | 2581    | except_stmts
         462     | 2657    | forhead.1
         465     | 2666    | forhead.2
         469     | 2679    | maybe_type_qual
         471     | 2690    | xexpr
         474     | 2700    | asm_operands
         476     | 2705    | nonnull_asm_operands
         478     | 2711    | asm_operand
         479     | 2716    | asm_clobbers
         481     | 2728    | parmlist
         489     | 2779    | parms
         492     | 2790    | parm
         496     | 2805    | see_typename
         497     | 2809    | dont_see_typename
         498     | 2813    | bad_parm
         500     | 2827    | opt.init
         502     | 2834    | maybe_raises
         504     | 2841    | raise_identifier
         511     | 2857    | raise_identifiers
         513     | 2866    | operator_name
   --------------------------------------------------


h. Grammar Description File with line number
Command line: ytool cpp.y h >temp
The content of temp is:


1   :
2   : /* yacc parser for C++ syntax.
3   :    Copyright (C) 1988, 1989 Free Software Foundation, Inc.
4   :    Hacked by Michael Tiemann (tiemann@mcc.com)
5   :
6   : This file is part of GNU CC.
7   :
8   : GNU CC is free software; you can redistribute it and/or modify
9   : it under the terms of the GNU General Public License as published by
10  : the Free Software Foundation; either version 1, or (at your option)
11  : any later version.
12  :
13  : GNU CC is distributed in the hope that it will be useful,
14  : but WITHOUT ANY WARRANTY; without even the implied warranty of
15  : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  : GNU General Public License for more details.
17  :
18  : You should have received a copy of the GNU General Public License
19  : along with GNU CC; see the file COPYING.  If not, write to
20  : the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
21  :
22  :
23  : /* This grammar is based on the GNU CC grammar.  */
24  :
25  : /* Also note: this version contains experimental exception
26  :    handling features.  They could break, change, disappear,
27  :    or otherwise exhibit volatile behavior.  Don't depend on
28  :    me (Michael Tiemann) to protect you from any negative impact
29  :    this may have on your professional, personal, or spiritual life.  */
30  :
31  : %{
32  : #include "config.h"
33  : #include "tree.h"
34  : #include "input.h"
35  : #include "cplus-parse.h"
36  : #include "cplus-tree.h"
37  : #include "assert.h"
38  :
39  : /* C++ extensions */
40  : extern tree ridpointers[];      /* need this up here */
41  : extern tree void_list_node;
42  :
43  : #include 
44  : #include 
45  :
46  : #ifndef errno
47  : extern int errno;
48  : #endif
49  :
50  : extern int end_of_file;
51  :
52  : void yyerror ();
53  :
54  : /* Contains error message to give if user tries to declare
55  :    a variable where one does not belong.  */
56  : static char *stmt_decl_msg = 0;
57  :
58  : #ifndef YYDEBUG
59  : /* Cause the `yydebug' variable to be defined.  */
60  : int yydebug;
61  : #endif
62  :
63  : /* Cons up an empty parameter list.  */
64  : #ifdef __GNU__
65  : __inline
66  : #endif
67  : static tree
68  : empty_parms ()
69  : {
70  :   tree parms;
71  :
72  :   if (strict_prototype)
73  :     parms = void_list_node;
74  :   else
75  :     parms = NULL_TREE;
76  :   return parms;
77  : }
78  :
79  : void yyhook ();
80  : %}
81  :
82  : %start program
83  :
84  : %union {long itype; tree ttype; enum tree_code code; }
85  :
86  : /* All identifiers that are not reserved words
87  :    and are not declared typedefs in the current block */
88  : %token IDENTIFIER
89  :
90  : /* All identifiers that are declared typedefs in the current block.
91  :    In some contexts, they are treated just like IDENTIFIER,
92  :    but they can also serve as typespecs in declarations.  */
93  : %token TYPENAME
94  :
95  : /* Reserved words that specify storage class.
96  :    yylval contains an IDENTIFIER_NODE which indicates which one.  */
97  : %token SCSPEC
98  :
99  : /* Reserved words that specify type.
100 :    yylval contains an IDENTIFIER_NODE which indicates which one.  */
101 : %token TYPESPEC
102 :
103 : /* Reserved words that qualify type: "const" or "volatile".
104 :    yylval contains an IDENTIFIER_NODE which indicates which one.  */
105 : %token TYPE_QUAL
106 :
107 : /* Character or numeric constants.
108 :    yylval is the node for the constant.  */
109 : %token CONSTANT
110 :
111 : /* String constants in raw form.
112 :    yylval is a STRING_CST node.  */
113 : %token STRING
114 :
115 : /* "...", used for functions with variable arglists.  */
116 : %token ELLIPSIS
117 :
118 : /* the reserved words */
119 : %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
120 : %token BREAK CONTINUE RETURN GOTO ASM TYPEOF ALIGNOF
121 : %token ATTRIBUTE
122 :
123 : /* the reserved words... C++ extensions */
124 : %token  AGGR
125 : %token DELETE NEW OVERLOAD PRIVATE PUBLIC PROTECTED THIS OPERATOR
126 : %token DYNAMIC POINTSAT_LEFT_RIGHT LEFT_RIGHT
127 : %token  SCOPE
128 :
129 : /* Define the operator tokens and their precedences.
130 :    The value is an integer because, if used, it is the tree code
131 :    to use in the expression made from the operator.  */
132 :
133 : %left EMPTY                     /* used to resolve s/r with epsilon */
134 :
135 : /* Add precedence rules to solve dangling else s/r conflict */
136 : %nonassoc IF
137 : %nonassoc ELSE
138 :
139 : %left IDENTIFIER TYPENAME TYPENAME_COLON SCSPEC TYPESPEC TYPE_QUAL ENUM AGGR
140 :
141 : %left '{' ','
142 :
143 : %right  ASSIGN '='
144 : %right  '?' ':' RANGE
145 : %left  OROR
146 : %left  ANDAND
147 : %left  '|'
148 : %left  '^'
149 : %left  '&'
150 : %left  MIN_MAX
151 : %left  EQCOMPARE
152 : %left  ARITHCOMPARE
153 : %left  LSHIFT RSHIFT
154 : %left  '+' '-'
155 : %left  '*' '/' '%'
156 : %right  UNARY PLUSPLUS MINUSMINUS
157 : %left HYPERUNARY
158 : %left  PAREN_STAR_PAREN PAREN_X_SCOPE_STAR_PAREN PAREN_X_SCOPE_REF_PAREN LEFT_RIGHT
159 : %left  POINTSAT '.' '(' '['
160 :
161 : %right SCOPE                    /* C++ extension */
162 : %nonassoc NEW DELETE RAISE RAISES RERAISE TRY EXCEPT CATCH
163 : %right DYNAMIC
164 :
165 : %type  unop
166 :
167 : %type  identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist /* exprlist */
168 : %type  expr_no_commas cast_expr unary_expr primary string STRING
169 : %type  typed_declspecs reserved_declspecs
170 : %type  typed_typespecs reserved_typespecquals
171 : %type  declmods typespec typespecqual_reserved
172 : %type  SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
173 : %type  initdecls notype_initdecls initdcl        /* C++ modification */
174 : %type  init initlist maybeasm
175 : %type  asm_operands nonnull_asm_operands asm_operand asm_clobbers
176 : %type  maybe_attribute attribute_list attrib
177 :
178 : %type  compstmt except_stmts
179 :
180 : %type  declarator notype_declarator after_type_declarator
181 :
182 : %type  structsp opt.component_decl_list component_decl_list component_decl components component_declarator
183 : %type  enumlist enumerator
184 : %type  typename absdcl absdcl1 type_quals
185 : %type  xexpr see_typename parmlist parms parm bad_parm
186 :
187 : /* C++ extensions */
188 : %token  TYPENAME_COLON TYPENAME_SCOPE TYPENAME_ELLIPSIS
189 : %token  PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
190 : %type  fn.def2 dummy_decl x_typespec return_id
191 : %type  class_head opt.init base_class_list base_class_visibility_list
192 : %type  after_type_declarator_no_typename
193 : %type  maybe_raises raise_identifier raise_identifiers
194 : %type  component_declarator0 scoped_identifier
195 : %type  forhead.1 identifier_or_opname operator_name
196 : %type  new delete object primary_no_id aggr nonmomentary_expr
197 : %type  LC forhead.2 initdcl0 notype_initdcl0 wrapper member_init_list
198 : %type  .scope try
199 : 
200 : %{
201 : /* the declaration found for the last IDENTIFIER token read in.
202 :    yylex must look this up to detect typedefs, which get token type TYPENAME,
203 :    so it is left around in case the identifier is not a typedef but is
204 :    used in a context which makes it a reference to a variable.  */
205 : tree lastiddecl;
206 :
207 : tree make_pointer_declarator (), make_reference_declarator ();
208 :
209 : tree combine_strings ();
210 : void reinit_parse_for_function ();
211 : void reinit_parse_for_method ();
212 :
213 : /* List of types and structure classes of the current declaration.  */
214 : tree current_declspecs;
215 :
216 : int undeclared_variable_notice; /* 1 if we explained undeclared var errors.  */
217 :
218 : int yylex ();
219 : extern FILE *finput;
220 : %}
221 : 
222 : %%
223 : program: .program /* empty */
224 :         | .program extdefs
225 :                 { finish_file (); }
226 :         ;
227 :
228 : .program: /* empty */
229 :                 {
230 :                   if (flag_cadillac)
231 :                     cadillac_start ();
232 :                 }
233 :
234 : /* the reason for the strange actions in this rule
235 :  is so that notype_initdecls when reached via datadef
236 :  can find a valid list of type and sc specs in src/ytool.pl. */
237 :
238 : extdefs:
239 :           {0ttype>60 NULL_TREE; } extdef
240 :         | extdefs {0ttype>60 NULL_TREE; } extdef
241 :         ;
242 :
243 : extdef:
244 :           fndef
245 :                 { if (pending_inlines) do_pending_inlines (); }
246 :         | datadef
247 :                 { if (pending_inlines) do_pending_inlines (); }
248 :         | overloaddef
249 :         | ASM '(' string ')' ';'
250 :                 { if (pedantic)
251 :                     warning ("ANSI C forbids use of `asm' keyword");
252 :                   if (TREE_CHAIN ())  = combine_strings ();
253 :                   assemble_asm (); }
254 :         | extern_lang_string '{' extdefs '}'
255 :                 { pop_lang_context (); }
256 :         | extern_lang_string '{' '}'
257 :                 { pop_lang_context (); }
258 :         | extern_lang_string fndef
259 :                 { if (pending_inlines) do_pending_inlines ();
260 :                   pop_lang_context (); }
261 :         | extern_lang_string datadef
262 :                 { if (pending_inlines) do_pending_inlines ();
263 :                   pop_lang_context (); }
264 :         ;
265 :
266 : extern_lang_string:
267 :           EXTERN_LANG_STRING
268 :                 { push_lang_context (); }
269 :         ;
270 :
271 : overloaddef:
272 :           OVERLOAD ov_identifiers ';'
273 :
274 : ov_identifiers: IDENTIFIER
275 :                 { declare_overloaded (); }
276 :         | ov_identifiers ',' IDENTIFIER
277 :                 { declare_overloaded (); }
278 :         ;

      .
      .
      .
© 1998-2005 SoloTony (Antonio Solo) www.solotony.com