# HG changeset patch # User jwe # Date 787247627 0 # Node ID 3e25eb05b6c69ec0d2994828d4736745d90acac8 # Parent fe71abb4345784cc62d01eb9512ddd4e24e4dd7e [project @ 1994-12-12 15:53:47 by jwe] diff -r fe71abb43457 -r 3e25eb05b6c6 src/lex.l --- a/src/lex.l Mon Dec 12 15:10:22 1994 +0000 +++ b/src/lex.l Mon Dec 12 15:53:47 1994 +0000 @@ -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) {