changeset 972:3e25eb05b6c6

[project @ 1994-12-12 15:53:47 by jwe]
author jwe
date Mon, 12 Dec 1994 15:53:47 +0000
parents fe71abb43457
children 46673c918034
files src/lex.l
diffstat 1 files changed, 28 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/lex.l
+++ b/src/lex.l
@@ -109,6 +109,7 @@
 static int next_token_is_bin_op (int spc_prev, char *yytext);
 static int next_token_is_postfix_unary_op (int spc_prev, char *yytext);
 static char *strip_trailing_whitespace (char *s);
+static void handle_number (char *yytext);
 static int handle_close_brace (char *yytext);
 static int handle_identifier (char *s, int next_tok_is_eq);
 
@@ -404,19 +405,7 @@
 %}
 
 {NUMBER}{Im} {
-    double value;
-    int nread = sscanf (yytext, "%lf", &value);
-    assert (nread == 1);
-    quote_is_transpose = 1;
-    cant_be_identifier = 1;
-    convert_spaces_to_comma = 1;
-    if (plotting && ! in_plot_range)
-      past_plot_range = 1;
-    yylval.tok_val = new token (value, yytext, input_line_number,
-				current_input_column);
-    token_stack.push (yylval.tok_val);
-    current_input_column += yyleng;
-    do_comma_insert_check ();
+    handle_number (yytext);
     return IMAG_NUM;
   }
 
@@ -427,19 +416,7 @@
 
 {D}+/\.[\*/\\^'] |
 {NUMBER} {
-    double value;
-    int nread = sscanf (yytext, "%lf", &value);
-    assert (nread == 1);
-    quote_is_transpose = 1;
-    cant_be_identifier = 1;
-    convert_spaces_to_comma = 1;
-    if (plotting && ! in_plot_range)
-      past_plot_range = 1;
-    yylval.tok_val = new token (value, yytext, input_line_number,
-				current_input_column);
-    token_stack.push (yylval.tok_val);
-    current_input_column += yyleng;
-    do_comma_insert_check ();
+    handle_number (yytext);
     return NUM;
   }
 
@@ -1413,6 +1390,31 @@
   return retval;
 }
 
+static void
+handle_number (char *yytext)
+{
+  double value;
+  int nread = sscanf (yytext, "%lf", &value);
+
+  assert (nread == 1);
+
+  quote_is_transpose = 1;
+  cant_be_identifier = 1;
+  convert_spaces_to_comma = 1;
+
+  if (plotting && ! in_plot_range)
+    past_plot_range = 1;
+
+  yylval.tok_val = new token (value, yytext, input_line_number,
+			      current_input_column);
+
+  token_stack.push (yylval.tok_val);
+
+  current_input_column += yyleng;
+
+  do_comma_insert_check ();
+}
+
 static int
 handle_close_brace (char *yytext)
 {