3 * Quick-and-dirty parser
5 * (c) 2004 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Catacomb.
12 * Catacomb is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * Catacomb is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 #ifndef CATACOMB_QDPARSE_H
29 #define CATACOMB_QDPARSE_H
35 /*----- Header files ------------------------------------------------------*/
41 /*----- Data structures ---------------------------------------------------*/
43 typedef struct qd_parse {
44 const char *p; /* Where we are right now */
45 const char *e; /* Error string (output) */
48 /*----- Functions provided ------------------------------------------------*/
50 /* --- @qd_skipspc@ --- *
52 * Arguments: @qd_parse *qd@ = context
56 * Use: Skips spaces in the string. No errors.
59 extern void qd_skipspc(qd_parse */*qd*/);
61 /* --- @qd_delim@ --- *
63 * Arguments: @qd_parse *qd@ = context
64 * @int ch@ = character to compare with
66 * Returns: Nonzero if it was, zero if it wasn't.
68 * Use: Checks the next (non-whitespace) character is what we
69 * expect. If it is, the character is eaten; otherwise it's no
73 extern int qd_delim(qd_parse */*qd*/, int /*ch*/);
75 /* --- @qd_enum@ --- *
77 * Arguments: @qd_parse *qd@ = context
78 * @const char *e@ = list of enum strings, space separated
80 * Returns: Index of the string matched, or @-1@.
82 * Use: Matches a keyword.
85 extern int qd_enum(qd_parse */*qd*/, const char */*e*/);
87 /* --- @qd_getmp@ --- *
89 * Arguments: @qd_parse *qd@ = context
91 * Returns: The integer extracted, or null.
93 * Use: Parses a multiprecision integer from a string.
96 extern mp *qd_getmp(qd_parse */*qd*/);
98 /* --- @qd_eofp@ --- *
100 * Arguments: @qd_parse *qd@ = context
102 * Returns: Nonzero if at EOF, zero otherwise.
105 extern int qd_eofp(qd_parse */*qd*/);
107 /*----- That's all, folks -------------------------------------------------*/