diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2005-08-22 14:43:43 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2005-08-22 14:43:43 +0000 |
commit | 0090bd524f6dee77bc4bbcad8e2158c5783f35a1 (patch) | |
tree | b2c42aaa68fd31845713dec53fe40de2e7141d0f /xmlregexp.c | |
parent | 355a023866e573462c65b2960491b1f5c6e3620b (diff) | |
download | android_external_libxml2-0090bd524f6dee77bc4bbcad8e2158c5783f35a1.tar.gz android_external_libxml2-0090bd524f6dee77bc4bbcad8e2158c5783f35a1.tar.bz2 android_external_libxml2-0090bd524f6dee77bc4bbcad8e2158c5783f35a1.zip |
exported xmlExpExpDerive(), added it to the testRegexp command line tool
* testRegexp.c xmlregexp.c include/libxml/xmlregexp.h: exported
xmlExpExpDerive(), added it to the testRegexp command line
tool when providing multiple expressions.
Daniel
Diffstat (limited to 'xmlregexp.c')
-rw-r--r-- | xmlregexp.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/xmlregexp.c b/xmlregexp.c index b4953e08..ffd9efbc 100644 --- a/xmlregexp.c +++ b/xmlregexp.c @@ -6820,6 +6820,43 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) { } /** + * xmlExpExpDerive: + * @ctxt: the expressions context + * @exp: the englobing expression + * @sub: the subexpression + * + * Evaluates the expression resulting from @exp consuming a sub expression @sub + * Based on algebraic derivation and sometimes direct Brzozowski derivation + * it usually tatkes less than linear time and can handle expressions generating + * infinite languages. + * + * Returns the resulting expression or NULL in case of internal error, the + * result must be freed + */ +xmlExpNodePtr +xmlExpExpDerive(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) { + if ((exp == NULL) || (ctxt == NULL) || (sub == NULL)) + return(NULL); + + /* + * O(1) speedups + */ + if (IS_NILLABLE(sub) && (!IS_NILLABLE(exp))) { +#ifdef DEBUG_DERIV + printf("Sub nillable and not exp : can't subsume\n"); +#endif + return(forbiddenExp); + } + if (xmlExpCheckCard(exp, sub) == 0) { +#ifdef DEBUG_DERIV + printf("sub generate longuer sequances than exp : can't subsume\n"); +#endif + return(forbiddenExp); + } + return(xmlExpExpDeriveInt(ctxt, exp, sub)); +} + +/** * xmlExpSubsume: * @ctxt: the expressions context * @exp: the englobing expression |