Mercurial > octave
comparison libinterp/parse-tree/lex.ll @ 30320:c41fec3367b0
new lexer utility function, warn_deprecated_syntax
* lex.h, lex.ll (base_lexer::warn_deprecated_syntax): New function.
(<DQ_STRING_START>(\.\.\.){S}*{NL}): Use it.
(<DQ_STRING_START>\\{S}+{NL}): Likewise.
(\\{S}*{NL}|\\{S}*{CCHAR}{ANY_EXCEPT_NL}*{NL}): Likewise.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 22 Nov 2021 15:41:42 -0500 |
parents | 501fe2c8a880 |
children | 2ba4758654ca |
comparison
equal
deleted
inserted
replaced
30319:a12b5a32f94b | 30320:c41fec3367b0 |
---|---|
1070 curr_lexer->lexer_debug ("<DQ_STRING_START>(\\.\\.\\.){S}*{NL}"); | 1070 curr_lexer->lexer_debug ("<DQ_STRING_START>(\\.\\.\\.){S}*{NL}"); |
1071 | 1071 |
1072 /* FIXME: Remove support for '...' continuation in Octave 9 */ | 1072 /* FIXME: Remove support for '...' continuation in Octave 9 */ |
1073 static const char *msg = "'...' continuations in double-quoted character strings were deprecated in version 7 and will not be allowed in a future version of Octave; please use '\\' instead"; | 1073 static const char *msg = "'...' continuations in double-quoted character strings were deprecated in version 7 and will not be allowed in a future version of Octave; please use '\\' instead"; |
1074 | 1074 |
1075 std::string nm = curr_lexer->m_fcn_file_full_name; | 1075 curr_lexer->warn_deprecated_syntax (msg); |
1076 | |
1077 if (nm.empty ()) | |
1078 warning_with_id ("Octave:deprecated-syntax", "%s", msg); | |
1079 else | |
1080 warning_with_id ("Octave:deprecated-syntax", | |
1081 "%s; near line %d of file '%s'", msg, | |
1082 curr_lexer->m_filepos.line (), nm.c_str ()); | |
1083 | 1076 |
1084 HANDLE_STRING_CONTINUATION; | 1077 HANDLE_STRING_CONTINUATION; |
1085 } | 1078 } |
1086 | 1079 |
1087 <DQ_STRING_START>\\{S}+{NL} { | 1080 <DQ_STRING_START>\\{S}+{NL} { |
1088 curr_lexer->lexer_debug ("<DQ_STRING_START>\\\\{S}+{NL}"); | 1081 curr_lexer->lexer_debug ("<DQ_STRING_START>\\\\{S}+{NL}"); |
1089 | 1082 |
1090 /* FIXME: Remove support for WS after line continuation in Octave 9 */ | 1083 /* FIXME: Remove support for WS after line continuation in Octave 9 */ |
1091 static const char *msg = "whitespace after continuation markers in double-quoted character strings were deprecated in version 7 and will not be allowed in a future version of Octave"; | 1084 static const char *msg = "whitespace after continuation markers in double-quoted character strings were deprecated in version 7 and will not be allowed in a future version of Octave"; |
1092 | 1085 |
1093 std::string nm = curr_lexer->m_fcn_file_full_name; | 1086 curr_lexer->warn_deprecated_syntax (msg); |
1094 | |
1095 if (nm.empty ()) | |
1096 warning_with_id ("Octave:deprecated-syntax", "%s", msg); | |
1097 else | |
1098 warning_with_id ("Octave:deprecated-syntax", | |
1099 "%s; near line %d of file '%s'", msg, | |
1100 curr_lexer->m_filepos.line (), nm.c_str ()); | |
1101 | 1087 |
1102 HANDLE_STRING_CONTINUATION; | 1088 HANDLE_STRING_CONTINUATION; |
1103 } | 1089 } |
1104 | 1090 |
1105 <DQ_STRING_START>\\{NL} { | 1091 <DQ_STRING_START>\\{NL} { |
1299 curr_lexer->lexer_debug ("\\\\{S}*{NL}|\\\\{S}*{CCHAR}{ANY_EXCEPT_NL}*{NL}"); | 1285 curr_lexer->lexer_debug ("\\\\{S}*{NL}|\\\\{S}*{CCHAR}{ANY_EXCEPT_NL}*{NL}"); |
1300 | 1286 |
1301 /* FIXME: Remove support for '\\' line continuation in Octave 9 */ | 1287 /* FIXME: Remove support for '\\' line continuation in Octave 9 */ |
1302 static const char *msg = "using continuation marker \\ outside of double quoted strings was deprecated in version 7 and will be removed from a future version of Octave, use ... instead"; | 1288 static const char *msg = "using continuation marker \\ outside of double quoted strings was deprecated in version 7 and will be removed from a future version of Octave, use ... instead"; |
1303 | 1289 |
1304 std::string nm = curr_lexer->m_fcn_file_full_name; | 1290 curr_lexer->warn_deprecated_syntax (msg); |
1305 | |
1306 if (nm.empty ()) | |
1307 warning_with_id ("Octave:deprecated-syntax", "%s", msg); | |
1308 else | |
1309 warning_with_id ("Octave:deprecated-syntax", | |
1310 "%s; near line %d of file '%s'", msg, | |
1311 curr_lexer->m_filepos.line (), nm.c_str ()); | |
1312 | 1291 |
1313 curr_lexer->handle_continuation (); | 1292 curr_lexer->handle_continuation (); |
1314 } | 1293 } |
1315 | 1294 |
1316 %{ | 1295 %{ |
3665 t.resize (n-1); | 3644 t.resize (n-1); |
3666 warn_language_extension (t + " used as operator"); | 3645 warn_language_extension (t + " used as operator"); |
3667 } | 3646 } |
3668 | 3647 |
3669 void | 3648 void |
3649 base_lexer::warn_deprecated_syntax (const std::string& msg) | |
3650 { | |
3651 if (m_fcn_file_full_name.empty ()) | |
3652 warning_with_id ("Octave:deprecated-syntax", "%s", msg.c_str ()); | |
3653 else | |
3654 warning_with_id ("Octave:deprecated-syntax", | |
3655 "%s; near line %d of file '%s'", msg.c_str (), | |
3656 m_filepos.line (), m_fcn_file_full_name.c_str ()); | |
3657 } | |
3658 | |
3659 void | |
3670 base_lexer::push_token (token *tok) | 3660 base_lexer::push_token (token *tok) |
3671 { | 3661 { |
3672 YYSTYPE *lval = yyget_lval (m_scanner); | 3662 YYSTYPE *lval = yyget_lval (m_scanner); |
3673 lval->tok_val = tok; | 3663 lval->tok_val = tok; |
3674 m_tokens.push (tok); | 3664 m_tokens.push (tok); |