/[global]/global/gctags/reserved.pl
ViewVC logotype

Diff of /global/gctags/reserved.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by shigio, Wed Oct 6 04:27:05 2004 UTC revision 1.13 by shigio, Thu Oct 7 15:46:59 2004 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl  #!/usr/bin/perl
2  #  #
3  # Copyright (c) 2003 Tama Communications Corporation  # Copyright (c) 2003, 2004 Tama Communications Corporation
4  #  #
5  # This file is part of GNU GLOBAL.  # This file is part of GNU GLOBAL.
6  #  #
# Line 151  print "#define START_VARIABLE\t$n_variab Line 151  print "#define START_VARIABLE\t$n_variab
151  print "#define START_WORD\t$n_word\n";  print "#define START_WORD\t$n_word\n";
152  print "#define START_SHARP\t$n_sharp\n";  print "#define START_SHARP\t$n_sharp\n";
153  print "#define START_YACC\t$n_yacc\n";  print "#define START_YACC\t$n_yacc\n";
154  print "#define IS_RESERVED(a)   ((a) >= START_WORD)\n";  print "#define IS_RESERVED_WORD(a)      ((a) >= START_WORD)\n";
155  print "#define IS_RESERVED_VARIABLE(a)  ((a) >= START_VARIABLE && (a) < START_WORD)\n";  print "#define IS_RESERVED_VARIABLE(a)  ((a) >= START_VARIABLE && (a) < START_WORD)\n";
156  print "#define IS_RESERVED_SHARP(a)     ((a) >= START_SHARP && (a) < START_YACC)\n";  print "#define IS_RESERVED_SHARP(a)     ((a) >= START_SHARP && (a) < START_YACC)\n";
157  print "#define IS_RESERVED_YACC(a)      ((a) >= START_YACC)\n";  print "#define IS_RESERVED_YACC(a)      ((a) >= START_YACC)\n";
# Line 222  while(<IP>) { Line 222  while(<IP>) {
222  }  }
223  close(IP);  close(IP);
224  print "%%\n";  print "%%\n";
225  print "static int reserved_word(const char *, int);\n";  #
226  print "static int\n";  # Generate reserved_xxxx() procedures.
227  print "reserved_word(str, len)\n";  #
228  print "const char *str;\n";  sub generate_procedure {
229  print "int len;\n";          local($type) = @_;
230  print "{\n";          local($TYPE) = $type;
231  print "\tstruct keyword *keyword = ${pre}_lookup(str, len);\n";  
232  print "\tint n = keyword ? keyword->token : 0;\n";          $TYPE =~ tr/a-z/A-Z/;
233  print "\treturn IS_RESERVED(n) ? n : 0;\n";          print "static int reserved_${type}(const char *, int);\n";
 print "}\n";  
 if ($n_variable > $START_VARIABLE) {  
         print "static int reserved_variable(const char *, int);\n";  
234          print "static int\n";          print "static int\n";
235          print "reserved_variable(str, len)\n";          print "reserved_${type}(str, len)\n";
236          print "const char *str;\n";          print "const char *str;\n";
237          print "int len;\n";          print "int len;\n";
238          print "{\n";          print "{\n";
239          print "\tstruct keyword *keyword = ${pre}_lookup(str, len);\n";          print "\tstruct keyword *keyword = ${pre}_lookup(str, len);\n";
240          print "\tint n = keyword ? keyword->token : 0;\n";          print "\tint n = keyword ? keyword->token : 0;\n";
241          print "\treturn IS_RESERVED_VARIABLE(n) ? n : 0;\n";          print "\treturn IS_RESERVED_${TYPE}(n) ? n : 0;\n";
242          print "}\n";          print "}\n";
243  }  }
244    if ($n_word > $START_WORD) {
245            generate_procedure('word');
246    }
247    if ($n_variable > $START_VARIABLE) {
248            generate_procedure('variable');
249    }
250  if ($n_sharp > $START_SHARP) {  if ($n_sharp > $START_SHARP) {
251          print "static int reserved_sharp(const char *, int);\n";          generate_procedure('sharp');
         print "static int\n";  
         print "reserved_sharp(str, len)\n";  
         print "const char *str;\n";  
         print "int len;\n";  
         print "{\n";  
         print "\tstruct keyword *keyword = ${pre}_lookup(str, len);\n";  
         print "\tint n = keyword ? keyword->token : 0;\n";  
         print "\treturn IS_RESERVED_SHARP(n) ? n : 0;\n";  
         print "}\n";  
252  }  }
253  if ($n_yacc > $START_YACC) {  if ($n_yacc > $START_YACC) {
254          print "static int reserved_yacc(const char *, int);\n";          generate_procedure('yacc');
         print "static int\n";  
         print "reserved_yacc(str, len)\n";  
         print "const char *str;\n";  
         print "int len;\n";  
         print "{\n";  
         print "\tstruct keyword *keyword = ${pre}_lookup(str, len);\n";  
         print "\tint n = keyword ? keyword->token : 0;\n";  
         print "\treturn IS_RESERVED_YACC(n) ? n : 0;\n";  
         print "}\n";  
255  }  }
256  exit 0;  exit 0;

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26