comparison src/lex.l @ 1755:3a9462b655f1

[project @ 1996-01-22 04:47:22 by jwe]
author jwe
date Mon, 22 Jan 1996 04:47:22 +0000
parents fe9d3b2ded26
children 5cdd59e7579a
comparison
equal deleted inserted replaced
1754:5f1938919fdc 1755:3a9462b655f1
474 // Gobble comments. If closest nesting is inside parentheses, don't 474 // Gobble comments. If closest nesting is inside parentheses, don't
475 // return a new line. 475 // return a new line.
476 %} 476 %}
477 477
478 {CCHAR} { 478 {CCHAR} {
479 if (! help_buf && beginning_of_function && nesting_level.empty ()) 479 if (help_buf.empty () && beginning_of_function && nesting_level.empty ())
480 { 480 {
481 grab_help_text (); 481 grab_help_text ();
482 beginning_of_function = 0; 482 beginning_of_function = 0;
483 } 483 }
484 else 484 else
679 // Only ask for input from stdin if we are expecting interactive 679 // Only ask for input from stdin if we are expecting interactive
680 // input. 680 // input.
681 if (interactive && ! (reading_fcn_file || get_input_from_eval_string)) 681 if (interactive && ! (reading_fcn_file || get_input_from_eval_string))
682 yyrestart (stdin); 682 yyrestart (stdin);
683 683
684 // Delete the buffer for help text. 684 // Clear the buffer for help text.
685 delete [] help_buf; 685
686 help_buf = 0; 686 help_buf.resize (0);
687 } 687 }
688 688
689 // Replace backslash escapes in a string with the real values. 689 // Replace backslash escapes in a string with the real values.
690 690
691 static void 691 static void
1024 if (defining_func) 1024 if (defining_func)
1025 { 1025 {
1026 error ("function keyword invalid within a function body"); 1026 error ("function keyword invalid within a function body");
1027 1027
1028 if ((reading_fcn_file || reading_script_file) 1028 if ((reading_fcn_file || reading_script_file)
1029 && curr_fcn_file_name) 1029 && ! curr_fcn_file_name.empty ())
1030 error ("defining new function near line %d of file `%s.m'", 1030 error ("defining new function near line %d of file `%s.m'",
1031 input_line_number, curr_fcn_file_name); 1031 input_line_number, curr_fcn_file_name.c_str ());
1032 else 1032 else
1033 error ("defining new function near line %d", input_line_number); 1033 error ("defining new function near line %d",
1034 input_line_number);
1034 1035
1035 return LEXICAL_ERROR; 1036 return LEXICAL_ERROR;
1036 } 1037 }
1037 else 1038 else
1038 { 1039 {
1074 // current contents of help_buf. 1075 // current contents of help_buf.
1075 1076
1076 static void 1077 static void
1077 grab_help_text (void) 1078 grab_help_text (void)
1078 { 1079 {
1079 delete [] help_buf; 1080 help_buf.resize (0);
1080 help_buf = 0;
1081
1082 ostrstream buf;
1083 1081
1084 int in_comment = 1; 1082 int in_comment = 1;
1085 int c = 0; 1083 int c = 0;
1086 1084
1087 while ((c = yyinput ()) != EOF) 1085 while ((c = yyinput ()) != EOF)
1088 { 1086 {
1089 if (in_comment) 1087 if (in_comment)
1090 { 1088 {
1091 buf << (char) c; 1089 help_buf += (char) c;
1090
1092 if (c == '\n') 1091 if (c == '\n')
1093 in_comment = 0; 1092 in_comment = 0;
1094 } 1093 }
1095 else 1094 else
1096 { 1095 {
1113 1112
1114 done: 1113 done:
1115 1114
1116 if (c) 1115 if (c)
1117 yyunput (c, yytext); 1116 yyunput (c, yytext);
1118
1119 buf << ends;
1120
1121 help_buf = buf.str ();
1122
1123 if (! help_buf || ! *help_buf)
1124 {
1125 delete [] help_buf;
1126 help_buf = 0;
1127 }
1128 } 1117 }
1129 1118
1130 // Return 1 if the given character matches any character in the given 1119 // Return 1 if the given character matches any character in the given
1131 // string. 1120 // string.
1132 1121
1832 if (in_comment) 1821 if (in_comment)
1833 break; 1822 break;
1834 else 1823 else
1835 { 1824 {
1836 warning ("ignoring trailing garbage after end of function\n\ 1825 warning ("ignoring trailing garbage after end of function\n\
1837 near line %d of file `%s.m'", lineno, curr_fcn_file_name); 1826 near line %d of file `%s.m'", lineno, curr_fcn_file_name.c_str ());
1838 1827
1839 yyunput ('\n', yytext); 1828 yyunput ('\n', yytext);
1840 return; 1829 return;
1841 } 1830 }
1842 } 1831 }