Main Page | Class List | Directories | File List | Class Members | File Members

awkgram.c File Reference

#include "awk.h"

Go to the source code of this file.

Classes

union  YYSTYPE
union  yyalloc
struct  token
struct  finfo
struct  fdesc

Defines

#define YYBISON   1
#define YYSKELETON_NAME   "yacc.c"
#define YYPURE   0
#define YYLSP_NEEDED   0
#define FUNC_CALL   258
#define NAME   259
#define REGEXP   260
#define ERROR   261
#define YNUMBER   262
#define YSTRING   263
#define RELOP   264
#define IO_OUT   265
#define IO_IN   266
#define ASSIGNOP   267
#define ASSIGN   268
#define MATCHOP   269
#define CONCAT_OP   270
#define LEX_BEGIN   271
#define LEX_END   272
#define LEX_IF   273
#define LEX_ELSE   274
#define LEX_RETURN   275
#define LEX_DELETE   276
#define LEX_SWITCH   277
#define LEX_CASE   278
#define LEX_DEFAULT   279
#define LEX_WHILE   280
#define LEX_DO   281
#define LEX_FOR   282
#define LEX_BREAK   283
#define LEX_CONTINUE   284
#define LEX_PRINT   285
#define LEX_PRINTF   286
#define LEX_NEXT   287
#define LEX_EXIT   288
#define LEX_FUNCTION   289
#define LEX_GETLINE   290
#define LEX_NEXTFILE   291
#define LEX_IN   292
#define LEX_AND   293
#define LEX_OR   294
#define INCREMENT   295
#define DECREMENT   296
#define LEX_BUILTIN   297
#define LEX_LENGTH   298
#define NEWLINE   299
#define SLASH_BEFORE_EQUAL   300
#define UNARY   301
#define CAN_FREE   TRUE
#define DONT_FREE   FALSE
#define YYDEBUG_LEXER_TEXT   (lexeme)
#define HASHSIZE   1021
#define YYDEBUG   0
#define YYERROR_VERBOSE   0
#define yystype   YYSTYPE
#define YYSTYPE_IS_DECLARED   1
#define YYSTYPE_IS_TRIVIAL   1
#define YYSTACK_ALLOC   malloc
#define YYSTACK_FREE   free
#define YYSTACK_GAP_MAXIMUM   (sizeof (union yyalloc) - 1)
#define YYSTACK_BYTES(N)
#define YYCOPY(To, From, Count)
#define YYSTACK_RELOCATE(Stack)
#define YYFINAL   5
#define YYLAST   1008
#define YYNTOKENS   67
#define YYNNTS   53
#define YYNRULES   155
#define YYNSTATES   293
#define YYUNDEFTOK   2
#define YYMAXUTOK   301
#define YYTRANSLATE(YYX)   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
#define YYPACT_NINF   -236
#define YYTABLE_NINF   -93
#define YYSIZE_T   unsigned int
#define yyerrok   (yyerrstatus = 0)
#define yyclearin   (yychar = YYEMPTY)
#define YYEMPTY   (-2)
#define YYEOF   0
#define YYACCEPT   goto yyacceptlab
#define YYABORT   goto yyabortlab
#define YYERROR   goto yyerrlab1
#define YYFAIL   goto yyerrlab
#define YYRECOVERING()   (!!yyerrstatus)
#define YYBACKUP(Token, Value)
#define YYTERROR   1
#define YYERRCODE   256
#define YYLLOC_DEFAULT(Current, Rhs, N)
#define YYLEX   yylex ()
#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 YYPOPSTACK   (yyvsp--, yyssp--)
#define ARGS   0xFF
#define A(n)   (1<<(n))
#define VERSION_MASK   0xFF00
#define NOT_OLD   0x0100
#define NOT_POSIX   0x0200
#define GAWKX   0x0400
#define RESX   0x0800
#define SLOP   128
#define tokadd(x)   (*tok++ = (x), tok == tokend ? tokexpand() : tok)
#define nextc()
#define pushback()   (lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr)
#define SMART_ALECK   1

Typedefs

typedef short yysigned_char

Enumerations

enum  yytokentype {
  FUNC_CALL = 258, NAME = 259, REGEXP = 260, ERROR = 261,
  YNUMBER = 262, YSTRING = 263, RELOP = 264, IO_OUT = 265,
  IO_IN = 266, ASSIGNOP = 267, ASSIGN = 268, MATCHOP = 269,
  CONCAT_OP = 270, LEX_BEGIN = 271, LEX_END = 272, LEX_IF = 273,
  LEX_ELSE = 274, LEX_RETURN = 275, LEX_DELETE = 276, LEX_SWITCH = 277,
  LEX_CASE = 278, LEX_DEFAULT = 279, LEX_WHILE = 280, LEX_DO = 281,
  LEX_FOR = 282, LEX_BREAK = 283, LEX_CONTINUE = 284, LEX_PRINT = 285,
  LEX_PRINTF = 286, LEX_NEXT = 287, LEX_EXIT = 288, LEX_FUNCTION = 289,
  LEX_GETLINE = 290, LEX_NEXTFILE = 291, LEX_IN = 292, LEX_AND = 293,
  LEX_OR = 294, INCREMENT = 295, DECREMENT = 296, LEX_BUILTIN = 297,
  LEX_LENGTH = 298, NEWLINE = 299, SLASH_BEFORE_EQUAL = 300, UNARY = 301
}
enum  defref { FUNC_DEFINE, FUNC_USE }

Functions

static char *get_src_buf P ((void))
static void yydestruct (int yytype, YYSTYPE *yyvaluep)
int yyparse ()
const char * getfname (register NODE *(*fptr)(NODE *))
static char * get_src_buf ()
char * tokexpand ()
static void allow_newline (void)
static NODEnode_common (NODETYPE op)
NODEnode (NODE *left, NODETYPE op, NODE *right)
static NODEsnode (NODE *subn, NODETYPE op, int idx)
static NODEmake_for_loop (NODE *init, NODE *cond, NODE *incr)
static int dup_parms (NODE *func)
static int parms_shadow (const char *fname, NODE *func)
NODEinstall (char *name, NODE *value)
NODElookup (const char *name)
static int var_comp (const void *v1, const void *v2)
static void valinfo (NODE *n, FILE *fp)
void dump_vars (const char *fname)
void release_all_vars ()
static int fcompare (const void *p1, const void *p2)
void dump_funcs ()
void shadow_funcs ()
static NODEappend_right (NODE *list, NODE *new)
static NODEappend_pattern (NODE **list, NODE *patt)
static void func_install (NODE *params, NODE *def)
static void pop_var (NODE *np, int freeit)
static void pop_params (NODE *params)
static NODEmake_param (char *name)
static void check_funcs ()
static void param_sanity (NODE *arglist)
NODEvariable (char *name, int can_free, NODETYPE type)
static NODEmk_rexp (NODE *exp)
static int isnoeffect (NODETYPE type)
static int isassignable (register NODE *n)
NODEstopme (NODE *tree ATTRIBUTE_UNUSED)
static void dumpintlstr (const char *str, size_t len)
static void dumpintlstr2 (const char *str1, size_t len1, const char *str2, size_t len2)
static void count_args (NODE *tree)
static int isarray (NODE *n)

Variables

static int want_regexp
static int can_return
static int begin_or_end_rule = FALSE
static int parsing_end_rule = FALSE
static int in_print = FALSE
static int in_parens = 0
static char * lexptr
static char * lexend
static char * lexptr_begin
static char * lexeme
static char * thisline = NULL
static int param_counter
static char * tokstart = NULL
static char * tok = NULL
static char * tokend
static long func_count
NODEvariables [HASHSIZE]
static int var_count
char * source
int sourceline
srcsrcfiles
int numfiles
int errcount
NODEbegin_block
NODEend_block
static char builtin_func [] = "@builtin"
static const unsigned char yyr1 []
static const unsigned char yyr2 []
static const unsigned char yydefact []
static const short yydefgoto []
static const short yypact []
static const short yypgoto []
static const short yytable []
static const short yycheck []
static const unsigned char yystos []
int yychar
YYSTYPE yylval
int yynerrs
static const struct token tokentab []
static struct fdescftable [HASHSIZE]


Define Documentation

#define A n   )     (1<<(n))
 

Definition at line 2824 of file awkgram.c.

Referenced by snode().

#define ARGS   0xFF
 

Definition at line 2823 of file awkgram.c.

Referenced by snode().

#define ASSIGN   268
 

Definition at line 112 of file awkgram.c.

Referenced by yylex().

#define ASSIGNOP   267
 

Definition at line 111 of file awkgram.c.

Referenced by yylex().

#define CAN_FREE   TRUE
 

Definition at line 159 of file awkgram.c.

#define CONCAT_OP   270
 

Definition at line 114 of file awkgram.c.

#define DECREMENT   296
 

Definition at line 140 of file awkgram.c.

Referenced by yylex().

#define DONT_FREE   FALSE
 

Definition at line 160 of file awkgram.c.

#define ERROR   261
 

Definition at line 105 of file awkgram.c.

Referenced by system().

#define FUNC_CALL   258
 

Definition at line 102 of file awkgram.c.

Referenced by yylex().

#define GAWKX   0x0400
 

Definition at line 2828 of file awkgram.c.

Referenced by yylex().

#define HASHSIZE   1021
 

Definition at line 212 of file awkgram.c.

Referenced by check_funcs(), dump_funcs(), dump_vars(), func_use(), install(), lookup(), pop_var(), release_all_vars(), and shadow_funcs().

#define INCREMENT   295
 

Definition at line 139 of file awkgram.c.

Referenced by func_call(), interpret(), and yylex().

#define IO_IN   266
 

Definition at line 110 of file awkgram.c.

Referenced by yylex().

#define IO_OUT   265
 

Definition at line 109 of file awkgram.c.

Referenced by yylex().

#define LEX_AND   293
 

Definition at line 137 of file awkgram.c.

Referenced by yylex().

#define LEX_BEGIN   271
 

Definition at line 115 of file awkgram.c.

#define LEX_BREAK   283
 

Definition at line 127 of file awkgram.c.

#define LEX_BUILTIN   297
 

Definition at line 141 of file awkgram.c.

Referenced by yylex().

#define LEX_CASE   278
 

Definition at line 122 of file awkgram.c.

#define LEX_CONTINUE   284
 

Definition at line 128 of file awkgram.c.

#define LEX_DEFAULT   279
 

Definition at line 123 of file awkgram.c.

#define LEX_DELETE   276
 

Definition at line 120 of file awkgram.c.

#define LEX_DO   281
 

Definition at line 125 of file awkgram.c.

#define LEX_ELSE   274
 

Definition at line 118 of file awkgram.c.

#define LEX_END   272
 

Definition at line 116 of file awkgram.c.

#define LEX_EXIT   288
 

Definition at line 132 of file awkgram.c.

#define LEX_FOR   282
 

Definition at line 126 of file awkgram.c.

#define LEX_FUNCTION   289
 

Definition at line 133 of file awkgram.c.

#define LEX_GETLINE   290
 

Definition at line 134 of file awkgram.c.

#define LEX_IF   273
 

Definition at line 117 of file awkgram.c.

#define LEX_IN   292
 

Definition at line 136 of file awkgram.c.

#define LEX_LENGTH   298
 

Definition at line 142 of file awkgram.c.

Referenced by yylex().

#define LEX_NEXT   287
 

Definition at line 131 of file awkgram.c.

#define LEX_NEXTFILE   291
 

Definition at line 135 of file awkgram.c.

#define LEX_OR   294
 

Definition at line 138 of file awkgram.c.

Referenced by yylex().

#define LEX_PRINT   285
 

Definition at line 129 of file awkgram.c.

#define LEX_PRINTF   286
 

Definition at line 130 of file awkgram.c.

#define LEX_RETURN   275
 

Definition at line 119 of file awkgram.c.

#define LEX_SWITCH   277
 

Definition at line 121 of file awkgram.c.

#define LEX_WHILE   280
 

Definition at line 124 of file awkgram.c.

#define MATCHOP   269
 

Definition at line 113 of file awkgram.c.

Referenced by yylex().

#define NAME   259
 

Definition at line 103 of file awkgram.c.

Referenced by yylex().

#define NEWLINE   299
 

Definition at line 143 of file awkgram.c.

Referenced by yylex().

 
#define nextc  ) 
 

Value:

((lexptr && lexptr < lexend) ? \
                    ((int) (unsigned char) *lexptr++) : \
                    (get_src_buf() ? ((int) (unsigned char) *lexptr++) : EOF) \
                )

Definition at line 3297 of file awkgram.c.

Referenced by allow_newline(), and yylex().

#define NOT_OLD   0x0100
 

Definition at line 2826 of file awkgram.c.

Referenced by yylex().

#define NOT_POSIX   0x0200
 

Definition at line 2827 of file awkgram.c.

Referenced by yylex().

 
#define pushback  )     (lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr)
 

Definition at line 3322 of file awkgram.c.

Referenced by allow_newline(), and yylex().

#define REGEXP   260
 

Definition at line 104 of file awkgram.c.

Referenced by yylex().

#define RELOP   264
 

Definition at line 108 of file awkgram.c.

Referenced by yylex().

#define RESX   0x0800
 

Definition at line 2829 of file awkgram.c.

Referenced by yylex().

#define SLASH_BEFORE_EQUAL   300
 

Definition at line 144 of file awkgram.c.

Referenced by yylex().

#define SLOP   128
 

Referenced by get_src_buf().

#define SMART_ALECK   1
 

Referenced by yylex().

#define tokadd  )     (*tok++ = (x), tok == tokend ? tokexpand() : tok)
 

Definition at line 3189 of file awkgram.c.

Referenced by yylex().

#define UNARY   301
 

Definition at line 145 of file awkgram.c.

#define VERSION_MASK   0xFF00
 

Definition at line 2825 of file awkgram.c.

#define YNUMBER   262
 

Definition at line 106 of file awkgram.c.

Referenced by yylex().

#define YSTRING   263
 

Definition at line 107 of file awkgram.c.

Referenced by yylex().

#define YY_REDUCE_PRINT Rule   ) 
 

Definition at line 1128 of file awkgram.c.

#define YY_STACK_PRINT Bottom,
Top   ) 
 

Definition at line 1127 of file awkgram.c.

#define YYABORT   goto yyabortlab
 

Definition at line 982 of file awkgram.c.

Referenced by yyparse().

#define YYACCEPT   goto yyacceptlab
 

Definition at line 981 of file awkgram.c.

Referenced by yyparse().

#define YYBACKUP Token,
Value   ) 
 

Value:

do                                                              \
  if (yychar == YYEMPTY && yylen == 1)                          \
    {                                                           \
      yychar = (Token);                                         \
      yylval = (Value);                                         \
      yytoken = YYTRANSLATE (yychar);                           \
      YYPOPSTACK;                                               \
      goto yybackup;                                            \
    }                                                           \
  else                                                          \
    {                                                           \
      yyerror ("syntax error: cannot back up");\
      YYERROR;                                                  \
    }                                                           \
while (0)

Definition at line 993 of file awkgram.c.

#define YYBISON   1
 

Definition at line 37 of file awkgram.c.

#define yyclearin   (yychar = YYEMPTY)
 

Definition at line 977 of file awkgram.c.

#define YYCOPY To,
From,
Count   ) 
 

Value:

do                                      \
        {                                       \
          register YYSIZE_T yyi;                \
          for (yyi = 0; yyi < (Count); yyi++)   \
            (To)[yyi] = (From)[yyi];            \
        }                                       \
      while (0)

Definition at line 335 of file awkgram.c.

#define YYDEBUG   0
 

Definition at line 238 of file awkgram.c.

#define YYDEBUG_LEXER_TEXT   (lexeme)
 

Definition at line 204 of file awkgram.c.

#define YYDPRINTF Args   ) 
 

Definition at line 1124 of file awkgram.c.

Referenced by yyparse().

#define YYDSYMPRINT Args   ) 
 

Definition at line 1125 of file awkgram.c.

#define YYDSYMPRINTF Title,
Token,
Value,
Location   ) 
 

Definition at line 1126 of file awkgram.c.

#define YYEMPTY   (-2)
 

Definition at line 978 of file awkgram.c.

Referenced by yyparse().

#define YYEOF   0
 

Definition at line 979 of file awkgram.c.

Referenced by yyparse().

#define YYERRCODE   256
 

Definition at line 1011 of file awkgram.c.

#define yyerrok   (yyerrstatus = 0)
 

Definition at line 976 of file awkgram.c.

#define YYERROR   goto yyerrlab1
 

Definition at line 983 of file awkgram.c.

#define YYERROR_VERBOSE   0
 

Definition at line 246 of file awkgram.c.

#define YYFAIL   goto yyerrlab
 

Definition at line 989 of file awkgram.c.

#define YYFINAL   5
 

Definition at line 371 of file awkgram.c.

Referenced by yyparse().

#define YYINITDEPTH   200
 

Definition at line 1134 of file awkgram.c.

Referenced by yyparse().

#define YYLAST   1008
 

Definition at line 373 of file awkgram.c.

Referenced by yyparse().

#define YYLEX   yylex ()
 

Definition at line 1029 of file awkgram.c.

Referenced by yyparse().

#define YYLLOC_DEFAULT Current,
Rhs,
 ) 
 

Value:

Current.first_line   = Rhs[1].first_line;      \
  Current.first_column = Rhs[1].first_column;    \
  Current.last_line    = Rhs[N].last_line;       \
  Current.last_column  = Rhs[N].last_column;

Definition at line 1017 of file awkgram.c.

Referenced by yyparse().

#define YYLSP_NEEDED   0
 

Definition at line 46 of file awkgram.c.

#define YYMAXDEPTH   10000
 

Definition at line 1149 of file awkgram.c.

Referenced by yyparse().

#define YYMAXUTOK   301
 

Definition at line 386 of file awkgram.c.

#define YYNNTS   53
 

Definition at line 378 of file awkgram.c.

#define YYNRULES   155
 

Definition at line 380 of file awkgram.c.

#define YYNSTATES   293
 

Definition at line 382 of file awkgram.c.

#define YYNTOKENS   67
 

Definition at line 376 of file awkgram.c.

#define YYPACT_NINF   -236
 

Definition at line 663 of file awkgram.c.

#define YYPOPSTACK   (yyvsp--, yyssp--)
 

#define YYPURE   0
 

Definition at line 43 of file awkgram.c.

 
#define YYRECOVERING  )     (!!yyerrstatus)
 

Definition at line 991 of file awkgram.c.

#define YYSIZE_T   unsigned int
 

Definition at line 973 of file awkgram.c.

Referenced by yyparse().

#define YYSKELETON_NAME   "yacc.c"
 

Definition at line 40 of file awkgram.c.

#define YYSTACK_ALLOC   malloc
 

Definition at line 302 of file awkgram.c.

Referenced by yyparse().