RPA Toolkit
modified the RPA error definitions.
authorMartin Stoilov <martin@rpasearch.com>
Wed, 22 Jun 2011 06:43:21 +0000 (23:43 -0700)
committerMartin Stoilov <martin@rpasearch.com>
Wed, 22 Jun 2011 06:43:21 +0000 (23:43 -0700)
phpext/prpa/prpa.c
rgrep/rpagrep.c
rgrep/unix/main.c
rpa/rpadbex.c
rpa/rpaerror.h
tests/testmisc/rpagen-test.c

index 69dd949..d859a83 100644 (file)
@@ -157,6 +157,21 @@ PHP_MINIT_FUNCTION(prpa)
     REGISTER_LONG_CONSTANT("RPA_RECORD_END", RPA_RECORD_END, CONST_CS | CONST_PERSISTENT);
     REGISTER_LONG_CONSTANT("RPA_DBEXCFG_DEBUG", RPA_DBEXCFG_DEBUG, CONST_CS | CONST_PERSISTENT);
     REGISTER_LONG_CONSTANT("RPA_DBEXCFG_OPTIMIZATIONS", RPA_DBEXCFG_OPTIMIZATIONS, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("RPA_E_NONE", RPA_E_NONE, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("RPA_E_OUTOFMEM", RPA_E_OUTOFMEM, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("RPA_E_NOTCOMPILED", RPA_E_NOTCOMPILED, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("RPA_E_NOTOPEN", RPA_E_NOTOPEN, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("RPA_E_NOTCLOSED", RPA_E_NOTCLOSED, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("RPA_E_NOTFOUND", RPA_E_NOTFOUND, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("RPA_E_SYNTAXERROR", RPA_E_SYNTAXERROR, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("RPA_E_UNRESOLVEDSYMBOL", RPA_E_UNRESOLVEDSYMBOL, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("RPA_E_PARAM", RPA_E_PARAM, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("RPA_E_COMPILE", RPA_E_COMPILE, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("RPA_E_EXECUTION", RPA_E_EXECUTION, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("RPA_E_USERABORT", RPA_E_USERABORT, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("RPA_E_RULEABORT", RPA_E_RULEABORT, CONST_CS | CONST_PERSISTENT);
+    REGISTER_LONG_CONSTANT("RPA_E_INVALIDINPUT", RPA_E_INVALIDINPUT, CONST_CS | CONST_PERSISTENT);
+
        return SUCCESS;
 }
 /* }}} */
index 7396804..8f66c75 100644 (file)
@@ -145,7 +145,7 @@ int rpa_grep_load_pattern(rpa_grep_t *pGrep, rpa_buffer_t *buf)
        if (ret < 0) {
                rpa_errinfo_t errinfo;
                rpa_dbex_lasterrorinfo(pGrep->hDbex, &errinfo);
-               if (errinfo.code == RPA_E_SYNTAX_ERROR) {
+               if (errinfo.code == RPA_E_SYNTAXERROR) {
                        pattern += errinfo.offset;
                        for (line = 1; pattern >= buf->s; --pattern) {
                                if (*pattern == '\n')
index 5e566dd..9908f18 100644 (file)
@@ -195,7 +195,7 @@ int main(int argc, const char *argv[])
        if (rpa_dbex_compile(pGrep->hDbex) < 0) {
                rpa_errinfo_t errinfo;
                rpa_dbex_lasterrorinfo(pGrep->hDbex, &errinfo);
-               if (errinfo.code == RPA_E_UNRESOLVED_SYMBOL) {
+               if (errinfo.code == RPA_E_UNRESOLVEDSYMBOL) {
                        fprintf(stdout, "ERROR: Unresolved Symbol: %s\n", errinfo.name);
                } else {
                        fprintf(stdout, "ERROR %ld: Compilation failed.\n", errinfo.code);
index 148c4fc..20a0692 100644 (file)
@@ -226,16 +226,16 @@ static rinteger rpa_dbex_rh_uid(rpadbex_t *dbex, rlong rec)
 
        if (prec->type & RPA_RECORD_START) {
                if (rpa_dbex_rulename(dbex, rec, &name, &namesize) < 0) {
-                       RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_SYNTAX_ERROR);
+                       RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_SYNTAXERROR);
                        return -1;
                }
                pnumrec = rpa_dbex_record(dbex, rpa_recordtree_lastchild(dbex->records, rec, RPA_RECORD_END));
                if (!pnumrec) {
-                       RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_SYNTAX_ERROR);
+                       RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_SYNTAXERROR);
                        return -1;
                }
                if (rpa_record2long(pnumrec, &uid) < 0) {
-                       RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_SYNTAX_ERROR);
+                       RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_SYNTAXERROR);
                        return -1;
                }
                rpa_compiler_rulepref_set_ruleuid(dbex->co, name, namesize, uid);
@@ -258,16 +258,16 @@ static rinteger rpa_dbex_rh_uid(rpadbex_t *dbex, rlong rec)
        R_ASSERT(prec);
        rpa_dbex_debug_recordhead(dbex, rec);
        if (rpa_dbex_rulename(dbex, rec, &name, &namesize) < 0) {
-               RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_SYNTAX_ERROR);
+               RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_SYNTAXERROR);
                return -1;
        }
        pnumrec = rpa_dbex_record(dbex, rpa_recordtree_lastchild(dbex->records, rec, RPA_RECORD_END));
        if (!pnumrec) {
-               RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_SYNTAX_ERROR);
+               RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_SYNTAXERROR);
                return -1;
        }
        if (rpa_record2long(pnumrec, &uid) < 0) {
-               RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_SYNTAX_ERROR);
+               RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_SYNTAXERROR);
                return -1;
        }
        rpa_compiler_rulepref_set_ruleuid(dbex->co, name, namesize, uid);
@@ -1232,7 +1232,7 @@ static rinteger rpa_dbex_rh_aref(rpadbex_t *dbex, rlong rec)
        if ((prec->usertype & RPA_LOOP_PATH) && rpa_parseinfo_loopdetect(dbex, rec, rpa_dbex_firstinlined(dbex))) {
                info = (rpa_ruleinfo_t *) r_harray_get(dbex->rules, rpa_dbex_lookup(dbex, name, namesize));
                if (!info) {
-                       RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_UNRESOLVED_SYMBOL);
+                       RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_UNRESOLVEDSYMBOL);
                        RPA_DBEX_SETERRINFO_NAME(dbex, name, namesize);
                        return -1;
                }
@@ -1287,7 +1287,7 @@ static rinteger rpa_dbex_rh_aref(rpadbex_t *dbex, rlong rec)
                if ((prec->usertype & RPA_LOOP_PATH) && rpa_parseinfo_loopdetect(dbex, rec, rpa_dbex_firstinlined(dbex))) {
                        info = (rpa_ruleinfo_t *) r_harray_get(dbex->rules, rpa_dbex_lookup(dbex, name, namesize));
                        if (!info) {
-                               RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_UNRESOLVED_SYMBOL);
+                               RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_UNRESOLVEDSYMBOL);
                                RPA_DBEX_SETERRINFO_NAME(dbex, name, namesize);
                                return -1;
                        }
@@ -1731,7 +1731,7 @@ rlong rpa_dbex_load(rpadbex_t *dbex, const rchar *rules, rsize_t size)
                        if (*ptext == '\n')
                                line += 1;
                }
-               RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_SYNTAX_ERROR);
+               RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_SYNTAXERROR);
                RPA_DBEX_SETERRINFO_OFFSET(dbex, ret);
                RPA_DBEX_SETERRINFO_LINE(dbex, line);
                return -1;
@@ -2194,7 +2194,7 @@ rinteger rpa_dbex_compile(rpadbex_t *dbex)
        }
 
        if (rvm_codegen_relocate(dbex->co->cg, &labelerr) < 0) {
-               RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_UNRESOLVED_SYMBOL);
+               RPA_DBEX_SETERRINFO_CODE(dbex, RPA_E_UNRESOLVEDSYMBOL);
                RPA_DBEX_SETERRINFO_NAME(dbex, labelerr->name->str, labelerr->name->size);
                return -1;
        }
index 5f00cf3..4ecfd4e 100644 (file)
 
 #define RPA_E_NONE 0
 #define RPA_E_OUTOFMEM 1001
-#define RPA_E_INVALID_INPUT 1002
+#define RPA_E_NOTCOMPILED 1002
 #define RPA_E_NOTOPEN 1003
 #define RPA_E_NOTCLOSED 1004
 #define RPA_E_NOTFOUND 1005
-#define RPA_E_SYNTAX_ERROR 1006
-#define RPA_E_UNRESOLVED_SYMBOL 1007
+#define RPA_E_SYNTAXERROR 1006
+#define RPA_E_UNRESOLVEDSYMBOL 1007
 #define RPA_E_PARAM 1008
 #define RPA_E_COMPILE 1009
-#define RPA_E_NOTCOMPILED 1010
 
 #define RPA_E_EXECUTION 2001
 #define RPA_E_USERABORT 2002
 #define RPA_E_RULEABORT 2003
+#define RPA_E_INVALIDINPUT 2004
 
 /**
  * \typedef rpaerror_t
index a3891ee..f490d1e 100644 (file)
@@ -2089,7 +2089,7 @@ void rpagen_load_rules(rpa_dbex_handle dbex, rvm_compiler_t *co)
                        if (*pattern == '\n')
                                line += 1;
                }
-               fprintf(stdout, "Line: %d, RPA LOAD ERROR: %s\n", line, (rpa_dbex_get_error(dbex) == RPA_E_SYNTAX_ERROR) ? "Syntax Error." : "Pattern Loading failed.");
+               fprintf(stdout, "Line: %d, RPA LOAD ERROR: %s\n", line, (rpa_dbex_get_error(dbex) == RPA_E_SYNTAXERROR) ? "Syntax Error." : "Pattern Loading failed.");
                goto error;
        }