/[ascend]/trunk/base/generic/compiler/scanner.h
ViewVC logotype

Contents of /trunk/base/generic/compiler/scanner.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 410 - (show annotations) (download) (as text)
Sun Apr 2 06:12:01 2006 UTC (14 years, 6 months ago) by ben.allan
File MIME type: text/x-chdr
File size: 5434 byte(s)
leave it in there.
1 /*
2 * Scanner Module
3 * by Tom Epperly
4 * 7/21/89
5 * Part of ASCEND
6 * Version: $Revision: 1.11 $
7 * Version control file: $RCSfile: scanner.h,v $
8 * Date last modified: $Date: 1998/02/18 22:57:22 $
9 * Last modified by: $Author: ballan $
10 *
11 * This file is part of the Ascend Language Interpreter.
12 *
13 * Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
14 *
15 * The Ascend Language Interpreter is free software; you can redistribute
16 * it and/or modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of the
18 * License, or (at your option) any later version.
19 *
20 * The Ascend Language Interpreter is distributed in hope that it will be
21 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License along
26 * with the program; if not, write to the Free Software Foundation, Inc., 675
27 * Mass Ave, Cambridge, MA 02139 USA. Check the file named COPYING.
28 */
29
30 /** @file
31 * This module is a module to convert a stream of character into a stream
32 * of tokens. It has been defined to be consistent with the routines
33 * required by the common compiler-compiler yacc.
34 * <pre>
35 * When #including scanner.h, make sure these files are #included first:
36 * #include "compiler.h"
37 * </pre>
38 */
39
40 #ifndef ASC_SCANNER_H
41 #define ASC_SCANNER_H
42
43 #define YY_MAXLEN MAXTOKENLENGTH
44 /**<
45 * Maximum token size(in characters).
46 * This must be greater than 2 and usually much greater than 2.
47 */
48
49 extern int yylex(void);
50 /**<
51 * <!-- int zz_lex(); -->
52 * Declaration of the Lexical Analyzer Function generated by Flex.
53 * (This is typically only called by the parser.)
54 */
55
56 extern unsigned long LineNum(void);
57 /**<
58 * <!-- unsigned long LineNum(); -->
59 *
60 * This function returns the line number position of the scanner.
61 */
62
63 extern void Asc_ScannerAssignFile(FILE *f, unsigned long linenum);
64 /**<
65 * <!-- Asc_ScannerAssignFile(f,linenum) -->
66 * <!-- FILE *f; -->
67 * <!-- unsigned long linenum; -->
68 *
69 * Change the input to file f and reset the line count to linenum.
70 */
71
72 extern void Asc_ScannerAssignString(void *yybs, unsigned long linenum, int first);
73 /**<
74 * <!-- Asc_ScannerAssignString(yybs,linenum,first) -->
75 * <!-- unsigned long linenum; -->
76 * <!-- int first; -->
77 *
78 * Change the input to string buffer yybs and reset the line count to linenum.
79 * If first !=0, calls BEGIN(INITIAL) as well.
80 * Current (file) buffer is pushed on the stack.
81 */
82
83 extern void *Asc_ScannerCreateStringBuffer(CONST char *string, int len);
84 /**<
85 * <!-- yybs = (YY_BUFFER_STATE)Asc_ScannerCreateStringBuffer(string,len); -->
86 * Pushes current buffer on stack and returns a YY_BUFFER_STATE
87 * (as void *) created from the string given. len is the length
88 * of the string given and is passed to yy_scan_bytes.
89 */
90
91 extern void Asc_ScannerReleaseStringBuffer(void *yybs);
92 /**<
93 * <!-- Asc_ScannerReleaseStringBuffer(yybs); -->
94 * Pops the buffer stack. Do not call this without a matching
95 * call to Asc_ScannerCreateStringBuffer preceding it.
96 * This function is NOT the opposite of Asc_ScannerPushBuffer.
97 */
98
99 extern int Asc_ScannerPushBuffer(CONST char *filename);
100 /**<
101 * <!-- void Asc_ScannerPushBuffer(filename) -->
102 * <!-- const char *filename; -->
103 *
104 * Create a new scanner buffer to parse the file named in filename. This
105 * function calls Asc_RequireModule to open the file and create the module
106 * definition and prepares the scanner for parsing the file.
107 * Returns 0 on success or error codes: 1 if the REQUIRE statements are
108 * too deeply nested, or 2 if the call to Asc_RequireModule fails.
109 */
110
111 extern void Asc_ErrMsgTypeDefnEOF(void);
112 /**<
113 * <!-- void Asc_ErrMsgTypeDefnEOF() -->
114 * <!-- const char *filename; -->
115 *
116 * Print an error message on the filehandle ASCERR that an End of File
117 * was reached inside a type definition.
118 * Note: This function is actually defined in ascParse.y (to avoid making
119 * g_type_name a global variable) and only used in scanner.l. Since there
120 * is no easy way to have yacc define a header file of function
121 * declarations, we are declaring it here.
122 */
123
124 extern void Asc_DestroyScannerWorkBuffer(void);
125 /**<
126 * <!-- void Asc_DestroyScannerWorkBuffer() -->
127 *
128 * Free the memory used by the Work Buffer in the scanner. Typically
129 * you only want to call this at shutdown or when you've completely
130 * finished with the scanner; however, it should do the right thing if
131 * you destroy the Work Buffer and then scan another file.
132 */
133
134 extern void Asc_DestroyScannerInputBuffer(void);
135 /**<
136 * Calls yy_delete_buffer on the 0th file buffer that we get at
137 * startup. Call this only at the final shutdown of the scanner.
138 */
139
140 #define yylval zz_lval
141 #endif /* ASC_SCANNER_H */
142

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22