4 * Copyright (c) 2009-2011 project bchan
6 * This software is provided 'as-is', without any express or implied
7 * warranty. In no event will the authors be held liable for any damages
8 * arising from the use of this software.
10 * Permission is granted to anyone to use this software for any purpose,
11 * including commercial applications, and to alter it and redistribute it
12 * freely, subject to the following restrictions:
14 * 1. The origin of this software must not be misrepresented; you must not
15 * claim that you wrote the original software. If you use this software
16 * in a product, an acknowledgment in the product documentation would be
17 * appreciated but is not required.
19 * 2. Altered source versions must be plainly marked as such, and must not be
20 * misrepresented as being the original software.
22 * 3. This notice may not be removed or altered from any source
29 #ifndef __PARSELIB_H__
30 #define __PARSELIB_H__
32 typedef struct tokenchecker_valuetuple_t_ tokenchecker_valuetuple_t;
33 struct tokenchecker_valuetuple_t_ {
38 typedef struct tokenchecker_t_ tokenchecker_t;
39 struct tokenchecker_t_ {
40 tokenchecker_valuetuple_t *namelist;
50 TOKENCHECKER_CONTINUE,
51 TOKENCHECKER_CONTINUE_NOMATCH,
52 TOKENCHECKER_DETERMINE,
54 TOKENCHECKER_AFTER_END
57 IMPORT VOID tokenchecker_initialize(tokenchecker_t *checker, tokenchecker_valuetuple_t *namelist, W namelistnum, B *endchars);
58 IMPORT VOID tokenchecker_finalize(tokenchecker_t *checker);
59 IMPORT VOID tokenchecker_clear(tokenchecker_t *checker);
60 IMPORT W tokenchecker_inputchar(tokenchecker_t *checker, UB c, W *val);
61 IMPORT W tokenchecker_endinput(tokenchecker_t *checker, W *val);
62 IMPORT VOID tokenchecker_getlastmatchedstring(tokenchecker_t *checker, UB **str, W *len);
64 typedef struct charreferparser_t_ charreferparser_t;
65 struct charreferparser_t_ {
81 CHARREFERPARSER_RESULT_CONTINUE,
82 CHARREFERPARSER_RESULT_DETERMINE,
83 CHARREFERPARSER_RESULT_INVALID
84 } charreferparser_result_t;
86 IMPORT W charreferparser_initialize(charreferparser_t *parser);
87 IMPORT VOID charreferparser_finalize(charreferparser_t *parser);
88 IMPORT charreferparser_result_t charreferparser_parsechar(charreferparser_t *parser, UB ch);
89 IMPORT W charreferparser_getcharnumber(charreferparser_t *parser);
90 IMPORT VOID charreferparser_getlastmatchedstring(charreferparser_t *parser, UB **str, W *len);
91 IMPORT W charreferparser_parsestr(charreferparser_t *parser, UB *str, W len);
92 IMPORT VOID charreferparser_resetstate(charreferparser_t *parser);