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