Mercurial > hg > octave-lyh
comparison libinterp/parse-tree/lex.ll @ 16282:82ff1c5bbff0 classdef
maint: periodic merge of default to classdef
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 11 Mar 2013 17:11:46 -0400 |
parents | 0dc6731fc0da 1bbc2fc552cf |
children | f58257a6d18c |
comparison
equal
deleted
inserted
replaced
16280:0dc6731fc0da | 16282:82ff1c5bbff0 |
---|---|
168 \ | 168 \ |
169 if (tok < 0) \ | 169 if (tok < 0) \ |
170 { \ | 170 { \ |
171 yyless (0); \ | 171 yyless (0); \ |
172 curr_lexer->xunput (','); \ | 172 curr_lexer->xunput (','); \ |
173 /* Adjust for comma that was not really in the input stream. */ \ | |
174 curr_lexer->current_input_column--; \ | |
173 } \ | 175 } \ |
174 else \ | 176 else \ |
175 { \ | 177 { \ |
176 return tok; \ | 178 return tok; \ |
177 } \ | 179 } \ |
287 } | 289 } |
288 | 290 |
289 <MATRIX_START>{NL} { | 291 <MATRIX_START>{NL} { |
290 curr_lexer->lexer_debug ("<MATRIX_START>{NL}"); | 292 curr_lexer->lexer_debug ("<MATRIX_START>{NL}"); |
291 | 293 |
294 curr_lexer->input_line_number++; | |
295 curr_lexer->current_input_column = 1; | |
296 | |
292 if (curr_lexer->nesting_level.is_paren ()) | 297 if (curr_lexer->nesting_level.is_paren ()) |
293 curr_lexer->gripe_matlab_incompatible ("bare newline inside parentheses"); | 298 curr_lexer->gripe_matlab_incompatible ("bare newline inside parentheses"); |
294 else | 299 else |
295 { | 300 { |
296 int tok = curr_lexer->previous_token_value (); | 301 int tok = curr_lexer->previous_token_value (); |
297 | 302 |
298 if (! (tok == ';' || tok == '[' || tok == '{')) | 303 if (! (tok == ';' || tok == '[' || tok == '{')) |
299 curr_lexer->xunput (';'); | 304 { |
305 curr_lexer->xunput (';'); | |
306 // Adjust for semicolon that was not really in the input stream. | |
307 curr_lexer->current_input_column--; | |
308 } | |
300 } | 309 } |
301 } | 310 } |
302 | 311 |
303 %{ | 312 %{ |
304 // For this and the next two rules, we're looking at ']', and we | 313 // For this and the next two rules, we're looking at ']', and we |
361 | 370 |
362 if (unput_comma) | 371 if (unput_comma) |
363 { | 372 { |
364 yyless (0); | 373 yyless (0); |
365 curr_lexer->xunput (','); | 374 curr_lexer->xunput (','); |
375 // Adjust for comma that was not really in the input stream. | |
376 curr_lexer->current_input_column--; | |
366 } | 377 } |
367 else | 378 else |
368 { | 379 { |
369 curr_lexer->nesting_level.bracket (); | 380 curr_lexer->nesting_level.bracket (); |
370 | 381 |
766 } | 777 } |
767 else | 778 else |
768 { | 779 { |
769 yyless (0); | 780 yyless (0); |
770 curr_lexer->xunput (','); | 781 curr_lexer->xunput (','); |
782 // Adjust for comma that was not really in the input stream. | |
783 curr_lexer->current_input_column--; | |
771 } | 784 } |
772 } | 785 } |
773 else | 786 else |
774 { | 787 { |
775 if (tok == '[' || tok == '{' | 788 if (tok == '[' || tok == '{' |
832 } | 845 } |
833 else | 846 else |
834 { | 847 { |
835 yyless (0); | 848 yyless (0); |
836 curr_lexer->xunput (','); | 849 curr_lexer->xunput (','); |
850 // Adjust for comma that was not really in the input stream. | |
851 curr_lexer->current_input_column--; | |
837 } | 852 } |
838 } | 853 } |
839 else | 854 else |
840 { | 855 { |
841 curr_lexer->current_input_column++; | 856 curr_lexer->current_input_column++; |
922 | 937 |
923 if (tok < 0) | 938 if (tok < 0) |
924 { | 939 { |
925 yyless (0); | 940 yyless (0); |
926 curr_lexer->xunput (','); | 941 curr_lexer->xunput (','); |
942 // Adjust for comma that was not really in the input stream. | |
943 curr_lexer->current_input_column--; | |
927 } | 944 } |
928 else | 945 else |
929 return tok; | 946 return tok; |
930 } | 947 } |
931 | 948 |
936 | 953 |
937 if (tok < 0) | 954 if (tok < 0) |
938 { | 955 { |
939 yyless (0); | 956 yyless (0); |
940 curr_lexer->xunput (','); | 957 curr_lexer->xunput (','); |
958 // Adjust for comma that was not really in the input stream. | |
959 curr_lexer->current_input_column--; | |
941 } | 960 } |
942 else | 961 else |
943 return tok; | 962 return tok; |
944 } | 963 } |
945 | 964 |
960 | 979 |
961 if (unput_comma) | 980 if (unput_comma) |
962 { | 981 { |
963 yyless (0); | 982 yyless (0); |
964 curr_lexer->xunput (','); | 983 curr_lexer->xunput (','); |
984 // Adjust for comma that was not really in the input stream. | |
985 curr_lexer->current_input_column--; | |
965 } | 986 } |
966 else | 987 else |
967 { | 988 { |
968 // If we are looking for an object index, then push TRUE for | 989 // If we are looking for an object index, then push TRUE for |
969 // looking_at_object_index. Otherwise, just push whatever state | 990 // looking_at_object_index. Otherwise, just push whatever state |
1058 | 1079 |
1059 if (unput_comma) | 1080 if (unput_comma) |
1060 { | 1081 { |
1061 yyless (0); | 1082 yyless (0); |
1062 curr_lexer->xunput (','); | 1083 curr_lexer->xunput (','); |
1084 // Adjust for comma that was not really in the input stream. | |
1085 curr_lexer->current_input_column--; | |
1063 } | 1086 } |
1064 else | 1087 else |
1065 { | 1088 { |
1066 curr_lexer->nesting_level.brace (); | 1089 curr_lexer->nesting_level.brace (); |
1067 | 1090 |
1759 xunput (c); | 1782 xunput (c); |
1760 c = '\n'; | 1783 c = '\n'; |
1761 } | 1784 } |
1762 } | 1785 } |
1763 | 1786 |
1764 if (c == '\n') | |
1765 input_line_number++; | |
1766 | |
1767 return c; | 1787 return c; |
1768 } | 1788 } |
1769 | 1789 |
1770 void | 1790 void |
1771 octave_lexer::xunput (char c, char *buf) | 1791 octave_lexer::xunput (char c, char *buf) |
1776 { | 1796 { |
1777 std::cerr << "U: "; | 1797 std::cerr << "U: "; |
1778 display_character (c); | 1798 display_character (c); |
1779 std::cerr << std::endl; | 1799 std::cerr << std::endl; |
1780 } | 1800 } |
1781 | |
1782 if (c == '\n') | |
1783 input_line_number--; | |
1784 | 1801 |
1785 yyunput (c, buf, scanner); | 1802 yyunput (c, buf, scanner); |
1786 } | 1803 } |
1787 } | 1804 } |
1788 | 1805 |
2181 comment_text = ""; | 2198 comment_text = ""; |
2182 | 2199 |
2183 at_beginning_of_statement = true; | 2200 at_beginning_of_statement = true; |
2184 | 2201 |
2185 if (! looking_at_continuation) | 2202 if (! looking_at_continuation) |
2186 xunput ('\n'); | 2203 { |
2204 xunput ('\n'); | |
2205 // Adjust for newline that was not really in the input stream. | |
2206 input_line_number--; | |
2207 } | |
2187 } | 2208 } |
2188 | 2209 |
2189 // We have seen a backslash and need to find out if it should be | 2210 // We have seen a backslash and need to find out if it should be |
2190 // treated as a continuation character. If so, this eats it, up to | 2211 // treated as a continuation character. If so, this eats it, up to |
2191 // and including the new line character. | 2212 // and including the new line character. |