Mercurial > octave-dspies
diff src/lex.l @ 4753:9f0ce1536368
[project @ 2004-02-13 17:55:24 by jwe]
author | jwe |
---|---|
date | Fri, 13 Feb 2004 17:55:24 +0000 |
parents | e1c2d8ca8bc0 |
children | e941e1470d7b |
line wrap: on
line diff
--- a/src/lex.l Sat Feb 07 22:47:38 2004 +0000 +++ b/src/lex.l Fri Feb 13 17:55:24 2004 +0000 @@ -20,6 +20,8 @@ */ +%option prefix = "octave_" + %s COMMAND_START %s MATRIX_START @@ -77,6 +79,75 @@ #error lex.l requires flex version 2.5.4 or later #endif +#define yylval octave_lval + +// Arrange to get input via readline. + +#ifdef YY_INPUT +#undef YY_INPUT +#endif +#define YY_INPUT(buf, result, max_size) \ + if ((result = octave_read (buf, max_size)) < 0) \ + YY_FATAL_ERROR ("octave_read () in flex scanner failed"); + +// Try to avoid crashing out completely on fatal scanner errors. +// The call to yy_fatal_error should never happen, but it avoids a +// `static function defined but not used' warning from gcc. + +#ifdef YY_FATAL_ERROR +#undef YY_FATAL_ERROR +#endif +#define YY_FATAL_ERROR(msg) \ + do \ + { \ + error (msg); \ + OCTAVE_QUIT; \ + yy_fatal_error (msg); \ + } \ + while (0) + +#define TOK_RETURN(tok) \ + do \ + { \ + current_input_column += yyleng; \ + lexer_flags.quote_is_transpose = false; \ + lexer_flags.cant_be_identifier = false; \ + lexer_flags.convert_spaces_to_comma = true; \ + return (tok); \ + } \ + while (0) + +#define TOK_PUSH_AND_RETURN(name, tok) \ + do \ + { \ + yylval.tok_val = new token (name, input_line_number, \ + current_input_column); \ + token_stack.push (yylval.tok_val); \ + TOK_RETURN (tok); \ + } \ + while (0) + +#define BIN_OP_RETURN(tok, convert) \ + do \ + { \ + yylval.tok_val = new token (input_line_number, current_input_column); \ + token_stack.push (yylval.tok_val); \ + current_input_column += yyleng; \ + lexer_flags.quote_is_transpose = false; \ + lexer_flags.cant_be_identifier = true; \ + lexer_flags.convert_spaces_to_comma = convert; \ + return (tok); \ + } \ + while (0) + +#define XBIN_OP_RETURN(tok, convert) \ + do \ + { \ + gripe_matlab_incompatible_operator (yytext); \ + BIN_OP_RETURN (tok, convert); \ + } \ + while (0) + // TRUE means that we have encountered EOF on the input stream. bool parser_end_of_input = false;