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

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