[BACK]Return to lowparse.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Annotation of src/usr.bin/make/lowparse.h, Revision 1.8

1.4       espie       1: #ifndef LOWPARSE_H
                      2: #define LOWPARSE_H
                      3:
1.8     ! espie       4: /* $OpenBSD: lowparse.h,v 1.7 2010/07/19 19:46:44 espie Exp $ */
1.1       espie       5:
                      6: /*
                      7:  * Copyright (c) 1999 Marc Espie.
                      8:  *
                      9:  * Extensive code changes for the OpenBSD project.
                     10:  *
                     11:  * Redistribution and use in source and binary forms, with or without
                     12:  * modification, are permitted provided that the following conditions
                     13:  * are met:
                     14:  * 1. Redistributions of source code must retain the above copyright
                     15:  *    notice, this list of conditions and the following disclaimer.
                     16:  * 2. Redistributions in binary form must reproduce the above copyright
                     17:  *    notice, this list of conditions and the following disclaimer in the
                     18:  *    documentation and/or other materials provided with the distribution.
                     19:  *
                     20:  * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
                     21:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
                     22:  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
                     23:  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OPENBSD
                     24:  * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
                     25:  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
                     26:  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     27:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     28:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     29:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
                     30:  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     31:  */
1.4       espie      32: /* low-level parsing module:
                     33:  *     select input stream to parse, and do high-speed processing of
                     34:  *     lines: skipping comments, handling continuation lines, or skipping
                     35:  *     over dead conditionals.
                     36:  *
                     37:  * Basic template:
                     38:  *
                     39:  * Parse_Fromxxx(source);
                     40:  * do {
                     41:  *     while ((line = Parse_ReadNormalLine(&buf)) != NULL) {
1.5       espie      42:  *             handle line, use Parse_Fromxxx to push includes,
1.4       espie      43:  *             Parse_ReadNextConditional to get over non-conditional lines.
                     44:  *             or Parse_ReadUnparsedLine to handle special cases manually.
                     45:  *     }
                     46:  * } while (Parse_NextFile());
                     47:  */
                     48:
                     49: /* Initialization and cleanup */
1.1       espie      50: #ifdef CLEANUP
1.3       espie      51: extern void LowParse_Init(void);
                     52: extern void LowParse_End(void);
1.4       espie      53: #else
                     54: #define LowParse_Init()
                     55: #define LowParse_End()
1.1       espie      56: #endif
1.4       espie      57:
                     58: /* Selection of input stream */
                     59: /* Parse_FromFile(filename, filehandle);
                     60:  *     Push given filehandle on the input stack, using filename for diagnostic
                     61:  *     messages.  The module assumes ownership of the filehandle and of
                     62:  *     the filename: provide copies if necessary.  */
                     63: extern void Parse_FromFile(const char *, FILE *);
                     64: /* Parse_FromString(str, lineno);
                     65:  *     Push expanded string str on the input stack, assuming it starts at
                     66:  *     lineno in the current file.  This is used to reparse .for loops
                     67:  *     after the variable has been expanded, hence no need to respecify
                     68:  *     the filename. The module assumes ownership of the string: provide a
                     69:  *     copy if necessary.  */
                     70: extern void Parse_FromString(char *, unsigned long);
                     71:
                     72: /* Error reporting, and tagging of read structures. */
                     73: /* lineno = Parse_Getlineno();
                     74:  *     Returns the current lineno. */
                     75: extern unsigned long Parse_Getlineno(void);
                     76: /* name = Parse_Getfilename();
                     77:  *     Returns the current filename.  Safe to keep without copying.  */
                     78: extern const char *Parse_Getfilename(void);
1.8     ! espie      79:
        !            80: /* Parse_FillLocation(origin)
        !            81:  *     Fill the location pointed by origin with the current location. */
        !            82: extern void Parse_FillLocation(Location *);
1.4       espie      83:
                     84: /* continue = Parse_NextFile();
                     85:  *     Advance parsing to the next file in the input stack. Returns true
                     86:  *     if there is parsing left to do.
                     87:  */
                     88: extern bool Parse_NextFile(void);
                     89:
                     90:
                     91: /* line = Parse_ReadNormalLine(buf);
                     92:  *     Reads next line into buffer and return its contents.  Handles line
                     93:  *     continuation, remove extra blanks, and skip trivial comments.  tabs at
                     94:  *     beginning of line are left alone, to be able to recognize target
                     95:  *     lines. */
                     96: extern char *Parse_ReadNormalLine(Buffer);
                     97:
                     98: /* line = ParseReadNextConditionalLine(buf);
                     99:  *     Returns next conditional line, skipping over everything else. */
                    100: extern char *Parse_ReadNextConditionalLine(Buffer);
                    101: /* line = ParseReadUnparsedLine(buf, type);
                    102:  *     Reads line without parsing anything beyond continuations.
                    103:  *     Handle special cases such as conditional lines, or lines that
                    104:  *     need a reparse (loops). */
                    105: extern char *Parse_ReadUnparsedLine(Buffer, const char *);
                    106: /* Parse_ReportErrors();
                    107:  *     At end of parsing, report on fatal errors.
                    108:  */
                    109: extern void Parse_ReportErrors(void);
1.1       espie     110: #endif