File parse-yacc.c

RCS Header: /home/amb/cxref/RCS/parse.y 1.44 2002/05/05 09:48:06 amb Exp

C Cross Referencing & Documentation tool. Version 1.5d.
C parser.

References Variables: firstparse-yacc.c


Included Files


Preprocessor definitions

#define YYBISON 1

#define YYSKELETON_NAME "yacc.c"

#define YYPURE 0

#define YYLSP_NEEDED 0

#define YYTOKENTYPE

#define IDENTIFIER 258

#define TYPE_NAME 259

#define LITERAL 260

#define STRING_LITERAL 261

#define ELLIPSES 262

#define MUL_ASSIGN 263

#define DIV_ASSIGN 264

#define MOD_ASSIGN 265

#define ADD_ASSIGN 266

#define SUB_ASSIGN 267

#define LEFT_ASSIGN 268

#define RIGHT_ASSIGN 269

#define AND_ASSIGN 270

#define XOR_ASSIGN 271

#define OR_ASSIGN 272

#define EQ_OP 273

#define NE_OP 274

#define PTR_OP 275

#define AND_OP 276

#define OR_OP 277

#define DEC_OP 278

#define INC_OP 279

#define LE_OP 280

#define GE_OP 281

#define LEFT_SHIFT 282

#define RIGHT_SHIFT 283

#define SIZEOF 284

#define TYPEDEF 285

#define EXTERN 286

#define STATIC 287

#define AUTO 288

#define REGISTER 289

#define CONST 290

#define VOLATILE 291

#define VOID 292

#define INLINE 293

#define CHAR 294

#define SHORT 295

#define INT 296

#define LONG 297

#define SIGNED 298

#define UNSIGNED 299

#define FLOAT 300

#define DOUBLE 301

#define STRUCT 302

#define UNION 303

#define ENUM 304

#define CASE 305

#define DEFAULT 306

#define IF 307

#define ELSE 308

#define SWITCH 309

#define WHILE 310

#define DO 311

#define FOR 312

#define GOTO 313

#define CONTINUE 314

#define BREAK 315

#define RETURN 316

#define ASM 317

#define yylex cxref_yylex

The variable must be LOCAL or EXTERNAL or GLOBAL, so this checks and sets that.

#define SCOPE

#define YYERROR_VERBOSE 1

#define YYSTACK_ALLOC alloca

#define YYSTACK_FREE( Ptr )

#define YYSTACK_GAP_MAXIMUM

#define YYSTACK_BYTES( N )

#define YYCOPY( To, From, Count )

#define YYSTACK_RELOCATE( Stack )

#define YYFINAL 90

#define YYLAST 1712

#define YYNTOKENS 87

#define YYNNTS 171

#define YYNRULES 381

#define YYNSTATES 579

#define YYUNDEFTOK 2

#define YYMAXUTOK 317

#define YYTRANSLATE( YYX )

#define YYPACT_NINF -445

#define YYTABLE_NINF -238

#define YYSIZE_T __SIZE_TYPE__

#define yyerrok

#define yyclearin

#define YYEMPTY -2

#define YYEOF 0

#define YYACCEPT

#define YYABORT

#define YYERROR

#define YYFAIL

#define YYRECOVERING

#define YYBACKUP( Token, Value )

#define YYTERROR 1

#define YYERRCODE 256

#define YYLLOC_DEFAULT( Current, Rhs, N )

#define YYLEX yylex

#define YYFPRINTF fprintf

#define YYDPRINTF( Args )

#define YYDSYMPRINT( Args )

#define YYDSYMPRINTF( Title, Token, Value, Location )

#define YY_STACK_PRINT( Bottom, Top )

#define YY_REDUCE_PRINT( Rule )

#define YYINITDEPTH 200

#define YYMAXDEPTH 10000

#define yystrlen strlen

#define YYPOPSTACK


Type enum yytokentype

enum yytokentype
enum yytokentype 
   { 
     IDENTIFIER; 
     TYPE_NAME; 
     LITERAL; 
     STRING_LITERAL; 
     ELLIPSES; 
     MUL_ASSIGN; 
     DIV_ASSIGN; 
     MOD_ASSIGN; 
     ADD_ASSIGN; 
     SUB_ASSIGN; 
     LEFT_ASSIGN; 
     RIGHT_ASSIGN; 
     AND_ASSIGN; 
     XOR_ASSIGN; 
     OR_ASSIGN; 
     EQ_OP; 
     NE_OP; 
     PTR_OP; 
     AND_OP; 
     OR_OP; 
     DEC_OP; 
     INC_OP; 
     LE_OP; 
     GE_OP; 
     LEFT_SHIFT; 
     RIGHT_SHIFT; 
     SIZEOF; 
     TYPEDEF; 
     EXTERN; 
     STATIC; 
     AUTO; 
     REGISTER; 
     CONST; 
     VOLATILE; 
     VOID; 
     INLINE; 
     CHAR; 
     SHORT; 
     INT; 
     LONG; 
     SIGNED; 
     UNSIGNED; 
     FLOAT; 
     DOUBLE; 
     STRUCT; 
     UNION; 
     ENUM; 
     CASE; 
     DEFAULT; 
     IF; 
     ELSE; 
     SWITCH; 
     WHILE; 
     DO; 
     FOR; 
     GOTO; 
     CONTINUE; 
     BREAK; 
     RETURN; 
     ASM; 
   } 

Typedef stack

A structure to hold the information about an object.

typedef struct _stack stack
struct _stack 
   { 
     char* name; The name of the object.
     char* type; The type of the object.
     char* qual; The type qualifier of the object.
   } 


Type union yyalloc

union yyalloc
union yyalloc 
   { 
     short yyss; 
     yystype yyvs; 
   } 

Typedef yysigned_char

typedef signed char yysigned_char

Global Variable yydebug

Turn the debugging output on and off.

int yydebug
Visible in:  cxref.c
   func.c
   parse-lex.c
   parse-yacc.c
   parse-yy.h
   preproc.c
   type.c
   var.c
Used in: DocumentTheFile()cxref.c
  yyparse()parse-yacc.c


Global Variable yylval

For communication between the lex and yacc code.

yystype yylval
Visible in:  cxref.c
   func.c
   parse-lex.c
   parse-yacc.c
   parse-yacc.h
   parse-yy.h
   preproc.c
   type.c
   var.c
Used in: cxref_yylex()parse-yacc.c
  yyerror()parse-yacc.c
  yylex()parse-lex.c
  yyparse()parse-yacc.c


Global Variable in_typedef

A flag that is set to true when typedef is seen in a statement.

int in_typedef
Visible in:  parse-yacc.c
   type.c
Used in: ResetParser()parse-yacc.c
  SeenStructUnionEnd()type.c
  SeenStructUnionStart()type.c
  yyparse()parse-yacc.c


Global Variable yychar

int yychar
Visible in:  parse-yacc.c
Used in: yyerror()parse-yacc.c
  yyparse()parse-yacc.c

Global Variable yynerrs

int yynerrs
Visible in:  parse-yacc.c
Used in: yyparse()parse-yacc.c

External Variables

in_header
When in a header file, some stuff can be skipped over quickly.

extern int in_header
Defined in: preproc.c


Local Variables

scope
The scope of the function / variable that is being examined.

static int scope
Used in: ResetParser()
  yyparse()

in_function
When in a function or a function definition, the behaviour is different.

static int in_function
Used in: ResetParser()
  yyparse()

in_funcdef
When in a function or a function definition, the behaviour is different.

static int in_funcdef
Used in: ResetParser()
  yyparse()

in_funcbody
When in a function or a function definition, the behaviour is different.

static int in_funcbody
Used in: ResetParser()
  yyparse()

first
The parsing stack first value.

static stack first
Used in:  parse-yacc.c
  ResetParser()
  push()

list
The parsing stack list of all values.

static stack* list
Used in: ResetParser()
  pop()
  push()

current
The parsing stack current values.

static stack* current
Used in: ResetParser()
  pop()
  push()
  reset()
  yyparse()

depth
The depth of the stack currently in use.

static int depth
Used in: ResetParser()
  pop()
  push()

maxdepth
The depth of the stack total malloced.

static int maxdepth
Used in: ResetParser()
  push()

common_comment
Declarations that are in the same statement share this comment.

static char* common_comment
Used in: ResetParser()
  yyparse()

in_structunion
When inside a struct / union / enum definition, this is the depth.

static int in_structunion
Used in: ResetParser()
  cxref_yylex()
  yyparse()

comp_type
When inside a struct / union definition, this is the component type.

static char* comp_type
Used in: ResetParser()
  yyparse()

in_type_spec
To solve the problem where a type name is used as an identifier.

static int in_type_spec
Used in: ResetParser()
  cxref_yylex()
  yyparse()

yytranslate
static const unsigned char yytranslate[]
Used in: yyerror()
  yyparse()

yyprhs
static const unsigned short yyprhs[]
Used in: yy_reduce_print()

yyrhs
static const short yyrhs[]
Used in: yy_reduce_print()

yyrline
static const unsigned short yyrline[]
Used in: yy_reduce_print()

yytname
static const char* const yytname[]
Used in: yy_reduce_print()
  yyerror()
  yyparse()
  yysymprint()

yytoknum
static const unsigned short yytoknum[]

yyr1
static const unsigned short yyr1[]
Used in: yy_reduce_print()
  yyparse()

yyr2
static const unsigned char yyr2[]
Used in: yyparse()

yydefact
static const unsigned short yydefact[]
Used in: yyparse()

yydefgoto
static const short yydefgoto[]
Used in: yyparse()

yypact
static const short yypact[]
Used in: yyparse()

yypgoto
static const short yypgoto[]
Used in: yyparse()

yytable
static const short yytable[]
Used in: yyparse()

yycheck
static const short yycheck[]
Used in: yyparse()

yystos
static const unsigned short yystos[]
Used in: yyparse()

last_yylex
static int last_yylex[11]
Used in: cxref_yylex()
  yyerror()

last_yylval
static char* last_yylval[11]
Used in: cxref_yylex()
  yyerror()

count
static int count
Used in: cxref_yylex()
  yyerror()

modcount
static int modcount
Used in: cxref_yylex()
  yyerror()


Global Function ResetParser()

Reset the Parser, ready for the next file.

void ResetParser ( void )
Prototyped in: cxref.h
Calls: SafeFree()memory.c
  reset()parse-yacc.c
Called by: main()cxref.c
References Variables: common_commentparse-yacc.c
  comp_typeparse-yacc.c
  currentparse-yacc.c
  depthparse-yacc.c
  firstparse-yacc.c
  in_funcbodyparse-yacc.c
  in_funcdefparse-yacc.c
  in_functionparse-yacc.c
  in_structunionparse-yacc.c
  in_type_specparse-yacc.c
  in_typedefparse-yacc.c
  listparse-yacc.c
  maxdepthparse-yacc.c
  scopeparse-yacc.c


Global Function yyparse()

int yyparse ( void )
Prototyped in: parse-yy.h
Calls: CheckFunctionVariableRef()func.c
  ConcatStrings()memory.c
  CopyString()memory.c
  DownScope()var.c
  GetCurrentComment()comment.c
  IsAScopeVariable()var.c
  IsATypeName()type.c
  SeenFunctionArg()func.c
  SeenFunctionCall()func.c
  SeenFunctionDeclaration()func.c
  SeenFunctionDefinition()func.c
  SeenFunctionProto()func.c
  SeenScopeVariable()var.c
  SeenStructUnionComp()type.c
  SeenStructUnionEnd()type.c
  SeenStructUnionStart()type.c
  SeenTypedef()type.c
  SeenTypedefName()type.c
  SeenVariableDefinition()var.c
  SetCurrentComment()comment.c
  UpScope()var.c
  cxref_yylex()parse-yacc.c
  pop()parse-yacc.c
  push()parse-yacc.c
  reset()parse-yacc.c
  yy_reduce_print()parse-yacc.c
  yy_stack_print()parse-yacc.c
  yydestruct()parse-yacc.c
  yyerror()parse-yacc.c
  yystpcpy()parse-yacc.c
  yysymprint()parse-yacc.c
  __builtin_alloca(), __builtin_memcpy(), fprintf(), strcmp(), strlen(), strstr()
Called by: DocumentTheFile()cxref.c
References Variables: common_commentparse-yacc.c
  comp_typeparse-yacc.c
  currentparse-yacc.c
  in_funcbodyparse-yacc.c
  in_funcdefparse-yacc.c
  in_functionparse-yacc.c
  in_headerpreproc.c
  in_structunionparse-yacc.c
  in_type_specparse-yacc.c
  in_typedefparse-yacc.c
  scopeparse-yacc.c
  yycharparse-yacc.c
  yycheckparse-yacc.c
  yydebugparse-yacc.c
  yydefactparse-yacc.c
  yydefgotoparse-yacc.c
  yylvalparse-yacc.c
  yynerrsparse-yacc.c
  yypactparse-yacc.c
  yypgotoparse-yacc.c
  yyr1parse-yacc.c
  yyr2parse-yacc.c
  yystosparse-yacc.c
  yytableparse-yacc.c
  yytnameparse-yacc.c
  yytranslateparse-yacc.c

Local Function cxref_yylex()

Call the lexer, the feedback from the parser to the lexer is applied here.

static int cxref_yylex ( void )

int cxref_yylex
Returns the value from the lexer, modified due to parser feedback.
Prototyped in: parse-yacc.c
Calls: yylex()parse-lex.c
Called by: yyerror()parse-yacc.c
  yyparse()parse-yacc.c
References Variables: countparse-yacc.c
  in_structunionparse-yacc.c
  in_type_specparse-yacc.c
  last_yylexparse-yacc.c
  last_yylvalparse-yacc.c
  modcountparse-yacc.c
  yylvalparse-yacc.c

Local Function pop()

Pop a level from the stack.

static void pop ( void )
Calls: reset()parse-yacc.c
Called by: yyparse()parse-yacc.c
References Variables: currentparse-yacc.c
  depthparse-yacc.c
  listparse-yacc.c


Local Function push()

Push a level onto the stack.

static void push ( void )
Calls: SafeMalloc()memory.c
  SafeRealloc()memory.c
  reset()parse-yacc.c
Called by: yyparse()parse-yacc.c
References Variables: currentparse-yacc.c
  depthparse-yacc.c
  firstparse-yacc.c
  listparse-yacc.c
  maxdepthparse-yacc.c


Local Function reset()

Reset the current level on the stack.

static void reset ( void )
Called by: ResetParser()parse-yacc.c
  pop()parse-yacc.c
  push()parse-yacc.c
  yyparse()parse-yacc.c
References Variables: currentparse-yacc.c


Local Function yy_reduce_print()

static void yy_reduce_print ( int yyrule )
Calls: fprintf()
Called by: yyparse()parse-yacc.c
References Variables: yyprhsparse-yacc.c
  yyr1parse-yacc.c
  yyrhsparse-yacc.c
  yyrlineparse-yacc.c
  yytnameparse-yacc.c

Local Function yy_stack_print()

static void yy_stack_print ( short* bottom, short* top )
Calls: fprintf()
Called by: yyparse()parse-yacc.c

Local Function yydestruct()

static void yydestruct ( int yytype, yystype* yyvaluep )
Called by: yyparse()parse-yacc.c

Local Function yyerror()

Stop parsing the current file, due to an error.

static void yyerror ( char* s )

char* s
The error message to print out.
Prototyped in: parse-yacc.c
Calls: cxref_yylex()parse-yacc.c
  yylex()parse-lex.c
  fflush(), fprintf()
Called by: yyparse()parse-yacc.c
References Variables: countparse-yacc.c
  last_yylexparse-yacc.c
  last_yylvalparse-yacc.c
  modcountparse-yacc.c
  parse_fileparse-lex.c
  parse_lineparse-lex.c
  yycharparse-yacc.c
  yylvalparse-yacc.c
  yytnameparse-yacc.c
  yytranslateparse-yacc.c

Local Function yystpcpy()

static char* yystpcpy ( char* yydest, const char* yysrc )
Called by: yyparse()parse-yacc.c

Local Function yysymprint()

static void yysymprint ( FILE* yyoutput, int yytype, yystype* yyvaluep )
Calls: fprintf(), printf()
Called by: yyparse()parse-yacc.c
References Variables: yytnameparse-yacc.c