# HG changeset patch # User jwe # Date 1076694924 0 # Node ID 9f0ce153636804c4dc33bca67c5875378425b67f # Parent 2be826ada7bb88359e50c00c7ea26efb4d16c05e [project @ 2004-02-13 17:55:24 by jwe] diff -r 2be826ada7bb -r 9f0ce1536368 src/ChangeLog --- a/src/ChangeLog Sat Feb 07 22:47:38 2004 +0000 +++ b/src/ChangeLog Fri Feb 13 17:55:24 2004 +0000 @@ -1,3 +1,16 @@ +2004-02-13 John W. Eaton + + * toplev.cc (main_loop): Call octave_parse, not yyparse. + * octave.cc (octave_main): Increment octave_debug, not yydebug. + * parse.y (%name-prefix): New directive, set to "octave_". + * parse.h: Provide declarations for octave_lex and octave_parse + instead of yylex and yyparse. + * lex.l (%option prefix): New directive, set to "_octave". + Define yylval to be octave_lval. + Move definitions of YY_INPUT, YY_FATAL_ERROR, TOK_RETURN, + TOK_PUSH_AND_RETURN, BIN_OP_RETURN, XBIN_OP_RETURN here. + * lex.h: From here. + 2004-02-07 Petter Risholm * ov-struct.cc (Fcell2struct): New function. diff -r 2be826ada7bb -r 9f0ce1536368 src/lex.h --- a/src/lex.h Sat Feb 07 22:47:38 2004 +0000 +++ b/src/lex.h Fri Feb 13 17:55:24 2004 +0000 @@ -23,74 +23,7 @@ #if !defined (octave_lex_h) #define octave_lex_h 1 -// 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) - -// XXX FIXME XXX -- these input buffer things should be members of an +// XXX FIXME XXX -- these input buffer things should be members of a // parser input stream class. typedef struct yy_buffer_state *YY_BUFFER_STATE; diff -r 2be826ada7bb -r 9f0ce1536368 src/lex.l --- 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; diff -r 2be826ada7bb -r 9f0ce1536368 src/octave.cc --- a/src/octave.cc Sat Feb 07 22:47:38 2004 +0000 +++ b/src/octave.cc Fri Feb 13 17:55:24 2004 +0000 @@ -413,7 +413,8 @@ break; case 'd': - yydebug++; + // This is the same as yydebug in parse.y. + octave_debug++; break; case 'f': diff -r 2be826ada7bb -r 9f0ce1536368 src/parse.h --- a/src/parse.h Sat Feb 07 22:47:38 2004 +0000 +++ b/src/parse.h Fri Feb 13 17:55:24 2004 +0000 @@ -30,8 +30,8 @@ #include extern void reset_parser (void); -extern int yylex (void); -extern int yyparse (void); +extern int octave_lex (void); +extern int octave_parse (void); class tree; class tree_matrix; @@ -46,7 +46,7 @@ extern symbol_table *tmp_local_sym_tab; // Nonzero means print parser debugging info (-d). -extern int yydebug; +extern int octave_debug; // The current input line number. extern int input_line_number; diff -r 2be826ada7bb -r 9f0ce1536368 src/parse.y --- a/src/parse.y Sat Feb 07 22:47:38 2004 +0000 +++ b/src/parse.y Fri Feb 13 17:55:24 2004 +0000 @@ -348,6 +348,8 @@ // Bison declarations. +%name-prefix = "octave_" + %union { // The type of the basic tokens returned by the lexer. diff -r 2be826ada7bb -r 9f0ce1536368 src/toplev.cc --- a/src/toplev.cc Sat Feb 07 22:47:38 2004 +0000 +++ b/src/toplev.cc Fri Feb 13 17:55:24 2004 +0000 @@ -149,7 +149,8 @@ reset_parser (); - retval = yyparse (); + // This is the same as yyparse in parse.y. + retval = octave_parse (); if (retval == 0) {