| 1 | /* -*-c-*- |
| 2 | * |
| 3 | * $Id: qdparse.h,v 1.1 2004/03/27 17:54:12 mdw Exp $ |
| 4 | * |
| 5 | * Quick-and-dirty parser |
| 6 | * |
| 7 | * (c) 2004 Straylight/Edgeware |
| 8 | */ |
| 9 | |
| 10 | /*----- Licensing notice --------------------------------------------------* |
| 11 | * |
| 12 | * This file is part of Catacomb. |
| 13 | * |
| 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. |
| 18 | * |
| 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. |
| 23 | * |
| 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, |
| 27 | * MA 02111-1307, USA. |
| 28 | */ |
| 29 | |
| 30 | /*----- Revision history --------------------------------------------------* |
| 31 | * |
| 32 | * $Log: qdparse.h,v $ |
| 33 | * Revision 1.1 2004/03/27 17:54:12 mdw |
| 34 | * Standard curves and curve checking. |
| 35 | * |
| 36 | */ |
| 37 | |
| 38 | #ifndef CATACOMB_QDPARSE_H |
| 39 | #define CATACOMB_QDPARSE_H |
| 40 | |
| 41 | #ifdef __cplusplus |
| 42 | extern "C" { |
| 43 | #endif |
| 44 | |
| 45 | /*----- Header files ------------------------------------------------------*/ |
| 46 | |
| 47 | #ifndef CATACOMB_MP_H |
| 48 | # include "mp.h" |
| 49 | #endif |
| 50 | |
| 51 | /*----- Data structures ---------------------------------------------------*/ |
| 52 | |
| 53 | typedef struct qd_parse { |
| 54 | const char *p; /* Where we are right now */ |
| 55 | const char *e; /* Error string (output) */ |
| 56 | } qd_parse; |
| 57 | |
| 58 | /*----- Functions provided ------------------------------------------------*/ |
| 59 | |
| 60 | /* --- @qd_skipspc@ --- * |
| 61 | * |
| 62 | * Arguments: @qd_parse *qd@ = context |
| 63 | * |
| 64 | * Returns: --- |
| 65 | * |
| 66 | * Use: Skips spaces in the string. No errors. |
| 67 | */ |
| 68 | |
| 69 | extern void qd_skipspc(qd_parse */*qd*/); |
| 70 | |
| 71 | /* --- @qd_delim@ --- * |
| 72 | * |
| 73 | * Arguments: @qd_parse *qd@ = context |
| 74 | * @int ch@ = character to compare with |
| 75 | * |
| 76 | * Returns: Nonzero if it was, zero if it wasn't. |
| 77 | * |
| 78 | * Use: Checks the next (non-whitespace) character is what we |
| 79 | * expect. If it is, the character is eaten; otherwise it's no |
| 80 | * big deal. |
| 81 | */ |
| 82 | |
| 83 | extern int qd_delim(qd_parse */*qd*/, int /*ch*/); |
| 84 | |
| 85 | /* --- @qd_enum@ --- * |
| 86 | * |
| 87 | * Arguments: @qd_parse *qd@ = context |
| 88 | * @const char *e@ = list of enum strings, space separated |
| 89 | * |
| 90 | * Returns: Index of the string matched, or @-1@. |
| 91 | * |
| 92 | * Use: Matches a keyword. |
| 93 | */ |
| 94 | |
| 95 | extern int qd_enum(qd_parse */*qd*/, const char */*e*/); |
| 96 | |
| 97 | /* --- @qd_getmp@ --- * |
| 98 | * |
| 99 | * Arguments: @qd_parse *qd@ = context |
| 100 | * |
| 101 | * Returns: The integer extracted, or null. |
| 102 | * |
| 103 | * Use: Parses a multiprecision integer from a string. |
| 104 | */ |
| 105 | |
| 106 | extern mp *qd_getmp(qd_parse */*qd*/); |
| 107 | |
| 108 | /* --- @qd_eofp@ --- * |
| 109 | * |
| 110 | * Arguments: @qd_parse *qd@ = context |
| 111 | * |
| 112 | * Returns: Nonzero if at EOF, zero otherwise. |
| 113 | */ |
| 114 | |
| 115 | extern int qd_eofp(qd_parse */*qd*/); |
| 116 | |
| 117 | /*----- That's all, folks -------------------------------------------------*/ |
| 118 | |
| 119 | #ifdef __cplusplus |
| 120 | } |
| 121 | #endif |
| 122 | |
| 123 | #endif |