Mercurial > hg > octave-lyh
comparison src/lex.l @ 4051:b79da8779a0e
[project @ 2002-08-17 19:38:32 by jwe]
author | jwe |
---|---|
date | Sat, 17 Aug 2002 19:38:33 +0000 |
parents | 7e0c73f17a5d |
children | b4fa31442a78 |
comparison
equal
deleted
inserted
replaced
4050:6481f41a79f3 | 4051:b79da8779a0e |
---|---|
29 #endif | 29 #endif |
30 | 30 |
31 #include <cctype> | 31 #include <cctype> |
32 #include <cstring> | 32 #include <cstring> |
33 | 33 |
34 #include <strstream> | |
35 #include <string> | 34 #include <string> |
36 | 35 |
37 #include "SLStack.h" | 36 #include "SLStack.h" |
38 | 37 |
39 #include "cmd-edit.h" | 38 #include "cmd-edit.h" |
39 #include "lo-sstream.h" | |
40 | 40 |
41 // These would be alphabetical, but y.tab.h must be included before | 41 // These would be alphabetical, but y.tab.h must be included before |
42 // oct-gperf.h and y.tab.h must be included after token.h and the tree | 42 // oct-gperf.h and y.tab.h must be included after token.h and the tree |
43 // class declarations. We can't include y.tab.h in oct-gperf.h | 43 // class declarations. We can't include y.tab.h in oct-gperf.h |
44 // because it may not be protected to allow it to be included multiple | 44 // because it may not be protected to allow it to be included multiple |
1785 // characters, return 0. Otherwise, return 1. | 1785 // characters, return 0. Otherwise, return 1. |
1786 | 1786 |
1787 static bool | 1787 static bool |
1788 have_continuation (bool trailing_comments_ok) | 1788 have_continuation (bool trailing_comments_ok) |
1789 { | 1789 { |
1790 std::ostrstream buf; | 1790 OSSTREAM buf; |
1791 | 1791 |
1792 std::string comment_buf; | 1792 std::string comment_buf; |
1793 | 1793 |
1794 bool in_comment = false; | 1794 bool in_comment = false; |
1795 bool beginning_of_comment = false; | 1795 bool beginning_of_comment = false; |
1877 | 1877 |
1878 unput (c); | 1878 unput (c); |
1879 return false; | 1879 return false; |
1880 | 1880 |
1881 cleanup: | 1881 cleanup: |
1882 buf << std::ends; | 1882 |
1883 char *s = buf.str (); | 1883 buf << OSSTREAM_ENDS; |
1884 if (s) | 1884 std::string s = OSSTREAM_STR (buf); |
1885 { | 1885 OSSTREAM_FREEZE (buf); |
1886 int len = strlen (s); | 1886 |
1887 while (len--) | 1887 int len = s.length (); |
1888 unput (s[len]); | 1888 while (len--) |
1889 } | 1889 unput (s[len]); |
1890 delete [] s; | |
1891 | 1890 |
1892 return false; | 1891 return false; |
1893 } | 1892 } |
1894 | 1893 |
1895 // We have seen a `.' and need to see if it is the start of a | 1894 // We have seen a `.' and need to see if it is the start of a |
1939 } | 1938 } |
1940 | 1939 |
1941 static int | 1940 static int |
1942 handle_string (char delim, int text_style) | 1941 handle_string (char delim, int text_style) |
1943 { | 1942 { |
1944 std::ostrstream buf; | 1943 OSSTREAM buf; |
1945 | 1944 |
1946 int bos_line = input_line_number; | 1945 int bos_line = input_line_number; |
1947 int bos_col = current_input_column; | 1946 int bos_col = current_input_column; |
1948 | 1947 |
1949 int c; | 1948 int c; |
1992 if (c == delim) | 1991 if (c == delim) |
1993 buf << static_cast<char> (c); | 1992 buf << static_cast<char> (c); |
1994 else | 1993 else |
1995 { | 1994 { |
1996 unput (c); | 1995 unput (c); |
1997 buf << std::ends; | 1996 buf << OSSTREAM_ENDS; |
1998 char *t = buf.str (); | 1997 std::string s = do_string_escapes (OSSTREAM_STR (buf)); |
1999 std::string s = do_string_escapes (t); | 1998 OSSTREAM_FREEZE (buf); |
2000 delete [] t; | |
2001 | 1999 |
2002 if (text_style && lexer_flags.doing_set) | 2000 if (text_style && lexer_flags.doing_set) |
2003 { | 2001 { |
2004 s = std::string (1, delim) + s + std::string (1, delim); | 2002 s = std::string (1, delim) + s + std::string (1, delim); |
2005 } | 2003 } |