forked from boostorg/regex
regex: updated snip4.cpp (fixed patholgical expressions).
[SVN r8366]
This commit is contained in:
@ -1,3 +1,11 @@
|
||||
FIXED: Pathological regular expressions in snip4.cpp and in docs.
|
||||
FIXED: Missing std:: prefixes in some headers.
|
||||
|
||||
Version 302:
|
||||
FIXED: STLPort debug problems.
|
||||
FIXED: Compatibility with updated Dinkum libraries and VC6.
|
||||
ADDED: Tentative support for partial matches (not yet documented).
|
||||
|
||||
Version 301:
|
||||
First boost release version,
|
||||
CHANGED: reg_match to match_results
|
||||
@ -209,5 +217,6 @@ BUG: character sets don't function correctly when regbase::char_classes
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -88,14 +88,14 @@ extern const char* pre_format = "(?1<)(?2>)";
|
||||
|
||||
|
||||
const char* expression_text = // preprocessor directives: index 1
|
||||
"(^[[:blank:]]*#([^\\n]*\\\\[[:space:]]+)*[^\\n]*)|"
|
||||
// comment: index 3
|
||||
"(//[^\\n]*|/\\*([^*]|\\*+[^*/])*\\*+/)|"
|
||||
// literals: index 5
|
||||
"\\<([+-]?((0x[[:xdigit:]]+)|(([[:digit:]]*\\.)?[[:digit:]]+([eE][+-]?[[:digit:]]+)?))u?((int(8|16|32|64))|L)?)\\>|"
|
||||
// string literals: index 14
|
||||
"('([^\\\\']|\\\\.)*'|\"([^\\\\\"]|\\\\.)*\")|"
|
||||
// keywords: index 17
|
||||
"(^[[:blank:]]*#(?:[^\\\\\\n]|\\\\[^\\n[:punct:][:word:]]*[\\n[:punct:][:word:]])*)|"
|
||||
// comment: index 2
|
||||
"(//[^\\n]*|/\\*.*?\\*/)|"
|
||||
// literals: index 3
|
||||
"\\<([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(?:8|16|32|64))|L)?)\\>|"
|
||||
// string literals: index 4
|
||||
"('(?:[^\\\\']|\\\\.)*'|\"(?:[^\\\\\"]|\\\\.)*\")|"
|
||||
// keywords: index 5
|
||||
"\\<(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import"
|
||||
"|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall"
|
||||
"|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool"
|
||||
@ -108,16 +108,16 @@ const char* expression_text = // preprocessor directives: index 1
|
||||
;
|
||||
|
||||
const char* format_string = "(?1<font color=\"#008040\">$&</font>)"
|
||||
"(?3<I><font color=\"#000080\">$&</font></I>)"
|
||||
"(?5<font color=\"#0000A0\">$&</font>)"
|
||||
"(?14<font color=\"#0000FF\">$&</font>)"
|
||||
"(?17<B>$&</B>)";
|
||||
"(?2<I><font color=\"#000080\">$&</font></I>)"
|
||||
"(?3<font color=\"#0000A0\">$&</font>)"
|
||||
"(?4<font color=\"#0000FF\">$&</font>)"
|
||||
"(?5<B>$&</B>)";
|
||||
|
||||
const char* header_text = "<HTML>\n<HEAD>\n"
|
||||
"<TITLE>Auto-generated html formated source</TITLE>\n"
|
||||
"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=windows-1252\">\n"
|
||||
"</HEAD>\n"
|
||||
"<BODY LINK=\"#0000ff\" VLINK=\"#800080\" BGCOLOR=\"#ffff99\">\n"
|
||||
"<BODY LINK=\"#0000ff\" VLINK=\"#800080\" BGCOLOR=\"#ffffff\">\n"
|
||||
"<P> </P>\n<PRE>";
|
||||
|
||||
const char* footer_text = "</PRE>\n</BODY>\n\n";
|
||||
|
@ -2053,7 +2053,7 @@ follows: <br>
|
||||
takes C/C++ source code as input, and outputs syntax highlighted
|
||||
HTML code. </p>
|
||||
|
||||
<pre><font color="#008040">#include <iostream></font>
|
||||
<pre>
|
||||
<font color="#008040">#include <fstream></font>
|
||||
<font color="#008040">#include <sstream></font>
|
||||
<font color="#008040">#include <string></font>
|
||||
@ -2082,8 +2082,8 @@ boost::regex e1, e2;
|
||||
<b>while</b>(is.get(c))
|
||||
{
|
||||
<b>if</b>(s.capacity() == s.size())
|
||||
s.reserve(s.capacity() * <font color="#000080">3</font>);
|
||||
s.append(<font color="#000080">1</font>, c);
|
||||
s.reserve(s.capacity() * <font color="#0000A0">3</font>);
|
||||
s.append(<font color="#0000A0">1</font>, c);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2105,12 +2105,12 @@ color="#0000FF">".htm"</font>));
|
||||
<font color="#000080"><i>// temporary string stream</i></font>
|
||||
std::ostringstream t(std::ios::out | std::ios::binary);
|
||||
std::ostream_iterator<<b>char</b>, <b>char</b>> oi(t);
|
||||
regex_merge(oi, in.begin(), in.end(), e2, pre_format);
|
||||
boost::regex_merge(oi, in.begin(), in.end(), e2, pre_format);
|
||||
<font color="#000080"><i>// then output to final output stream</i></font>
|
||||
<font color="#000080"><i>// adding syntax highlighting:</i></font>
|
||||
std::string s(t.str());
|
||||
std::ostream_iterator<<b>char</b>, <b>char</b>> out(os);
|
||||
regex_merge(out, s.begin(), s.end(), e1, format_string);
|
||||
boost::regex_merge(out, s.begin(), s.end(), e1, format_string);
|
||||
os << footer_text;
|
||||
}
|
||||
<b>return</b> <font color="#0000A0">0</font>;
|
||||
@ -2123,14 +2123,14 @@ color="#0000FF">"(?1<)(?2>)"</font>;
|
||||
|
||||
|
||||
<b>const</b> <b>char</b>* expression_text = <font color="#000080"><i>// preprocessor directives: index 1</i></font>
|
||||
<font color="#0000FF">"(^[[:blank:]]*#([^\\n]*\\\\[[:space:]]+)*[^\\n]*)|"</font>
|
||||
<font color="#000080"><i>// comment: index 3</i></font>
|
||||
<font color="#0000FF">"(//[^\\n]*|/\\*([^*]|\\*+[^*/])*\\*+/)|"</font>
|
||||
<font color="#000080"><i>// literals: index 5</i></font>
|
||||
<font color="#0000FF">"\\<([+-]?((0x[[:xdigit:]]+)|(([[:digit:]]*\\.)?[[:digit:]]+([eE][+-]?[[:digit:]]+)?))u?((int(8|16|32|64))|L)?)\\>|"</font>
|
||||
<font color="#000080"><i>// string literals: index 14</i></font>
|
||||
<font color="#0000FF">"('([^\\\\']|\\\\.)*'|\"([^\\\\\"]|\\\\.)*\")|"</font>
|
||||
<font color="#000080"><i>// keywords: index 17</i></font>
|
||||
<font color="#0000FF">"(^[[:blank:]]*#(?:[^\\\\\\n]|\\\\[^\\n[:punct:][:word:]]*[\\n[:punct:][:word:]])*)|"</font>
|
||||
<font color="#000080"><i>// comment: index 2</i></font>
|
||||
<font color="#0000FF">"(//[^\\n]*|/\\*.*?\\*/)|"</font>
|
||||
<font color="#000080"><i>// literals: index 3</i></font>
|
||||
<font color="#0000FF">"\\<([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(?:8|16|32|64))|L)?)\\>|"</font>
|
||||
<font color="#000080"><i>// string literals: index 4</i></font>
|
||||
<font color="#0000FF">"('(?:[^\\\\']|\\\\.)*'|\"(?:[^\\\\\"]|\\\\.)*\")|"</font>
|
||||
<font color="#000080"><i>// keywords: index 5</i></font>
|
||||
<font color="#0000FF">"\\<(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import"</font>
|
||||
<font color="#0000FF">"|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall"</font>
|
||||
<font color="#0000FF">"|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool"</font>
|
||||
@ -2143,16 +2143,16 @@ color="#0000FF">"(?1<)(?2>)"</font>;
|
||||
;
|
||||
|
||||
<b>const</b> <b>char</b>* format_string = <font color="#0000FF">"(?1<font color=\"#008040\">$&</font>)"</font>
|
||||
<font color="#0000FF">"(?3<I><font color=\"#000080\">$&</font></I>)"</font>
|
||||
<font color="#0000FF">"(?5<font color=\"#0000A0\">$&</font>)"</font>
|
||||
<font color="#0000FF">"(?14<font color=\"#0000FF\">$&</font>)"</font>
|
||||
<font color="#0000FF">"(?17<B>$&</B>)"</font>;
|
||||
<font color="#0000FF">"(?2<I><font color=\"#000080\">$&</font></I>)"</font>
|
||||
<font color="#0000FF">"(?3<font color=\"#0000A0\">$&</font>)"</font>
|
||||
<font color="#0000FF">"(?4<font color=\"#0000FF\">$&</font>)"</font>
|
||||
<font color="#0000FF">"(?5<B>$&</B>)"</font>;
|
||||
|
||||
<b>const</b> <b>char</b>* header_text = <font color="#0000FF">"<HTML>\n<HEAD>\n"</font>
|
||||
<font color="#0000FF">"<TITLE>Auto-generated html formated source</TITLE>\n"</font>
|
||||
<font color="#0000FF">"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=windows-1252\">\n"</font>
|
||||
<font color="#0000FF">"</HEAD>\n"</font>
|
||||
<font color="#0000FF">"<BODY LINK=\"#0000ff\" VLINK=\"#800080\" BGCOLOR=\"#ffff99\">\n"</font>
|
||||
<font color="#0000FF">"<BODY LINK=\"#0000ff\" VLINK=\"#800080\" BGCOLOR=\"#ffffff\">\n"</font>
|
||||
<font color="#0000FF">"<P> </P>\n<PRE>"</font>;
|
||||
|
||||
<b>const</b> <b>char</b>* footer_text = <font color="#0000FF">"</PRE>\n</BODY>\n\n"</font>;
|
||||
|
Reference in New Issue
Block a user