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