Added 'prefix' and 'suffix' for keyword-list

master
Yevgen Muntyan 2006-04-27 00:17:04 -05:00
parent 0c93d6509e
commit 3de7d80d8f
7 changed files with 293 additions and 271 deletions

View File

@ -933,12 +933,14 @@ static KeywordXML*
keyword_xml_parse (xmlNode *node)
{
KeywordXML *xml = NULL;
xmlChar *name = NULL, *word_boundary = NULL;
xmlChar *name = NULL, *word_boundary = NULL, *prefix = NULL, *suffix = NULL;
g_assert (IS_KEYWORD_LIST_NODE (node));
name = GET_PROP (node, KEYWORD_NAME_PROP);
word_boundary = GET_PROP (node, KEYWORD_WBNDRY_PROP);
prefix = GET_PROP (node, KEYWORD_PREFIX_PROP);
suffix = GET_PROP (node, KEYWORD_SUFFIX_PROP);
if (!name || !name[0])
{
@ -949,11 +951,15 @@ keyword_xml_parse (xmlNode *node)
xml = g_new0 (KeywordXML, 1);
xml->name = STRDUP (name);
xml->word_boundary = parse_bool (word_boundary, TRUE)
xml->word_boundary = parse_bool (word_boundary, TRUE);
xml->prefix = STRDUP (prefix);
xml->suffix = STRDUP (suffix);
DEBUG_PRINT ({
g_print ("keyword-list: %s\n", name);
g_print (" word-boundary: %s\n", xml->word_boundary ? "TRUE" : "FALSE");
g_print (" prefix: %s\n", xml->prefix ? xml->prefix : "<NULL>");
g_print (" suffix: %s\n", xml->suffix ? xml->suffix : "<NULL>");
g_print ("\n");
});
@ -994,11 +1000,15 @@ keyword_xml_parse (xmlNode *node)
xml->words = g_slist_reverse (xml->words);
STRING_FREE (name);
STRING_FREE (prefix);
STRING_FREE (suffix);
STRING_FREE (word_boundary);
return xml;
error:
STRING_FREE (name);
STRING_FREE (prefix);
STRING_FREE (suffix);
STRING_FREE (word_boundary);
keyword_xml_free (xml);
return NULL;
@ -1013,6 +1023,8 @@ keyword_xml_free (KeywordXML *xml)
g_slist_foreach (xml->words, (GFunc) g_free, NULL);
g_slist_free (xml->words);
g_free (xml->name);
g_free (xml->suffix);
g_free (xml->prefix);
g_free (xml);
}
}
@ -2047,6 +2059,7 @@ rule_keywords_xml_create_rule (RuleKeywordsXML *xml,
return moo_rule_keywords_new (kw_xml->words,
rule_xml_get_flags (xml),
kw_xml->word_boundary,
kw_xml->prefix, kw_xml->suffix,
rule_xml_get_style (xml));
}

View File

@ -96,6 +96,8 @@ struct _KeywordXML {
GSList *words; /* char*; must not be empty */
guint n_words;
gboolean word_boundary; /* optional, defaults to TRUE */
char *prefix; /* optional, defaults to NULL */
char *suffix; /* optional, defaults to NULL */
};
struct _ContextXML {

View File

@ -772,6 +772,8 @@ MooRule*
moo_rule_keywords_new (GSList *words,
MooRuleFlags flags,
gboolean word_boundary,
const char *prefix,
const char *suffix,
const char *style)
{
GSList *l;
@ -780,10 +782,10 @@ moo_rule_keywords_new (GSList *words,
g_return_val_if_fail (words != NULL, NULL);
if (word_boundary)
pattern = g_string_new ("\\b(");
else
pattern = g_string_new ("(");
pattern = g_string_new (NULL);
g_string_printf (pattern, "%s%s(",
word_boundary ? "\\b" : "",
prefix ? prefix : "");
for (l = words; l != NULL; l = l->next)
{
@ -801,10 +803,9 @@ moo_rule_keywords_new (GSList *words,
g_string_append (pattern, word);
}
if (word_boundary)
g_string_append (pattern, ")\\b");
else
g_string_append (pattern, ")");
g_string_append_printf (pattern, ")%s%s",
suffix ? suffix : "",
word_boundary ? "\\b" : "");
rule = moo_rule_regex_new (pattern->str, TRUE, 0, 0, flags, style);

View File

@ -74,6 +74,8 @@ MooRule *moo_rule_any_char_new (const char *string,
MooRule *moo_rule_keywords_new (GSList *words,
MooRuleFlags flags,
gboolean word_boundary,
const char *prefix,
const char *suffix,
const char *style);
MooRule *moo_rule_zero_new (MooRuleFlags flags);
MooRule *moo_rule_include_new (MooContext *context);

View File

@ -74,6 +74,8 @@
#define KEYWORD_NAME_PROP "name"
#define KEYWORD_WBNDRY_PROP "word-boundary"
#define KEYWORD_PREFIX_PROP "prefix"
#define KEYWORD_SUFFIX_PROP "suffix"
#define CONTEXT_NAME_PROP "name"
#define CONTEXT_STYLE_PROP "style"

View File

@ -44,6 +44,8 @@
<!ATTLIST keyword-list
name CDATA #REQUIRED
word-boundary CDATA #IMPLIED
prefix CDATA #IMPLIED
suffix CDATA #IMPLIED
>
<!-- keyword -->

View File

@ -9,265 +9,265 @@
<keyword>\\input</keyword>
</keyword-list>
<keyword-list name="Keyword" word-boundary="False">
<keyword>@WHITESPACE</keyword>
<keyword>@!</keyword>
<keyword>@"</keyword>
<keyword>@'</keyword>
<keyword>@\*</keyword>
<keyword>@,</keyword>
<keyword>@-</keyword>
<keyword>@\.</keyword>
<keyword>@:</keyword>
<keyword>@=</keyword>
<keyword>@\?</keyword>
<keyword>@\^</keyword>
<keyword>@`</keyword>
<keyword>@\{</keyword>
<keyword>@}</keyword>
<keyword>@=</keyword>
<keyword>@aa\{}</keyword>
<keyword>@AA\{}</keyword>
<keyword>@ae\{}</keyword>
<keyword>@AE\{}</keyword>
<keyword>@afourpaper</keyword>
<keyword>@appendix</keyword>
<keyword>@appendixsec</keyword>
<keyword>@appendixsection</keyword>
<keyword>@appendixsubsec</keyword>
<keyword>@appendixsubsubsec</keyword>
<keyword>@asis</keyword>
<keyword>@author</keyword>
<keyword>@b</keyword>
<keyword>@bullet\{}</keyword>
<keyword>@bye</keyword>
<keyword>@c</keyword>
<keyword>@cartouche</keyword>
<keyword>@center</keyword>
<keyword>@centerchap</keyword>
<keyword>@chapheading</keyword>
<keyword>@chapter</keyword>
<keyword>@cindex</keyword>
<keyword>@cite</keyword>
<keyword>@clear</keyword>
<keyword>@code</keyword>
<keyword>@comment</keyword>
<keyword>@contents</keyword>
<keyword>@copyright\{}</keyword>
<keyword>@defcodeindex</keyword>
<keyword>@defcv</keyword>
<keyword>@defcvx</keyword>
<keyword>@deffn</keyword>
<keyword>@deffnx</keyword>
<keyword>@defindex</keyword>
<keyword>@definfoenclose</keyword>
<keyword>@defivar</keyword>
<keyword>@defivarx</keyword>
<keyword>@defmac</keyword>
<keyword>@defmacx</keyword>
<keyword>@defmethod</keyword>
<keyword>@defmethodx</keyword>
<keyword>@defop</keyword>
<keyword>@defopx</keyword>
<keyword>@defopt</keyword>
<keyword>@defoptx</keyword>
<keyword>@defspec</keyword>
<keyword>@defspecx</keyword>
<keyword>@deftp</keyword>
<keyword>@deftpx</keyword>
<keyword>@deftypefn</keyword>
<keyword>@deftypefnx</keyword>
<keyword>@deftypefun</keyword>
<keyword>@deftypefunx</keyword>
<keyword>@deftypemethod</keyword>
<keyword>@deftypemethodx</keyword>
<keyword>@deftypevr</keyword>
<keyword>@deftypevrx</keyword>
<keyword>@deftypevar</keyword>
<keyword>@deftypevarx</keyword>
<keyword>@defun</keyword>
<keyword>@defunx</keyword>
<keyword>@defvar</keyword>
<keyword>@defvarx</keyword>
<keyword>@detailmenu\{}</keyword>
<keyword>@dfn</keyword>
<keyword>@dircategory</keyword>
<keyword>@direntry</keyword>
<keyword>@display</keyword>
<keyword>@dmn</keyword>
<keyword>@dotaccent</keyword>
<keyword>@dots\{}</keyword>
<keyword>@email</keyword>
<keyword>@emph</keyword>
<keyword>@end\\scartouche</keyword>
<keyword>@end\\sdirentry</keyword>
<keyword>@end\\senumerate</keyword>
<keyword>@end\\sexample</keyword>
<keyword>@end\\sflushleft</keyword>
<keyword>@end\\sflushright</keyword>
<keyword>@end\\sformat</keyword>
<keyword>@end\\sftable</keyword>
<keyword>@end\\sgroup</keyword>
<keyword>@end\\shtml</keyword>
<keyword>@end\\sifclear</keyword>
<keyword>@end\\sifhtml</keyword>
<keyword>@end\\sifinfo</keyword>
<keyword>@end\\sifnothtml</keyword>
<keyword>@end\\sifnotinfo</keyword>
<keyword>@end\\sifnottex</keyword>
<keyword>@end\\sifset</keyword>
<keyword>@end\\siftex</keyword>
<keyword>@end\\signore</keyword>
<keyword>@end\\sitemize</keyword>
<keyword>@end\\slisp</keyword>
<keyword>@end\\smenu</keyword>
<keyword>@end\\smultitable</keyword>
<keyword>@end\\squotation</keyword>
<keyword>@end\\ssmallexample</keyword>
<keyword>@end\\ssmalllisp</keyword>
<keyword>@end\\stable</keyword>
<keyword>@end\\stex</keyword>
<keyword>@end\\stitlepage</keyword>
<keyword>@end\\svtable</keyword>
<keyword>@enddots\{}</keyword>
<keyword>@enumerate</keyword>
<keyword>@equiv\{}</keyword>
<keyword>@error\{}</keyword>
<keyword>@evenfooting</keyword>
<keyword>@evenheading</keyword>
<keyword>@everyfooting</keyword>
<keyword>@everyheading</keyword>
<keyword>@example</keyword>
<keyword>@exclamdown\{}</keyword>
<keyword>@exdent</keyword>
<keyword>@expansion\{}</keyword>
<keyword>@file</keyword>
<keyword>@finalout</keyword>
<keyword>@findex</keyword>
<keyword>@flushleft</keyword>
<keyword>@flushright</keyword>
<keyword>@footnote</keyword>
<keyword>@footnotestyle</keyword>
<keyword>@format</keyword>
<keyword>@ftable</keyword>
<keyword>@group</keyword>
<keyword>@H</keyword>
<keyword>@heading</keyword>
<keyword>@headings</keyword>
<keyword>@html</keyword>
<keyword>@hyphenation</keyword>
<keyword>@i</keyword>
<keyword>@ifclear</keyword>
<keyword>@ifhtml</keyword>
<keyword>@ifinfo</keyword>
<keyword>@ifnothtml</keyword>
<keyword>@ifnotinfo</keyword>
<keyword>@ifnottex</keyword>
<keyword>@ifset</keyword>
<keyword>@iftex</keyword>
<keyword>@ignore</keyword>
<keyword>@image</keyword>
<keyword>@include</keyword>
<keyword>@inforef</keyword>
<keyword>@item</keyword>
<keyword>@itemize</keyword>
<keyword>@itemx</keyword>
<keyword>@kbd</keyword>
<keyword>@kbdinputstyle</keyword>
<keyword>@key</keyword>
<keyword>@kindex</keyword>
<keyword>@l\{}</keyword>
<keyword>@L\{}</keyword>
<keyword>@lisp</keyword>
<keyword>@lowersections</keyword>
<keyword>@macro</keyword>
<keyword>@majorheading</keyword>
<keyword>@math</keyword>
<keyword>@menu</keyword>
<keyword>@minus\{}</keyword>
<keyword>@multitable</keyword>
<keyword>@need</keyword>
<keyword>@node</keyword>
<keyword>@noindent</keyword>
<keyword>@o\{}</keyword>
<keyword>@O\{}</keyword>
<keyword>@oddfooting</keyword>
<keyword>@oddheading</keyword>
<keyword>@oe\{}</keyword>
<keyword>@OE\{}</keyword>
<keyword>@page</keyword>
<keyword>@paragraphindent</keyword>
<keyword>@pindex</keyword>
<keyword>@point\{}</keyword>
<keyword>@pounds\{}</keyword>
<keyword>@print\{}</keyword>
<keyword>@printindex</keyword>
<keyword>@pxref</keyword>
<keyword>@questiondown\{}</keyword>
<keyword>@quotation</keyword>
<keyword>@r</keyword>
<keyword>@raisesections</keyword>
<keyword>@ref</keyword>
<keyword>@refill</keyword>
<keyword>@result\{}</keyword>
<keyword>@ringaccent</keyword>
<keyword>@samp</keyword>
<keyword>@sc</keyword>
<keyword>@section</keyword>
<keyword>@set</keyword>
<keyword>@setchapternewpage</keyword>
<keyword>@setfilename</keyword>
<keyword>@settitle</keyword>
<keyword>@shortcontents</keyword>
<keyword>@shorttitlepage</keyword>
<keyword>@smallbook</keyword>
<keyword>@smallexample</keyword>
<keyword>@smalllisp</keyword>
<keyword>@sp</keyword>
<keyword>@ss\{}</keyword>
<keyword>@strong</keyword>
<keyword>@subheading</keyword>
<keyword>@subsection</keyword>
<keyword>@subsubheading</keyword>
<keyword>@subsubsection</keyword>
<keyword>@subtitle</keyword>
<keyword>@summarycontents</keyword>
<keyword>@syncodeindex</keyword>
<keyword>@synindex</keyword>
<keyword>@t</keyword>
<keyword>@tab</keyword>
<keyword>@table</keyword>
<keyword>@TeX\{}</keyword>
<keyword>@tex</keyword>
<keyword>@thischapter</keyword>
<keyword>@thischaptername</keyword>
<keyword>@thisfile</keyword>
<keyword>@thispage</keyword>
<keyword>@thistitle</keyword>
<keyword>@tieaccent</keyword>
<keyword>@tindex</keyword>
<keyword>@title</keyword>
<keyword>@titlefont</keyword>
<keyword>@titlepage</keyword>
<keyword>@today\{}</keyword>
<keyword>@top</keyword>
<keyword>@u</keyword>
<keyword>@ubaraccent</keyword>
<keyword>@udotaccent</keyword>
<keyword>@unnumbered</keyword>
<keyword>@unnumberedsec</keyword>
<keyword>@unnumberedsubsec</keyword>
<keyword>@unnumberedsubsubsec</keyword>
<keyword>@uref</keyword>
<keyword>@url</keyword>
<keyword>@v</keyword>
<keyword>@value</keyword>
<keyword>@var</keyword>
<keyword>@vindex</keyword>
<keyword>@vskip</keyword>
<keyword>@vtable</keyword>
<keyword>@w</keyword>
<keyword>@xref</keyword>
<keyword-list name="Keyword" word-boundary="False" prefix="@">
<keyword>WHITESPACE</keyword>
<keyword>!</keyword>
<keyword>"</keyword>
<keyword>'</keyword>
<keyword>\*</keyword>
<keyword>,</keyword>
<keyword>-</keyword>
<keyword>\.</keyword>
<keyword>:</keyword>
<keyword>=</keyword>
<keyword>\?</keyword>
<keyword>\^</keyword>
<keyword>`</keyword>
<keyword>\{</keyword>
<keyword>}</keyword>
<keyword>=</keyword>
<keyword>aa\{}</keyword>
<keyword>AA\{}</keyword>
<keyword>ae\{}</keyword>
<keyword>AE\{}</keyword>
<keyword>afourpaper</keyword>
<keyword>appendix</keyword>
<keyword>appendixsec</keyword>
<keyword>appendixsection</keyword>
<keyword>appendixsubsec</keyword>
<keyword>appendixsubsubsec</keyword>
<keyword>asis</keyword>
<keyword>author</keyword>
<keyword>b</keyword>
<keyword>bullet\{}</keyword>
<keyword>bye</keyword>
<keyword>c</keyword>
<keyword>cartouche</keyword>
<keyword>center</keyword>
<keyword>centerchap</keyword>
<keyword>chapheading</keyword>
<keyword>chapter</keyword>
<keyword>cindex</keyword>
<keyword>cite</keyword>
<keyword>clear</keyword>
<keyword>code</keyword>
<keyword>comment</keyword>
<keyword>contents</keyword>
<keyword>copyright\{}</keyword>
<keyword>defcodeindex</keyword>
<keyword>defcv</keyword>
<keyword>defcvx</keyword>
<keyword>deffn</keyword>
<keyword>deffnx</keyword>
<keyword>defindex</keyword>
<keyword>definfoenclose</keyword>
<keyword>defivar</keyword>
<keyword>defivarx</keyword>
<keyword>defmac</keyword>
<keyword>defmacx</keyword>
<keyword>defmethod</keyword>
<keyword>defmethodx</keyword>
<keyword>defop</keyword>
<keyword>defopx</keyword>
<keyword>defopt</keyword>
<keyword>defoptx</keyword>
<keyword>defspec</keyword>
<keyword>defspecx</keyword>
<keyword>deftp</keyword>
<keyword>deftpx</keyword>
<keyword>deftypefn</keyword>
<keyword>deftypefnx</keyword>
<keyword>deftypefun</keyword>
<keyword>deftypefunx</keyword>
<keyword>deftypemethod</keyword>
<keyword>deftypemethodx</keyword>
<keyword>deftypevr</keyword>
<keyword>deftypevrx</keyword>
<keyword>deftypevar</keyword>
<keyword>deftypevarx</keyword>
<keyword>defun</keyword>
<keyword>defunx</keyword>
<keyword>defvar</keyword>
<keyword>defvarx</keyword>
<keyword>detailmenu\{}</keyword>
<keyword>dfn</keyword>
<keyword>dircategory</keyword>
<keyword>direntry</keyword>
<keyword>display</keyword>
<keyword>dmn</keyword>
<keyword>dotaccent</keyword>
<keyword>dots\{}</keyword>
<keyword>email</keyword>
<keyword>emph</keyword>
<keyword>end\\scartouche</keyword>
<keyword>end\\sdirentry</keyword>
<keyword>end\\senumerate</keyword>
<keyword>end\\sexample</keyword>
<keyword>end\\sflushleft</keyword>
<keyword>end\\sflushright</keyword>
<keyword>end\\sformat</keyword>
<keyword>end\\sftable</keyword>
<keyword>end\\sgroup</keyword>
<keyword>end\\shtml</keyword>
<keyword>end\\sifclear</keyword>
<keyword>end\\sifhtml</keyword>
<keyword>end\\sifinfo</keyword>
<keyword>end\\sifnothtml</keyword>
<keyword>end\\sifnotinfo</keyword>
<keyword>end\\sifnottex</keyword>
<keyword>end\\sifset</keyword>
<keyword>end\\siftex</keyword>
<keyword>end\\signore</keyword>
<keyword>end\\sitemize</keyword>
<keyword>end\\slisp</keyword>
<keyword>end\\smenu</keyword>
<keyword>end\\smultitable</keyword>
<keyword>end\\squotation</keyword>
<keyword>end\\ssmallexample</keyword>
<keyword>end\\ssmalllisp</keyword>
<keyword>end\\stable</keyword>
<keyword>end\\stex</keyword>
<keyword>end\\stitlepage</keyword>
<keyword>end\\svtable</keyword>
<keyword>enddots\{}</keyword>
<keyword>enumerate</keyword>
<keyword>equiv\{}</keyword>
<keyword>error\{}</keyword>
<keyword>evenfooting</keyword>
<keyword>evenheading</keyword>
<keyword>everyfooting</keyword>
<keyword>everyheading</keyword>
<keyword>example</keyword>
<keyword>exclamdown\{}</keyword>
<keyword>exdent</keyword>
<keyword>expansion\{}</keyword>
<keyword>file</keyword>
<keyword>finalout</keyword>
<keyword>findex</keyword>
<keyword>flushleft</keyword>
<keyword>flushright</keyword>
<keyword>footnote</keyword>
<keyword>footnotestyle</keyword>
<keyword>format</keyword>
<keyword>ftable</keyword>
<keyword>group</keyword>
<keyword>H</keyword>
<keyword>heading</keyword>
<keyword>headings</keyword>
<keyword>html</keyword>
<keyword>hyphenation</keyword>
<keyword>i</keyword>
<keyword>ifclear</keyword>
<keyword>ifhtml</keyword>
<keyword>ifinfo</keyword>
<keyword>ifnothtml</keyword>
<keyword>ifnotinfo</keyword>
<keyword>ifnottex</keyword>
<keyword>ifset</keyword>
<keyword>iftex</keyword>
<keyword>ignore</keyword>
<keyword>image</keyword>
<keyword>include</keyword>
<keyword>inforef</keyword>
<keyword>item</keyword>
<keyword>itemize</keyword>
<keyword>itemx</keyword>
<keyword>kbd</keyword>
<keyword>kbdinputstyle</keyword>
<keyword>key</keyword>
<keyword>kindex</keyword>
<keyword>l\{}</keyword>
<keyword>L\{}</keyword>
<keyword>lisp</keyword>
<keyword>lowersections</keyword>
<keyword>macro</keyword>
<keyword>majorheading</keyword>
<keyword>math</keyword>
<keyword>menu</keyword>
<keyword>minus\{}</keyword>
<keyword>multitable</keyword>
<keyword>need</keyword>
<keyword>node</keyword>
<keyword>noindent</keyword>
<keyword>o\{}</keyword>
<keyword>O\{}</keyword>
<keyword>oddfooting</keyword>
<keyword>oddheading</keyword>
<keyword>oe\{}</keyword>
<keyword>OE\{}</keyword>
<keyword>page</keyword>
<keyword>paragraphindent</keyword>
<keyword>pindex</keyword>
<keyword>point\{}</keyword>
<keyword>pounds\{}</keyword>
<keyword>print\{}</keyword>
<keyword>printindex</keyword>
<keyword>pxref</keyword>
<keyword>questiondown\{}</keyword>
<keyword>quotation</keyword>
<keyword>r</keyword>
<keyword>raisesections</keyword>
<keyword>ref</keyword>
<keyword>refill</keyword>
<keyword>result\{}</keyword>
<keyword>ringaccent</keyword>
<keyword>samp</keyword>
<keyword>sc</keyword>
<keyword>section</keyword>
<keyword>set</keyword>
<keyword>setchapternewpage</keyword>
<keyword>setfilename</keyword>
<keyword>settitle</keyword>
<keyword>shortcontents</keyword>
<keyword>shorttitlepage</keyword>
<keyword>smallbook</keyword>
<keyword>smallexample</keyword>
<keyword>smalllisp</keyword>
<keyword>sp</keyword>
<keyword>ss\{}</keyword>
<keyword>strong</keyword>
<keyword>subheading</keyword>
<keyword>subsection</keyword>
<keyword>subsubheading</keyword>
<keyword>subsubsection</keyword>
<keyword>subtitle</keyword>
<keyword>summarycontents</keyword>
<keyword>syncodeindex</keyword>
<keyword>synindex</keyword>
<keyword>t</keyword>
<keyword>tab</keyword>
<keyword>table</keyword>
<keyword>TeX\{}</keyword>
<keyword>tex</keyword>
<keyword>thischapter</keyword>
<keyword>thischaptername</keyword>
<keyword>thisfile</keyword>
<keyword>thispage</keyword>
<keyword>thistitle</keyword>
<keyword>tieaccent</keyword>
<keyword>tindex</keyword>
<keyword>title</keyword>
<keyword>titlefont</keyword>
<keyword>titlepage</keyword>
<keyword>today\{}</keyword>
<keyword>top</keyword>
<keyword>u</keyword>
<keyword>ubaraccent</keyword>
<keyword>udotaccent</keyword>
<keyword>unnumbered</keyword>
<keyword>unnumberedsec</keyword>
<keyword>unnumberedsubsec</keyword>
<keyword>unnumberedsubsubsec</keyword>
<keyword>uref</keyword>
<keyword>url</keyword>
<keyword>v</keyword>
<keyword>value</keyword>
<keyword>var</keyword>
<keyword>vindex</keyword>
<keyword>vskip</keyword>
<keyword>vtable</keyword>
<keyword>w</keyword>
<keyword>xref</keyword>
</keyword-list>
<context name="Normal">