⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ytab.c

📁 这是一个C程序分析工具
💻 C
📖 第 1 页 / 共 5 页
字号:
   fprintf(out_fp, "METRE Version %s  ", metre_version);   fputs("Copyright (c) 1993-1995 by Paul Long  All rights reserved.\n", out_fp);}/* Print Metre command-usage information. */static void print_help(void){   fprintf(out_fp, "Syntax: %s [ option | file ]...\n", command_name);   fprintf(out_fp, "-%cxxx=[xxx] Define identifier          "         "-%cxxx       Name of output file\n",         DEFINE_OPT_CHAR, LISTING_OPT_CHAR);   fprintf(out_fp, "-%cxxx       Substitute file name       "         "-%c          Copy input to output\n",         SUBST_FILE_OPT_CHAR, COPY_INPUT_OPT_CHAR);   fprintf(out_fp, "-%c          Suppress warnings          "         "-%c          This help\n", NO_WARNINGS_OPT_CHAR, HELP_OPT_CHAR);   fprintf(out_fp, "-%cxxx       Response file\n", SCRIPT_FILE_OPT_CHAR);   /* Fire the project-help trigger. */   ZERO(int_prj);   int_prj.help = TRUE;   fire_prj();   int_prj.help = FALSE;}/* Called at the beginning of a function definition. */static void stat_func_begin(void){   /* Fire the beginning-of-function trigger. */   ZERO(int_fcn);   int_fcn.begin = TRUE;   fire_fcn();   int_fcn.begin = FALSE;   /* Initialize variables relating to a function. */   depth = 0;   is_within_function = TRUE;   fcn_decisions = 0;   fcn_conditions = 0;   previous_statements_line_number = 0;   /* Install starting counts. Replaced with deltas at end-of-function. */   int_fcn.lines.white = int_mod.lines.white;   int_fcn.lines.com = int_mod.lines.com;   int_fcn.lines.code = int_mod.lines.code;   int_fcn.lines.total = lineno();}/* Called at the end of a function definition. */static void stat_func_end(void){   /*      Replace initial counts with their deltas to arrive at totals for      the function.   */   int_fcn.lines.white = int_mod.lines.white - int_fcn.lines.white;   int_fcn.lines.com = int_mod.lines.com - int_fcn.lines.com;   int_fcn.lines.code = int_mod.lines.code - int_fcn.lines.code;   int_fcn.lines.total = lineno() - int_fcn.lines.total;   ++mod_functions;                 /* Increment function count. */   /* Accumulate function decision and condition counts into module counts. */   mod_decisions += fcn_decisions;   mod_conditions += fcn_conditions;   /*      Install the rest of the function-related information into the      function structure and fire the end-of-function trigger.   */   int_fcn.decisions = fcn_decisions;   int_fcn.conditions = fcn_conditions;   int_fcn.end = TRUE;   fire_fcn();   ZERO(int_fcn);   /*      Clear variables that would otherwise indicate that we are still      parsing a function.   */   strcpy(function_name, "");   is_within_function = FALSE;}/*   Returns pointer to current function name, or an empty string if not   in a function.*/char *fcn_name(void){   return function_name;}/*   Increment the number of statements for the current line. This   function is called whenever a statement is encountered. If the   current line number is the same as when the last statement was   encountered and if this is not the special situation of "else if,"   the counter is incremented.*/static void check_multiple_statements(void){   if (previous_statements_line_number == lineno())      if (is_else && is_if)         ;        /* do nothing */      else         ++int_lin.statements;   else      previous_statements_line_number = lineno();   is_else = is_if = FALSE;}/*   This is true for all of the fire_*() functions: Copy the internal   structure to the exported structure, allow the triggers to fire in   the rules() function, then zero-fill the exported structure so that   unrelated rules won't execute when other triggers are fired.*/void fire_prj(void){   prj = int_prj;   rules();   ZERO(prj);}void fire_mod(void){   mod = int_mod;   rules();   ZERO(mod);}static void fire_fcn(void){   fcn = int_fcn;   rules();   ZERO(fcn);}static void fire_stm(void){   stm = int_stm;   rules();   ZERO(stm);}void fire_lin(void){   lin = int_lin;   rules();   ZERO(lin);}void fire_lex(void){   lex = int_lex;   rules();   ZERO(lex);}void fire_grm(void){   grm = int_grm;   rules();   ZERO(grm);}/* Fire the operator trigger. */static void fire_operator(void){   current_operator = token();   int_grm.is_operator = TRUE;   fire_grm();   int_grm.is_operator = FALSE;   current_operator = "";}/* Fire the keyword trigger. */static void fire_keyword(void){   current_keyword = token();   int_grm.is_keyword = TRUE;   fire_grm();   int_grm.is_keyword = FALSE;   current_keyword = "";}/* Fire the identifier trigger. */static void fire_identifier(void){   current_identifier = token();   int_grm.is_identifier = TRUE;   fire_grm();   int_grm.is_identifier = FALSE;   current_identifier = "";}/* Fire the declarator trigger. */static void fire_declarator(void){   int_grm.is_declarator = TRUE;   fire_grm();   int_grm.is_declarator = FALSE;}/* Fire the type-name trigger. */static void fire_type_name(void){   current_type_name = token();   int_grm.is_type_name = TRUE;   fire_grm();   int_grm.is_type_name = FALSE;   current_type_name = "";}/* Fire the grammar trigger with is_constant set to TRUE. */static void found_constant(void){   int_grm.is_constant = TRUE;   fire_grm();   ZERO(int_grm);}/* Fire the grammar trigger with is_string set to TRUE. */static void found_string(void){   int_grm.is_string = TRUE;   fire_grm();   ZERO(int_grm);}/* Indicate a function call. */static void function_call(void){   int_grm.is_call = TRUE;   fire_grm();   ZERO(int_grm);}/* Indicate an expression statement. Can be empty, i.e. just ";". */static void found_expression_statement(BOOLEAN is_empty){   check_multiple_statements();   ++int_fcn.low;          /* Low-level statement. */   /* Used to consider adjacent case labels as one decision point. */   not_case_label();   /*      Indicate at the end of an expression, low-level statement, whether      an empty expression, then fire the end-of-statement trigger.   */   int_stm.is_expr = int_stm.is_low = int_stm.end = TRUE;   int_stm.is_empty_expr = is_empty;   int_stm.depth = depth;   fire_stm();   ZERO(int_stm);}/* Return whether the specified operator is the current operator. */BOOLEAN oper(char *op){   return grm.is_operator && strcmp(current_operator, op) == 0;}/* Return whether the specified keyword is the current keyword. */BOOLEAN keyword(char *name){   return grm.is_keyword && strcmp(current_keyword, name) == 0;}/* Return whether the specified identifier is the current identifier. */BOOLEAN identifier(char *name){   return grm.is_identifier && strcmp(current_identifier, name) == 0;}/*   Indicate the beginning of the declarations within a compound   statement, whether or not there were any, and the depth at which they   occured.*/static void before_compound_declarations(void){   int_stm.before_compound_declarations = TRUE;   int_stm.depth = depth;   fire_stm();   ZERO(int_stm);}/*   Indicate the end of the declarations within a compound statement,   whether or not there were any, and the depth at which they occured.*/static void after_compound_declarations(void){   int_stm.after_compound_declarations = TRUE;   int_stm.depth = depth;   fire_stm();   ZERO(int_stm);}/*   Indicate the beginning of an initializer (before the "=") and the   depth at which it occurs.*/static void before_initializer(void){   int_stm.before_initializer = TRUE;   int_stm.depth = depth;   fire_stm();   ZERO(int_stm);}/* Indicate the end of an initializer and the depth at which it occured. */static void after_initializer(void){   int_stm.after_initializer = TRUE;   int_stm.depth = depth;   fire_stm();   ZERO(int_stm);}/*   Return pointer to identifier that corresponds to when grammar   identifier trigger is fired.*/char *this_identifier(void){   return current_identifier;}/* Return pointer to last-encountered identifier. */char *last_identifier(void){   return last_ident;}/* Return pointer to last-encountered declarator. */char *last_declarator(void){   return last_decl;}/*   When prj.cmd_name is true, a rule may provide the name of the command   that invokes this program. The default is "METRE".*/void cmd_name(char *name){   if (name != NULL)      command_name = name;}/* Return command-line argument count. */int argc(void){   return cmd_line_argc;}/* Return pointer to command-line-argument array. */char **argv(void){   return cmd_line_argv;}static short yydef[] = {	  -1,  287,  300,  302,   -5,  -21,  -37,  299,  301,  -41, 	 -47,  -51,  -55,  -63,  308,  310,  312,  314,  316,  318, 	 321,  326,  329,  332,  333,  334,  303,  -67,  -71,  298, 	 296,  297,  -79,  295,  174,  -83,  148,  293,  294,  313, 	 315,  317,  319,  320,  322,  323,  324,  325,  327,  328, 	 330,  331,  294,  304,  289,  -87,  292,  309,  311,  -91, 	 -95,  291};static short yyex[] = {	   0,  288,   -1,    1,  257,  306,   40,  306,   41,  306, 	  91,  306,   44,  306,   42,  306,   59,  306,   -1,    6, 	 257,  307,   40,  307,   41,  307,   91,  307,   44,  307, 	  42,  307,   59,  307,   -1,    5,    0,    0,   -1,    1, 	 257,   14,   41,   12,   -1,   13,  123,   10,   -1,   11, 	 123,    8,   -1,    9,   44,  305,   61,    7,   59,  305, 	  -1,   19,  125,   15,   -1,   16,  125,   17,   -1,   18, 	  44,  305,   61,    7,   59,  305,   -1,    1,   41,    3, 	  -1,    4,   59,  290,   -1,    1,   59,  290,   -1,    1, 	  41,  290,   -1,    1,   41,  290,   -1,    1};static short yyact[] = {	-330, -319, -249, -267, -286, -285, -284, -283, -282, -281, 	-280, -279, -278, -277, -276, -275, -274, -273, -272, -271, 	-270, -269, -268,  301,  300,  299,  298,  297,  296,  295, 	 294,  293,  292,  291,  290,  289,  288,  287,  286,  285, 	 284,  283,  282,  257,   42,   40, -319, -267, -281, -280, 	-279, -278, -277, -276, -275, -274, -273, -272, -271, -270, 	-269, -268,  301,  300,  299,  298,  297,  296,  295,  294, 	 293,  292,  291,  290,  289,  288,  282,   42, -330, -319, 	-249,  257,   42,   40, -330, -249,  257,   40, -330, -328, 	  91,   40, -266, -249,  257,  123, -330, -319, -287, -249, 	 257,   59,   42,   40, -266, -267, -286, -285, -284, -283, 	-282, -281, -280, -279, -278, -277, -276, -275, -274, -273, 	-272, -271, -270, -269, -268,  301,  300,  299,  298,  297, 	 296,  295,  294,  293,  292,  291,  290,  289,  288,  287, 	 286,  285,  284,  283,  282,  123, -329,   41, -315, -320, 	-330, -319, -318, -317, -327, -316, -249, -250, -251, -321, 	-324, -323,  263,  262,  260,  259,  258,  257,  126,   93, 	  45,   43,   42,   40,   38,   33, -249,  257, -267, -286, 	-285, -284, -283, -282, -281, -280, -279, -278, -277, -276, 	-275, -274, -273, -272, -271, -270, -269, -268,  301,  300, 	 299,  298,  297,  296,  295,  294,  293,  292,  291,  290, 	 289,  288,  287,  286,  285,  284,  283,  282, -322, -287, 	  59,   44, -327,   93, -300, -301,  271,   63, -302,  270, 	-303,  124, -304,   94, -320,   38, -306, -305,  269,  268, 	-310, -309, -308, -307,  267,  266,   62,   60, -312, -311, 	 265,  264, -318, -317,   45,   43, -313, -319, -314,   47, 	  42,   37, -315, -320, -330, -319, -318, -317, -316, -249, 	-250, -251, -321, -324, -323,  263,  262,  260,  259,  258, 	 257,  126,   45,   43,   42,   40,   38,   33, -330, -326, 	-328, -325, -324, -323,  263,  262,  261,   91,   46,   40, 	-315, -320, -330, -319, -318, -317, -316, -249, -250, -251, 	-321, -324, -323, -267, -281, -280, -279, -278, -277, -276, 	-275, -274, -273, -272, -271, -270, -269, -268,  301,  300, 	 299,  298,  297,  296,  295,  294,  293,  292,  291,  290, 	 289,  288,  282,  263,  262,  260,  259,  258,  257,  126, 	  45,   43,   42,   40,   38,   33, -251,  259, -298,   61, 	-322, -265,  125,   44, -266,  123, -267, -281, -280, -279, 	-278, -277, -276, -275, -274, -273, -272, -271, -270, -269, 	-268,  301,  300,  299,  298,  297,  296,  295,  294,  293, 	 292,  291,  290,  289,  288,  282, -315, -320, -330, -319, 	-318, -317, -287, -266, -316, -249, -250, -251, -321, -324, 	-323, -263, -262, -261, -260, -258, -257, -256, -255, -254, 	-253, -252,  315,  314,  313,  312,  311,  310,  309,  308, 	 306,  305,  304,  263,  262,  260,  259,  258,  257,  126, 	 123,   59,   45,   43,   42,   40,   38,   33, -265,  125, 	-322,   44, -330, -319, -328, -249,  257,   91,   42,   40, 	-330, -319, -328, -267, -281, -280, -279, -278, -277, -276, 	-275, -274, -273, -272, -271, -270, -269, -268,  301,  300, 	 299,  298,  297,  296,  295,  294,  293,  292,  291,  290, 	 289,  288,  282,   91,   42,   40, -298, -297, -296, -295, 	-294, -293, -292, -291, -290, -289, -288,  281,  280,  279, 	 278,  277,  276,  275,  274,  273,  272,   61, -329, -322, 	  44,   41, -265, -249,  257,  125, -330, -319, -299, -249, 	-267, -281, -280, -279, -278, -277, -276, -275, -274, -273, 	-272, -271, -270, -269, -268,  301,  300,  299,  298,  297, 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -