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 |
/** addtogroup compiler Compiler |
39 |
@{ |
40 |
*/ |
41 |
|
42 |
#define YY_MAXLEN MAXTOKENLENGTH |
43 |
/**< |
44 |
* Maximum token size(in characters). |
45 |
* This must be greater than 2 and usually much greater than 2. |
46 |
*/ |
47 |
|
48 |
extern int asc_lex(void); |
49 |
/**< |
50 |
* Declaration of the Lexical Analyzer Function generated by Flex. |
51 |
* (This is typically only called by the parser.) |
52 |
*/ |
53 |
|
54 |
extern unsigned long LineNum(void); |
55 |
/**< |
56 |
* This function returns the line number position of the scanner. |
57 |
*/ |
58 |
|
59 |
extern void Asc_ScannerAssignFile(FILE *f, unsigned long linenum); |
60 |
/**< |
61 |
* Change the input to file f and reset the line count to linenum. |
62 |
*/ |
63 |
|
64 |
extern void Asc_ScannerAssignString(void *yybs, unsigned long linenum, int first); |
65 |
/**< |
66 |
* Change the input to string buffer yybs and reset the line count to linenum. |
67 |
* If first !=0, calls BEGIN(INITIAL) as well. |
68 |
* Current (file) buffer is pushed on the stack. |
69 |
*/ |
70 |
|
71 |
extern void *Asc_ScannerCreateStringBuffer(CONST char *string, int len); |
72 |
/**< |
73 |
* Pushes current buffer on stack and returns a YY_BUFFER_STATE |
74 |
* (as void *) created from the string given. len is the length |
75 |
* of the string given and is passed to yy_scan_bytes. |
76 |
*/ |
77 |
|
78 |
extern void Asc_ScannerReleaseStringBuffer(void *yybs); |
79 |
/**< |
80 |
* Pops the buffer stack. Do not call this without a matching |
81 |
* call to Asc_ScannerCreateStringBuffer preceding it. |
82 |
* This function is NOT the opposite of Asc_ScannerPushBuffer. |
83 |
*/ |
84 |
|
85 |
extern int Asc_ScannerPushBuffer(CONST char *filename); |
86 |
/**< |
87 |
* Create a new scanner buffer to parse the file named in filename. This |
88 |
* function calls Asc_RequireModule to open the file and create the module |
89 |
* definition and prepares the scanner for parsing the file. |
90 |
* Returns 0 on success or error codes: 1 if the REQUIRE statements are |
91 |
* too deeply nested, or 2 if the call to Asc_RequireModule fails. |
92 |
*/ |
93 |
|
94 |
extern void Asc_ErrMsgTypeDefnEOF(void); |
95 |
/**< |
96 |
* Print an error message on the filehandle ASCERR that an End of File |
97 |
* was reached inside a type definition. |
98 |
* Note: This function is actually defined in ascParse.y (to avoid making |
99 |
* g_type_name a global variable) and only used in scanner.l. Since there |
100 |
* is no easy way to have yacc define a header file of function |
101 |
* declarations, we are declaring it here. |
102 |
*/ |
103 |
|
104 |
extern void Asc_DestroyScannerWorkBuffer(void); |
105 |
/**< |
106 |
* Free the memory used by the Work Buffer in the scanner. Typically |
107 |
* you only want to call this at shutdown or when you've completely |
108 |
* finished with the scanner; however, it should do the right thing if |
109 |
* you destroy the Work Buffer and then scan another file. |
110 |
*/ |
111 |
|
112 |
extern void Asc_DestroyScannerInputBuffer(void); |
113 |
/**< |
114 |
* Calls yy_delete_buffer on the 0th file buffer that we get at |
115 |
* startup. Call this only at the final shutdown of the scanner. |
116 |
*/ |
117 |
|
118 |
/* @} */ |
119 |
|
120 |
#endif /* ASC_SCANNER_H */ |
121 |
|