octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lex.l compile problem


From: John W. Eaton
Subject: lex.l compile problem
Date: Wed, 13 Oct 1999 15:01:33 -0500 (CDT)

On 13-Oct-1999, A Scott Hodel <address@hidden> wrote:

| 
| Bug report for Octave 2.1.15 configured for alphaev56-dec-osf4.0e
| 
| I took a look at lex.l; here's what I've got: (line 952 is marked with >>>)
| 
|   int l = input_line_number;
|   int c = current_input_column;
| 
|   int len = s.length ();
| 
| >>>  const octave_kw *kw = octave_kw_lookup (s.c_str (), len);
| 
|   if (kw)
|     {
|       yylval.tok_val = 0;
| 
|       switch (kw->kw_id)
|         {
|         case all_va_args_kw:
|         case break_kw:
|         case case_kw:
| 
| I don't see what's causing the problem here.  If nothing comes to mind
| for you right away, let me know and I'll try to dig further.

Is your src/oct-gperf.h file empty?

If so, please try replacing it with the appended file.

I'll fix this for 2.1.16...

jwe


/* C code produced by gperf version 2.5 (GNU C++ version) */
/* Command-line: gperf -a -C -D -E -G -H octave_kw_hash -g -N octave_kw_lookup 
-p -t octave.gperf  */

enum octave_kw_id
{
  all_va_args_kw,
  break_kw,
  case_kw,
  catch_kw,
  continue_kw,
  else_kw,
  elseif_kw,
  end_kw,
  end_try_catch_kw,
  end_unwind_protect_kw,
  endfor_kw,
  endfunction_kw,
  endif_kw,
  endswitch_kw,
  endwhile_kw,
  for_kw,
  function_kw,
  global_kw,
  gplot_kw,
  gsplot_kw,
  if_kw,
  magic_file_kw,
  magic_line_kw,
  otherwise_kw,
  replot_kw,
  return_kw,
  static_kw,
  switch_kw,
  try_kw,
  unwind_protect_kw,
  unwind_protect_cleanup_kw,
  while_kw
};

struct octave_kw { const char *name; int tok; octave_kw_id kw_id; };
/* maximum key range = 48, duplicates = 1 */

#ifdef __GNUC__
inline
#endif
static unsigned int
octave_kw_hash (register const char *str, register int len)
{
  static const unsigned char asso_values[] =
    {
     50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
     50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
     50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
     50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
     50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
     50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
     50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
     50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
     50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
     50, 50, 50, 50, 50, 15, 50, 20,  5, 14,
      0,  0,  0, 15, 15,  0, 50,  0,  5, 50,
     28,  0,  0, 50, 10,  0, 25, 10, 50, 10,
     50,  5, 50, 50, 50, 50, 50, 50,
    };
  return len + asso_values[str[len - 1]] + asso_values[str[0]];
}

static const struct octave_kw wordlist[] =
{
      {"",}, {"",}, 
      {"if",  IF, if_kw},
      {"end",  END, end_kw},
      {"else",  ELSE, else_kw},
      {"endif",  END, endif_kw},
      {"elseif",  ELSEIF, elseif_kw},
      {"endwhile",  END, endwhile_kw},
      {"otherwise",  OTHERWISE, otherwise_kw},
      {"break",  BREAK, break_kw},
      {"for",  FOR, for_kw},
      {"while",  WHILE, while_kw},
      {"endfor",  END, endfor_kw},
      {"case",  CASE, case_kw},
      {"static",  STATIC, static_kw},
      {"switch",  SWITCH, switch_kw},
      {"continue",  CONTINUE, continue_kw},
      {"endswitch",  END, endswitch_kw},
      {"global",  GLOBAL, global_kw},
      {"end_try_catch",  END, end_try_catch_kw},
      {"all_va_args",  ALL_VA_ARGS, all_va_args_kw},
      {"unwind_protect_cleanup",  CLEANUP, unwind_protect_cleanup_kw},
      {"try",  TRY, try_kw},
      {"catch",  CATCH, catch_kw},
      {"function",  FCN, function_kw},
      {"__FILE__",  TEXT, magic_file_kw},
      {"__LINE__",  NUM, magic_line_kw},
      {"endfunction",  END, endfunction_kw},
      {"replot",  PLOT, replot_kw},
      {"end_unwind_protect",  END, end_unwind_protect_kw},
      {"return",  FUNC_RET, return_kw},
      {"gplot",  PLOT, gplot_kw},
      {"gsplot",  PLOT, gsplot_kw},
      {"unwind_protect",  UNWIND, unwind_protect_kw},
};

static const char gperf_lookup[] =
{
       -1, -1,  2,  3,  4,  5,  6, -1,  7,  8,  9, -1, -1, 10,
       -1, 11, 12, -1, 13, -1, 14, 15, 16, -1, 17, -1, 18, -1,
       19, -1, -1, 20, 21, 22, 23, -1, 24, -1, 58, 27, -1, 28,
       -1, 29, 30, 31, 32,-25, -2, 33,
};

#ifdef __GNUC__
inline
#endif
const struct octave_kw *
octave_kw_lookup (register const char *str, register int len)
{
  enum
    {
      TOTAL_KEYWORDS = 32,
      MIN_WORD_LENGTH = 2,
      MAX_WORD_LENGTH = 22,
      MIN_HASH_VALUE = 2,
      MAX_HASH_VALUE = 49,
    };

  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
    {
      register int key = octave_kw_hash (str, len);

      if (key <= MAX_HASH_VALUE && key >= 0)
        {
          register int index = gperf_lookup[key];

          if (index >= 0 && index < MAX_HASH_VALUE)
            {
              register const char *s = wordlist[index].name;

              if (*s == *str && !strcmp (str + 1, s + 1))
                return &wordlist[index];
            }
          else if (index < 0 && index >= -MAX_HASH_VALUE)
            return 0;
          else
            {
              register int offset = key + index + (index > 0 ? -MAX_HASH_VALUE 
: MAX_HASH_VALUE);
              register const struct octave_kw *base = 
&wordlist[-gperf_lookup[offset]];
              register const struct octave_kw *ptr = base + 
-gperf_lookup[offset + 1];

              while (--ptr >= base)
                if (*str == *ptr->name && !strcmp (str + 1, ptr->name + 1))
                  return ptr;
            }
        }
    }
  return 0;
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]