Mercurial > hg > octave-lyh
changeset 2166:d68119516779
[project @ 1996-05-13 13:41:55 by jwe]
author | jwe |
---|---|
date | Mon, 13 May 1996 13:43:07 +0000 |
parents | 83d91aa3759b |
children | d9b541575734 |
files | src/lex.h src/parse.y |
diffstat | 2 files changed, 82 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lex.h +++ b/src/lex.h @@ -191,6 +191,8 @@ // Flags that need to be shared between the lexer and parser. extern lexical_feedback lexer_flags; +extern void symbols_of_lex (void); + #endif /*
--- a/src/parse.y +++ b/src/parse.y @@ -35,6 +35,7 @@ #include "Matrix.h" +#include "defun.h" #include "error.h" #include "input.h" #include "lex.h" @@ -57,6 +58,31 @@ #include "utils.h" #include "variables.h" +// If TRUE, generate a warning for the assignment in things like +// +// octave> if (a = 2 < n) +// +// but not +// +// octave> if ((a = 2) < n) +// +static bool Vwarn_assign_as_truth_value; + +// If TRUE, generate a warning for the comma in things like +// +// octave> global a, b = 2 +// +static bool Vwarn_comma_in_global_decl; + +// If TRUE, generate warning if declared function name disagrees with +// the name of the file in which it is defined. +static bool Vwarn_function_name_clash; + +// If TRUE, generate warning if a statement in a function is not +// terminated with a semicolon. Useful for checking functions that +// should only produce output using explicit printing statements. +static bool Vwarn_missing_semicolon; + // Temporary symbol table pointer used to cope with bogus function syntax. symbol_table *tmp_local_sym_tab = 0; @@ -626,7 +652,7 @@ optcomma : // empty | ',' { - if (user_pref.warn_comma_in_global_decl) + if (Vwarn_comma_in_global_decl) warning ("comma in global declaration not\ interpreted as a command separator"); } @@ -1325,7 +1351,7 @@ static void maybe_warn_assign_as_truth_value (tree_expression *expr) { - if (user_pref.warn_assign_as_truth_value + if (Vwarn_assign_as_truth_value && expr->is_assignment_expression () && expr->is_in_parens () < 2) { @@ -1948,7 +1974,7 @@ { if (curr_fcn_file_name != id_name) { - if (user_pref.warn_function_name_clash) + if (Vwarn_function_name_clash) warning ("function name `%s' does not agree with function\ file name `%s'", id_name.c_str (), curr_fcn_file_full_name.c_str ()); @@ -2058,7 +2084,7 @@ static void maybe_warn_missing_semi (tree_statement_list *t) { - if (lexer_flags.defining_func && user_pref.warn_missing_semicolon) + if (lexer_flags.defining_func && Vwarn_missing_semicolon) { tree_statement *tmp = t->rear(); @@ -2069,6 +2095,56 @@ } } +static int +warn_assign_as_truth_value (void) +{ + Vwarn_assign_as_truth_value + = check_preference ("warn_assign_as_truth_value"); + + return 0; +} + +static int +warn_comma_in_global_decl (void) +{ + Vwarn_comma_in_global_decl = check_preference ("warn_comma_in_global_decl"); + + return 0; +} + +static int +warn_function_name_clash (void) +{ + Vwarn_function_name_clash = check_preference ("warn_function_name_clash"); + + return 0; +} + +static int +warn_missing_semicolon (void) +{ + Vwarn_missing_semicolon = check_preference ("warn_missing_semicolon"); + + return 0; +} + +void +symbols_of_parse (void) +{ + DEFVAR (warn_assign_as_truth_value, 1.0, 0, warn_assign_as_truth_value, + "produce warning for assignments used as truth values"); + + DEFVAR (warn_comma_in_global_decl, 1.0, 0, warn_comma_in_global_decl, + "produce warning for commas in global declarations"); + + DEFVAR (warn_function_name_clash, 1.0, 0, warn_function_name_clash, + "produce warning if function name conflicts with file name"); + + DEFVAR (warn_missing_semicolon, 0.0, 0, warn_missing_semicolon, + "produce a warning if a statement in a function file is not +terminated with a semicolon"); +} + /* ;;; Local Variables: *** ;;; mode: text ***