Mercurial > hg > octave-jordi
changeset 522:2dba380d2d85
[project @ 1994-07-20 18:31:40 by jwe]
author | jwe |
---|---|
date | Wed, 20 Jul 1994 18:33:28 +0000 |
parents | af19ffbbe91d |
children | 4a07f0083ab0 |
files | src/lex.l src/parse.y |
diffstat | 2 files changed, 59 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lex.l +++ b/src/lex.l @@ -34,6 +34,8 @@ #include "config.h" #endif +#include <string.h> + #include "input.h" #include "token.h" @@ -161,7 +163,7 @@ <HELP_FCN>[^ \t\n]*{S}* | <TEXT_FCN>[^ \t\n\;\,]*{S}* { - static char *tok = (char *) NULL; + static char *tok = 0; delete [] tok; tok = strip_trailing_whitespace (yytext); yylval.tok_val = new token (tok); @@ -178,7 +180,7 @@ } else { - static char *tok = (char *) NULL; + static char *tok = 0; delete [] tok; int off1 = doing_set ? 0 : 1; int off2 = doing_set ? 0 : 2; @@ -201,7 +203,7 @@ } else { - static char *tok = (char *) NULL; + static char *tok = 0; delete [] tok; int off1 = doing_set ? 0 : 1; int off2 = doing_set ? 0 : 2; @@ -231,7 +233,7 @@ } else { - static char *tok = (char *) NULL; + static char *tok = 0; delete [] tok; tok = strsave (yytext); tok[yyleng-1] = '\0'; @@ -261,7 +263,7 @@ } else { - static char *tok = (char *) NULL; + static char *tok = 0; delete [] tok; tok = strsave (yytext); tok[yyleng-1] = '\0'; @@ -479,7 +481,7 @@ // Truncate the token at the first space or tab but don't write // directly on yytext. - static char *tok = (char *) NULL; + static char *tok = 0; delete [] tok; tok = strip_trailing_whitespace (yytext); return handle_identifier (tok, 0); @@ -896,11 +898,11 @@ "lines", "linespoints", "points", - (char *) NULL, + 0, }; char **tmp = plot_styles; - while (*tmp != (char *) NULL) + while (*tmp) { if (almost_match (*tmp, s)) return *tmp; @@ -908,7 +910,7 @@ tmp++; } - return (char *) NULL; + return 0; } /* @@ -949,7 +951,7 @@ if (plotting && in_plot_style) { char *sty = plot_style_token (s); - if (sty != (char *) NULL) + if (sty) { in_plot_style = 0; yylval.tok_val = new token (sty); @@ -1031,7 +1033,7 @@ error ("function keyword invalid within a function body"); if ((reading_fcn_file || reading_script_file) - && curr_fcn_file_name != (char *) NULL) + && curr_fcn_file_name) error ("defining new function near line %d of file `%s.m'", input_line_number, curr_fcn_file_name); else @@ -1334,11 +1336,11 @@ char *retval = strsave (s); char *t = strchr (retval, ' '); - if (t != (char *) NULL) + if (t) *t = '\0'; t = strchr (retval, '\t'); - if (t != (char *) NULL) + if (t) *t = '\0'; return retval;
--- a/src/parse.y +++ b/src/parse.y @@ -37,6 +37,7 @@ #include "Matrix.h" #include "error.h" +#include "octave.h" #include "variables.h" #include "octave-hist.h" #include "user-prefs.h" @@ -46,8 +47,6 @@ #include "tree-plot.h" #include "tree-const.h" #include "symtab.h" -#include "builtins.h" -#include "octave.h" #include "parse.h" #include "lex.h" #include "token.h" @@ -70,7 +69,7 @@ int maybe_screwed_again = 0; // Temporary symbol table pointer used to cope with bogus function syntax. -symbol_table *tmp_local_sym_tab = (symbol_table *) NULL; +symbol_table *tmp_local_sym_tab = 0; // Stack to hold list of literal matrices. SLStack <tree_matrix *> ml; @@ -129,7 +128,7 @@ #define ABORT_PARSE \ do \ { \ - global_command = NULL_TREE; \ + global_command = 0; \ reset_parser (); \ yyerrok; \ if (interactive) \ @@ -241,13 +240,13 @@ input : '\n' { - global_command = NULL_TREE; + global_command = 0; promptflag = 1; YYACCEPT; } | END_OF_INPUT { - global_command = NULL_TREE; + global_command = 0; promptflag = 1; YYABORT; } @@ -284,9 +283,9 @@ ; simple_list : semi_comma - { $$ = (tree_command_list *) NULL; } + { $$ = 0; } | comma_semi - { $$ = (tree_command_list *) NULL; } + { $$ = 0; } | simple_list1 { $$ = $1->reverse (); } | simple_list1 semi_comma @@ -377,12 +376,11 @@ plot_command : PLOT plot_command1 { - tree_subplot_list *tmp = (tree_subplot_list *) NULL; - if ($2 != (tree_subplot_list *) NULL) + tree_subplot_list *tmp = 0; + if ($2) tmp = $2->reverse (); - if (tmp == (tree_subplot_list *) NULL - && $1->pttype () != token::replot) + if (! tmp && $1->pttype () != token::replot) { yyerror ("must have something to plot"); ABORT_PARSE; @@ -428,9 +426,9 @@ ranges1 : OPEN_BRACE expression COLON expression CLOSE_BRACE { $$ = new tree_plot_range ($2, $4); } | OPEN_BRACE COLON expression CLOSE_BRACE - { $$ = new tree_plot_range (NULL, $3); } + { $$ = new tree_plot_range (0, $3); } | OPEN_BRACE expression COLON CLOSE_BRACE - { $$ = new tree_plot_range ($2, NULL); } + { $$ = new tree_plot_range ($2, 0); } | OPEN_BRACE COLON CLOSE_BRACE { $$ = new tree_plot_range (); } | OPEN_BRACE CLOSE_BRACE @@ -438,7 +436,7 @@ ; plot_command1 : // empty - { $$ = (tree_subplot_list *) NULL; } + { $$ = 0; } | plot_command2 { $$ = $1; } | plot_command1 ',' plot_command2 @@ -452,23 +450,23 @@ ; plot_options : using - { $$ = new tree_subplot_list ($1, NULL, NULL); } + { $$ = new tree_subplot_list ($1, 0, 0); } | title - { $$ = new tree_subplot_list (NULL, $1, NULL); } + { $$ = new tree_subplot_list (0, $1, 0); } | style - { $$ = new tree_subplot_list (NULL, NULL, $1); } + { $$ = new tree_subplot_list (0, 0, $1); } | using title - { $$ = new tree_subplot_list ($1, $2, NULL); } + { $$ = new tree_subplot_list ($1, $2, 0); } | title using - { $$ = new tree_subplot_list ($2, $1, NULL); } + { $$ = new tree_subplot_list ($2, $1, 0); } | using style - { $$ = new tree_subplot_list ($1, NULL, $2); } + { $$ = new tree_subplot_list ($1, 0, $2); } | style using - { $$ = new tree_subplot_list ($2, NULL, $1); } + { $$ = new tree_subplot_list ($2, 0, $1); } | title style - { $$ = new tree_subplot_list (NULL, $1, $2); } + { $$ = new tree_subplot_list (0, $1, $2); } | style title - { $$ = new tree_subplot_list (NULL, $2, $1); } + { $$ = new tree_subplot_list (0, $2, $1); } | using title style { $$ = new tree_subplot_list ($1, $2, $3); } | using style title @@ -697,27 +695,29 @@ // anything -- no other possible syntax is valid if we've seen the // equals sign as the next token after the `]'. - $$ = (tree_multi_assignment_expression *) NULL; + $$ = 0; maybe_screwed_again--; tree_matrix *tmp = ml.pop (); tmp = tmp->reverse (); tree_return_list *id_list = tmp->to_return_list (); - if (id_list == NULL_TREE) + if (id_list) + { + $$ = new tree_multi_assignment_expression + (id_list, $6, $5->line (), $5->column ()); + } + else { yyerror ("parse error"); error ("invalid identifier list for assignment"); - $$ = (tree_multi_assignment_expression *) NULL; + $$ = 0; ABORT_PARSE; } - else - $$ = new tree_multi_assignment_expression - (id_list, $6, $5->line (), $5->column ()); } | NUM '=' expression { yyerror ("parse error"); error ("invalid assignment to a number"); - $$ = (tree_simple_assignment_expression *) NULL; + $$ = 0; ABORT_PARSE; } | simple_expr @@ -852,7 +852,7 @@ | colon_expr ':' simple_expr { $$ = $1->chain ($3); - if ($$ == (tree_colon_expression *) NULL) + if (! $$) { yyerror ("parse error"); ABORT_PARSE; @@ -905,13 +905,13 @@ { curr_sym_tab = top_level_sym_tab; defining_func = 0; - $$ = (tree_function *) NULL; + $$ = 0; } | FCN g_symtab are_we_screwed func_def2 { curr_sym_tab = top_level_sym_tab; defining_func = 0; - $$ = (tree_function *) NULL; + $$ = 0; } ; @@ -964,7 +964,7 @@ } $4->stash_fcn_file_name (curr_fcn_file_name); - $4->stash_fcn_file_time (time ((time_t *) NULL)); + $4->stash_fcn_file_time (time (0)); $4->mark_as_system_fcn_file (); } else if (! (input_from_tmp_history_file @@ -1023,16 +1023,15 @@ } | identifier '(' ')' { - $$ = new tree_index_expression - ($1, (tree_argument_list *) NULL, - $1->line (), $1->column ()); + $$ = new tree_index_expression ($1, 0, $1->line (), + $1->column ()); } | identifier '[' { yyerror ("parse error"); error ("use `(\' and `)\' as index operators, not\ `[\' and `]\'"); - $$ = (tree_index_expression *) NULL; + $$ = 0; ABORT_PARSE; } ; @@ -1040,7 +1039,7 @@ param_list : '(' ')' { quote_is_transpose = 0; - $$ = (tree_parameter_list *) NULL; + $$ = 0; } | '(' ELLIPSIS ')' { @@ -1106,7 +1105,7 @@ tree_constant *colon; colon = new tree_constant (tree_constant_rep::magic_colon); $$ = $1->chain (colon); - if ($$ == NULL_TREE) + if (! $$) { yyerror ("parse error"); ABORT_PARSE; @@ -1117,7 +1116,7 @@ | arg_list1 ',' expression { $$ = $1->chain ($3); - if ($$ == NULL_TREE) + if (! $$) { yyerror ("parse error"); ABORT_PARSE; @@ -1171,7 +1170,7 @@ { char *line = current_input_line; int err_col = current_input_column - 1; - if (err_col == 0 && line != (char *) NULL) + if (err_col == 0 && line) err_col = strlen (line) + 1; // Print a message like `parse error'. @@ -1182,7 +1181,7 @@ fprintf (stderr, " near line %d of file %s.m", input_line_number, curr_fcn_file_name); - if (line != (char *) NULL) + if (line) { int len = strlen (line); if (line[len-1] == '\n') @@ -1293,7 +1292,7 @@ { symbol_record *sr = global_sym_tab->lookup ("ans", 1, 0); - assert (sr != (symbol_record *) NULL); + assert (sr); tree_identifier *ans = new tree_identifier (sr);