X-Git-Url: https://git.distorted.org.uk/~mdw/fwd/blobdiff_plain/77d0e3dc66ecd3028914496e4c0084bcb1f8f7af..00e3c0f1bbe99682debd4e34d3d3bd950f8c30cb:/scan.h diff --git a/scan.h b/scan.h index eee6f61..756029b 100644 --- a/scan.h +++ b/scan.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: scan.h,v 1.2 1999/07/26 23:24:33 mdw Exp $ + * $Id: scan.h,v 1.4 2002/02/22 23:44:16 mdw Exp $ * * Character scanners * @@ -29,6 +29,13 @@ /*----- Revision history --------------------------------------------------* * * $Log: scan.h,v $ + * Revision 1.4 2002/02/22 23:44:16 mdw + * Miscellaneous tidying up, to make this code independent of `fw'. It + * might end up in a library somewhere. + * + * Revision 1.3 2002/01/13 14:50:07 mdw + * Make delimiters be a property of a scanner. + * * Revision 1.2 1999/07/26 23:24:33 mdw * Complete rewrite. Allow a list of character sources to enable changes * during parsing of syntactic constructs. @@ -60,7 +67,7 @@ typedef struct scansrc { struct scansrc_ops *ops; /* Pointer to operations table */ char *src; /* Name of this source */ int line; /* Current line number */ - int pushback; /* Pushback character */ + dstr pushback; /* Pushback characters */ char *tok; /* Token pushback */ unsigned t; /* Token type pushback */ } scansrc; @@ -78,6 +85,7 @@ typedef struct scanner { scansrc *head, **tail; /* Scanner list head and tail */ int t; /* Token type */ dstr d; /* Current token value */ + const char *wbegin, *wcont; /* Parsing exception strings */ } scanner; /*----- Particular scanner types ------------------------------------------*/ @@ -85,7 +93,7 @@ typedef struct scanner { /* --- @scan_file@ --- * * * Arguments: @FILE *fp@ = pointer to file descriptor - * @char *name@ = pointer to source file name + * @const char *name@ = pointer to source file name * @unsigned f@ = flags * * Returns: A scanner source. @@ -93,10 +101,10 @@ typedef struct scanner { * Use: Creates a new scanner source for reading from a file. */ -extern scansrc *scan_file(FILE */*fp*/, char */*name*/, unsigned /*f*/); +#define SCF_NOCLOSE 1u /* Don't close @fp@ when finished */ -#define SCF_NOCLOSE 1u -#define SCF_FREENAME 2u +extern scansrc *scan_file(FILE */*fp*/, const char */*name*/, + unsigned /*f*/); /* --- @scan_argv@ --- * *