![]() |
Home | Libraries | Author | Links |
00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 00003 * 00004 * The contents of this file are subject to the Mozilla Public License Version 00005 * 1.1 (the "License"); you may not use this file except in compliance with 00006 * the License. You may obtain a copy of the License at 00007 * http://www.mozilla.org/MPL/ 00008 * 00009 * Software distributed under the License is distributed on an "AS IS" basis, 00010 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 00011 * for the specific language governing rights and limitations under the 00012 * License. 00013 * 00014 * The Original Code is the SysToMath C Libraries package (LibStmC). 00015 * 00016 * The Initial Developer of the Original Code is 00017 * Tom Michaelis, SysToMath. 00018 * Portions created by the Initial Developer are Copyright (C) 1989-2006 00019 * the Initial Developer. All Rights Reserved. 00020 * 00021 * Contributor(s): 00022 * 00023 * Alternatively, the contents of this file may be used under the terms of 00024 * either the GNU General Public License Version 2 or later (the "GPL"), or 00025 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 00026 * in which case the provisions of the GPL or the LGPL are applicable instead 00027 * of those above. If you wish to allow use of your version of this file only 00028 * under the terms of either the GPL or the LGPL, and not to allow others to 00029 * use your version of this file under the terms of the MPL, indicate your 00030 * decision by deleting the provisions above and replace them with the notice 00031 * and other provisions required by the GPL or the LGPL. If you do not delete 00032 * the provisions above, a recipient may use your version of this file under 00033 * the terms of any one of the MPL, the GPL or the LGPL. 00034 * 00035 * ***** END LICENSE BLOCK ***** */ 00036 00037 /****************************************************************************** 00038 * First Release 1989-03-15 00039 ******************************************************************************/ 00040 00041 00080 #ifndef STM_MATCH_H 00081 #define STM_MATCH_H 00082 00083 00084 /* Include header files and macro definitions. */ 00085 #include <stm/internal/_match.h> 00086 00087 00088 #ifdef __cplusplus 00089 extern "C" 00090 { 00091 #endif 00092 00093 00353 StmAbstractType (StmRe) /* Re */ 00354 00355 00356 00375 StmAbstractType (StmReCtrl) /* ReCtrl */ 00376 00377 00433 StmAbstractType (StmReMtc) /* ReMtc */ 00434 00435 00488 StmAbstractType (StmQreMtc) /* QreMtc */ 00489 00490 00541 StmDllSpec 00542 StmReCtrl stmReCtrlCreate (FILE *debug, jmp_buf *penvbuf, 00543 const char *xlatetab, const char *const *errtxt); 00544 00545 00555 StmDllSpec 00556 void stmReCtrlDestroy (StmReCtrl reCtrl); 00557 00558 00573 StmDllSpec 00574 stm_inline int stmReCtrlSetErrorEnv (StmReCtrl reCtrl, jmp_buf *penvbuf); 00575 00576 00583 #define StmMtcErrors \ 00584 /* Error number Standard error text */ \ 00585 StmMtcErr (StmMtcErrOk, "no error"), \ 00586 StmMtcErr (StmMtcErrInval, "invalid argument"), \ 00587 StmMtcErr (StmMtcErrNoMem, "no more memory on heap"), \ 00588 StmMtcErr (StmMtcErrMblkBig, "heap memory block too big"), \ 00589 StmMtcErr (StmMtcErrLong, "syntax error: <reStr> too long"), \ 00590 StmMtcErr (StmMtcErrPar, "syntax error: ')' missing"), \ 00591 StmMtcErr (StmMtcErrSubRe, "syntax error: '&'<reName>'&' expected"), \ 00592 StmMtcErr (StmMtcErrQreActName, "syntax error: ':'<actionNames>':' expected"),\ 00593 StmMtcErr (StmMtcErrShort, "syntax error: <reStr> too short"), \ 00594 StmMtcErr (StmMtcErrRange, "syntax error in <range>"), \ 00595 StmMtcErr (StmMtcErrGroup, "syntax error in <group>"), \ 00596 StmMtcErr (StmMtcErrGend, "syntax error: ']' missing"), \ 00597 StmMtcErr (StmMtcErrInvalRe, "syntax error: illegal <reStr>"), \ 00598 StmMtcErr (StmMtcErrNoAction, "syntax error: <qualifRe> action unnamed"), \ 00599 StmMtcErr (StmMtcErrIllegal, "syntax error: <char> must be masked by '%'"),\ 00600 StmMtcErr (StmMtcErrRecursion, "syntax error: infinite recursion"), \ 00601 StmMtcErr (StmMtcErrNoQre, "syntax error: illegal empty <qualifRe>"), \ 00602 StmMtcErr (StmMtcErrNoQreAct, "<qualifRe> action not defined"), \ 00603 StmMtcErr (StmMtcErrQreInit, "<qualifRe> action initialization failed"), \ 00604 StmMtcErr (StmMtcErrQreAction, "<qualifRe> action failed"), \ 00605 StmMtcErr (StmMtcErrQreRollback, "<qualifRe> action rollback failed"), \ 00606 StmMtcErr (StmMtcErrQreDeinit, "<qualifRe> action deinitialization failed"), \ 00607 StmMtcErr (StmMtcErrNoReStr, "<reStr> not defined"), \ 00608 StmMtcErr (StmMtcErrReInit, "<reStr> action initialization failed"), \ 00609 StmMtcErr (StmMtcErrReRollback, "<reStr> action rollback failed"), \ 00610 StmMtcErr (StmMtcErrReAction, "<reStr> action failed"), \ 00611 StmMtcErr (StmMtcErrReDeinit, "<reStr> action deinitialization failed"), \ 00612 00613 00617 #define StmMtcErr(nr, txt) nr 00618 00619 00623 enum StmReCtrlErrnos 00624 { 00625 StmMtcErrors 00626 StmMtcErrCount 00627 }; 00628 #undef StmMtcErr 00629 00630 00639 StmDllSpec 00640 stm_inline int stmReCtrlGetErrno (StmReCtrl reCtrl); 00641 00642 00654 StmDllSpec 00655 const char *stmReCtrlGetErrorMsg (StmReCtrl reCtrl); 00656 00657 00666 StmDllSpec 00667 stm_inline const char *stmReCtrlGetDebugMsg (StmReCtrl reCtrl); 00668 00669 00685 typedef struct 00686 { 00687 StmBool init : 1; 00688 StmBool action : 1; 00689 StmBool rollback : 1; 00690 StmBool deinit : 1; 00691 } 00692 StmMtcFctCmd; 00693 00694 00698 enum StmMtcFctResult 00699 { 00700 StmMtcFctError = -1, 00702 StmMtcFctOk = 0, 00704 StmMtcFctFail = 1, 00705 StmMtcFctReduce = 2 00709 }; 00710 00711 00783 StmDllSpec 00784 int stmQreActDef (StmReCtrl reCtrl, const char *qreactname, 00785 int (*qreFct) (StmMtcFctCmd cmd, StmQreMtc qreMtc)); 00786 00787 00805 StmDllSpec 00806 stm_inline const char *stmReMtcReName (StmReMtc reMtc); 00807 00808 00817 StmDllSpec 00818 stm_inline StmBool stmReMtcReNested (StmReMtc reMtc); 00819 00820 00830 StmDllSpec 00831 stm_inline const char *stmReMtcReContextName (StmReMtc reMtc); 00832 00833 00842 StmDllSpec 00843 stm_inline const char *stmReMtcReStr (StmReMtc reMtc); 00844 00845 00853 StmDllSpec 00854 stm_inline int stmReMtcReStrLen (StmReMtc reMtc); 00855 00856 00863 StmDllSpec 00864 stm_inline void *stmReMtcEnv (StmReMtc reMtc); 00865 00866 00873 StmDllSpec 00874 stm_inline void *stmReMtcData (StmReMtc reMtc); 00875 00876 00883 StmDllSpec 00884 stm_inline void stmReMtcSetData (StmReMtc reMtc, void *data); 00885 00886 00893 StmDllSpec 00894 stm_inline const char *stmReMtcStr (StmReMtc reMtc); 00895 00896 00904 StmDllSpec 00905 stm_inline int stmReMtcLen (StmReMtc reMtc); 00906 00907 00914 StmDllSpec 00915 stm_inline int stmReMtcQreMtcCount (StmReMtc reMtc); 00916 00917 00926 StmDllSpec 00927 stm_inline StmQreMtc stmReMtcNthQreMtc (StmReMtc reMtc, unsigned nth); 00928 00929 00940 StmDllSpec 00941 stm_inline const char *stmReMtcNthQreMtcStr (StmReMtc reMtc, unsigned nth); 00942 00943 00954 StmDllSpec 00955 stm_inline int stmReMtcNthQreMtcLen (StmReMtc reMtc, unsigned nth); 00956 00957 00967 StmDllSpec 00968 stm_inline void *stmReMtcNthQreMtcData (StmReMtc reMtc, unsigned nth); 00969 00970 00982 StmDllSpec 00983 stm_inline int stmReMtcNthSimpleReMtcCount (StmReMtc reMtc, unsigned nth); 00984 00985 00995 StmDllSpec 00996 stm_inline StmReMtc stmReMtcNthMthSimpleReMtc (StmReMtc reMtc, 00997 unsigned nth, unsigned mth); 00998 00999 01011 StmDllSpec 01012 stm_inline const char *stmReMtcNthMthSimpleReMtcStr (StmReMtc reMtc, 01013 unsigned nth, 01014 unsigned mth); 01015 01016 01027 StmDllSpec 01028 stm_inline int stmReMtcNthMthSimpleReMtcLen (StmReMtc reMtc, 01029 unsigned nth, unsigned mth); 01030 01031 01043 StmDllSpec 01044 stm_inline void *stmReMtcNthMthSimpleReMtcData (StmReMtc reMtc, 01045 unsigned nth, unsigned mth); 01046 01047 01054 StmDllSpec 01055 stm_inline int stmReMtcMtermNr (StmReMtc reMtc); 01056 01057 01067 StmDllSpec 01068 stm_inline StmQreMtc stmReMtcSuperQreMtc (StmReMtc reMtc); 01069 01070 01080 StmDllSpec 01081 stm_inline void *stmReMtcSuperQreMtcData (StmReMtc reMtc); 01082 01083 01092 StmDllSpec 01093 stm_inline StmReMtc stmReMtcNthSuperReMtc (StmReMtc reMtc, unsigned nth); 01094 01095 01104 StmDllSpec 01105 stm_inline void *stmReMtcNthSuperReMtcData (StmReMtc reMtc, unsigned nth); 01106 01107 01114 StmDllSpec 01115 stm_inline int stmReMtcSimpleReMtcNr (StmReMtc reMtc); 01116 01117 01132 StmDllSpec 01133 stm_inline void *stmQreMtcEnv (StmQreMtc qreMtc); 01134 01135 01142 StmDllSpec 01143 stm_inline void *stmQreMtcData (StmQreMtc qreMtc); 01144 01145 01152 StmDllSpec 01153 stm_inline void stmQreMtcSetData (StmQreMtc qreMtc, void *data); 01154 01155 01162 StmDllSpec 01163 stm_inline const char *stmQreMtcStr (StmQreMtc qreMtc); 01164 01165 01173 StmDllSpec 01174 stm_inline int stmQreMtcLen (StmQreMtc qreMtc); 01175 01176 01184 StmDllSpec 01185 stm_inline int stmQreMtcSimpleReMtcCount (StmQreMtc qreMtc); 01186 01187 01196 StmDllSpec 01197 stm_inline StmReMtc stmQreMtcNthSimpleReMtc (StmQreMtc qreMtc, unsigned nth); 01198 01199 01210 StmDllSpec 01211 stm_inline const char *stmQreMtcNthSimpleReMtcStr (StmQreMtc qreMtc, 01212 unsigned nth); 01213 01214 01225 StmDllSpec 01226 stm_inline int stmQreMtcNthSimpleReMtcLen (StmQreMtc qreMtc, unsigned nth); 01227 01228 01238 StmDllSpec 01239 stm_inline void *stmQreMtcNthSimpleReMtcData (StmQreMtc qreMtc, 01240 unsigned nth); 01241 01242 01251 StmDllSpec 01252 stm_inline StmReMtc stmQreMtcSuperReMtc (StmQreMtc qreMtc); 01253 01254 01264 StmDllSpec 01265 stm_inline void *stmQreMtcSuperReMtcData (StmQreMtc qreMtc); 01266 01267 01276 StmDllSpec 01277 stm_inline StmReMtc stmQreMtcNthSuperReMtc (StmQreMtc qreMtc, unsigned nth); 01278 01279 01289 StmDllSpec 01290 stm_inline void *stmQreMtcNthSuperReMtcData (StmQreMtc qreMtc, unsigned nth); 01291 01292 01299 StmDllSpec 01300 stm_inline int stmQreMtcQualifReNr (StmQreMtc qreMtc); 01301 01302 01404 StmDllSpec 01405 StmRe stmReCreate (volatile StmReCtrl reCtrl, 01406 const char *reName, const char *reStr, 01407 int (*reFct) (StmMtcFctCmd cmd, StmReMtc reMtc)); 01408 01409 01423 StmDllSpec 01424 int stmReDestroy (StmRe re); 01425 01426 01445 StmDllSpec 01446 StmRe stmReGet (StmReCtrl reCtrl, const char *reName); 01447 01448 01455 StmDllSpec 01456 StmBool stmReTest (StmReCtrl reCtrl, const char *reName); 01457 01458 01479 StmDllSpec 01480 StmBool stmReMatch (StmRe re, const char *str, void *env, void *data); 01481 01482 01503 StmDllSpec 01504 StmBool stmReMatchSub (StmRe re, 01505 const char *str, int len, void *env, void *data); 01506 01507 01516 StmDllSpec 01517 stm_inline int stmReGetErrno (StmRe re); 01518 01519 01531 StmDllSpec 01532 const char *stmReGetErrorMsg (StmRe re); 01533 01534 01543 StmDllSpec 01544 stm_inline const char *stmReGetDebugMsg (StmRe re); 01545 01546 01554 StmDllSpec 01555 stm_inline const char *stmReGetReStr (StmRe re); 01556 01557 01564 #ifdef __cplusplus 01565 } 01566 #endif 01567 01568 01569 /* Include inline implementation. */ 01570 #include <stm/internal/_match.h> 01571 01572 01573 #endif
© Copyright Tom Michaelis 2002-2007
Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).