index 1bc106418052659854e49dbda93c54c876ba8669..e9c95864ed71c5c23d5bc53439d5e4206428e608 100644 (file)
 /* -*-c-*- ------------------ mix_eval_scanner.l :
 * scanner used by mix_eval_t
 * ------------------------------------------------------------------
- * Last change: Time-stamp: <01/04/01 15:08:21 jose>
+ * $Id: mix_eval_scanner.l,v 1.3 2004年08月02日 08:53:54 jao Exp $
 * ------------------------------------------------------------------
- * Copyright (C) 2000 Free Software Foundation, Inc.
- *
+ * Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+ *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
- *
+ *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
- *
+ *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
+ *
 */
 %{
 #define YY_DECL                            \
  mix_eval_result_t mix_eval_expr (mix_eval_data_ *data)
-/* keep track of current position in buffer */
+/* keep track of current position in buffer */
 #define YY_USER_ACTION yypos += yyleng;
 #define RETURN_STATE(err)           \
   g_free (expr_cp);             \
 } while (FALSE)
-static mix_word_t
- eval_binop_ (const gchar *op, mix_word_t x, mix_word_t y);
- 
-static int
- unput_word_ (mix_word_t word);
- 
+static mix_word_t eval_binop_ (const gchar *op, mix_word_t x, mix_word_t y);
+
+static int unput_word_ (mix_word_t word);
+
+/*  { */
+/*   gchar *value; */
+/*   gint k, result; */
+/*   value = g_strdup_printf ("%s%ld", */
+/*               mix_word_is_negative (word)? "-":"+", */
+/*               mix_word_magnitude (word)); */
+/*   result = strlen (value); */
+/*   for (k = result - 1; k >= 0; --k) */
+/*    unput (value[k]); */
+/*   g_free (value); */
+/*   return result; */
+/*  } */
+
 %}
 %option nomain
 %option caseless
-%option pointer
+%option array
 %option stack
 %option noyywrap
 %option noyy_top_state
 expr  [+-]?{atexpr}({binop}{1}{atexpr})*
 fpart  \({expr}\)
 wexpr  {expr}({fpart})?(,{expr}({fpart})?)*
- 
+
 %%
@@ -98,7 +109,7 @@ wexpr  {expr}({fpart})?(,{expr}({fpart})?)* 
  buffer = yy_scan_string (expr_cp);
  data->errpos = -1;
 %}
- 
+
 <*><<EOF>> {
  CLEAN_UP ();
@@ -126,7 +137,7 @@ wexpr  {expr}({fpart})?(,{expr}({fpart})?)* 
    data->errpos = yypos;
   return state;
  }
-}
+}
 <WEVAL>{
  {number}"(" {
  }
  {number}")" {
   glong val = atol (yytext);
-  if ( !is_fp ) {
+  if ( !is_fp ) {
    RETURN_STATE (MIX_EVAL_MIS_PAREN);
-  } else if ( val < 0 || val > MIX_BYTE_MAX
+  } else if ( val < 0 || val > MIX_BYTE_MAX
     || !mix_fspec_is_valid (mix_byte_new (val)) ) {
    RETURN_STATE (MIX_EVAL_INV_FSPEC);
   } else {
    is_fp = FALSE;
    wexpr_val = mix_word_store_field (mix_byte_new (val),
-                    wexpr_val_tmp,
+                    wexpr_val_tmp,
                    wexpr_val);
   }
  }
   if ( !mix_symbol_table_is_defined (data->table, s) ) {
    RETURN_STATE (MIX_EVAL_UNDEF_SYM);
   }
-  expr_val = eval_binop_ (yytext, expr_val,
+  expr_val = eval_binop_ (yytext, expr_val,
              mix_symbol_table_value (data->table, s));
  }
  {binop}"*" {
-  expr_val = eval_binop_ (yytext, expr_val,
+  expr_val = eval_binop_ (yytext, expr_val,
              mix_short_to_word_fast (data->loc));
  }
  "*" yypos -= unput_word_ (mix_short_to_word_fast (data->loc));
@@ -207,7 +218,7 @@ wexpr  {expr}({fpart})?(,{expr}({fpart})?)* 
   yypos -= unput_word_ (expr_val);
   yy_pop_state ();
  }
- 
+
  .  RETURN_STATE (MIX_EVAL_SYNTAX);
 }
@@ -220,8 +231,8 @@ eval_binop_ (const gchar *op, mix_word_t x, mix_word_t y) 
  mix_word_t result = MIX_WORD_ZERO;
  switch (op[0])
   {
-  case '+':
-   result = mix_word_add (x,y);
+  case '+':
+   result = mix_word_add (x,y);
    break;
   case '-':
    result = mix_word_sub (x,y);
@@ -249,18 +260,17 @@ eval_binop_ (const gchar *op, mix_word_t x, mix_word_t y) 
  return result;
 }
-
 static int
-unput_word_ (mix_word_t word)
-{
- gchar *value;
- gint k, result;
- value = g_strdup_printf ("%s%ld",
-             mix_word_is_negative (word)? "-":"+",
-             mix_word_magnitude (word));
+unput_word_ (mix_word_t word)
+{
+ gchar *value;
+ gint k, result;
+ value = g_strdup_printf ("%s%ld",
+             mix_word_is_negative (word)? "-":"+",
+             mix_word_magnitude (word));
  result = strlen (value);
- for (k = result - 1; k >= 0; --k)
-  unput (value[k]);
+ for (k = result - 1; k >= 0; --k)
+  unput (value[k]);
  g_free (value);
  return result;
 }
 
index fcd6054e43f0d4c7dd784cf3babff305680d933c..e85b6c892570988657b4848e839ed1023b786e70 100644 (file)
  } while (FALSE)
-static mix_word_t
-eval_binop_ (const gchar *op, mix_word_t x, mix_word_t y);
-
-static void yyunput(int, char*);
+static mix_word_t eval_binop_ (const gchar *op, mix_word_t x, mix_word_t y);
-static void
-unput_word_ (mix_word_t word)
- {
-  gchar *value;
-  gint k;
-  value = g_strdup_printf ("%s%ld",
-              mix_word_is_negative (word)? "-":"+",
-              mix_word_magnitude (word));
-  for (k = strlen (value) - 1; k >= 0; --k)
-   unput (value[k]);
-  g_free (value);
- }
+static void unput_word_ (mix_word_t word);
 %}
 %option nomain
 %option caseless
-%option pointer
+%option array
 %option stack
 %option noyywrap
 %option noyy_top_state
@@ -557,3 +543,15 @@ eval_binop_ (const gchar *op, mix_word_t x, mix_word_t y) 
  return result;
 }
+static void
+unput_word_ (mix_word_t word)
+{
+ gchar *value;
+ gint k;
+ value = g_strdup_printf ("%s%ld",
+              mix_word_is_negative (word)? "-":"+",
+              mix_word_magnitude (word));
+ for (k = strlen (value) - 1; k >= 0; --k)
+  unput (value[k]);
+ g_free (value);
+}