diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2004-08-02 08:53:54 +0000 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2004-08-02 08:53:54 +0000 |
commit | 3e85147e26d0938d63473e362abb2cd0caaa37a3 (patch) | |
tree | d9340054d12ba771cafc4af695d566a78dc1e27e /mixlib | |
parent | 720f9140a04718cc0f4d89cc3e2d8b49eda44464 (diff) | |
download | mdk-3e85147e26d0938d63473e362abb2cd0caaa37a3.tar.gz mdk-3e85147e26d0938d63473e362abb2cd0caaa37a3.tar.bz2 |
minor quibbles
Diffstat (limited to 'mixlib')
-rw-r--r-- | mixlib/mix_eval_scanner.l | 80 | ||||
-rw-r--r-- | mixlib/mix_scanner.l | 32 |
2 files changed, 60 insertions, 52 deletions
diff --git a/mixlib/mix_eval_scanner.l b/mixlib/mix_eval_scanner.l index 1bc1064..e9c9586 100644 --- a/mixlib/mix_eval_scanner.l +++ b/mixlib/mix_eval_scanner.l @@ -1,24 +1,24 @@ /* -*-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. - * + * */ %{ @@ -29,7 +29,7 @@ #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) \ @@ -45,17 +45,28 @@ 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 @@ -80,7 +91,7 @@ atexpr {digit}+|{symbol}|\* 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}"(" { @@ -135,15 +146,15 @@ wexpr {expr}({fpart})?(,{expr}({fpart})?)* } {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); } } @@ -187,11 +198,11 @@ wexpr {expr}({fpart})?(,{expr}({fpart})?)* 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; } diff --git a/mixlib/mix_scanner.l b/mixlib/mix_scanner.l index fcd6054..e85b6c8 100644 --- a/mixlib/mix_scanner.l +++ b/mixlib/mix_scanner.l @@ -106,29 +106,15 @@ } 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); +} |