1 |
jds |
54 |
/* |
2 |
aw0a |
1 |
* 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 |
jds |
54 |
/** @file |
31 |
aw0a |
1 |
* 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 |
jds |
54 |
* <pre> |
35 |
aw0a |
1 |
* When #including scanner.h, make sure these files are #included first: |
36 |
|
|
* #include "compiler.h" |
37 |
jds |
54 |
* </pre> |
38 |
aw0a |
1 |
*/ |
39 |
|
|
|
40 |
johnpye |
304 |
#ifndef ASC_SCANNER_H |
41 |
|
|
#define ASC_SCANNER_H |
42 |
aw0a |
1 |
|
43 |
johnpye |
385 |
#define YY_MAXLEN MAXTOKENLENGTH |
44 |
jds |
54 |
/**< |
45 |
|
|
* Maximum token size(in characters). |
46 |
|
|
* This must be greater than 2 and usually much greater than 2. |
47 |
aw0a |
1 |
*/ |
48 |
|
|
|
49 |
johnpye |
390 |
extern int yylex(void); |
50 |
jds |
54 |
/**< |
51 |
|
|
* <!-- int zz_lex(); --> |
52 |
aw0a |
1 |
* Declaration of the Lexical Analyzer Function generated by Flex. |
53 |
|
|
* (This is typically only called by the parser.) |
54 |
|
|
*/ |
55 |
|
|
|
56 |
jds |
54 |
extern unsigned long LineNum(void); |
57 |
|
|
/**< |
58 |
|
|
* <!-- unsigned long LineNum(); --> |
59 |
aw0a |
1 |
* |
60 |
|
|
* This function returns the line number position of the scanner. |
61 |
|
|
*/ |
62 |
|
|
|
63 |
jds |
54 |
extern void Asc_ScannerAssignFile(FILE *f, unsigned long linenum); |
64 |
|
|
/**< |
65 |
|
|
* <!-- Asc_ScannerAssignFile(f,linenum) --> |
66 |
|
|
* <!-- FILE *f; --> |
67 |
|
|
* <!-- unsigned long linenum; --> |
68 |
aw0a |
1 |
* |
69 |
|
|
* Change the input to file f and reset the line count to linenum. |
70 |
|
|
*/ |
71 |
|
|
|
72 |
jds |
54 |
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 |
aw0a |
1 |
* |
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 |
jds |
54 |
extern void *Asc_ScannerCreateStringBuffer(CONST char *string, int len); |
84 |
|
|
/**< |
85 |
|
|
* <!-- yybs = (YY_BUFFER_STATE)Asc_ScannerCreateStringBuffer(string,len); --> |
86 |
aw0a |
1 |
* 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 |
jds |
54 |
extern void Asc_ScannerReleaseStringBuffer(void *yybs); |
92 |
|
|
/**< |
93 |
|
|
* <!-- Asc_ScannerReleaseStringBuffer(yybs); --> |
94 |
aw0a |
1 |
* 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 |
jds |
54 |
extern int Asc_ScannerPushBuffer(CONST char *filename); |
100 |
|
|
/**< |
101 |
|
|
* <!-- void Asc_ScannerPushBuffer(filename) --> |
102 |
|
|
* <!-- const char *filename; --> |
103 |
aw0a |
1 |
* |
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 |
jds |
54 |
extern void Asc_ErrMsgTypeDefnEOF(void); |
112 |
|
|
/**< |
113 |
|
|
* <!-- void Asc_ErrMsgTypeDefnEOF() --> |
114 |
|
|
* <!-- const char *filename; --> |
115 |
aw0a |
1 |
* |
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 |
jds |
54 |
extern void Asc_DestroyScannerWorkBuffer(void); |
125 |
|
|
/**< |
126 |
|
|
* <!-- void Asc_DestroyScannerWorkBuffer() --> |
127 |
aw0a |
1 |
* |
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 |
jds |
54 |
extern void Asc_DestroyScannerInputBuffer(void); |
135 |
|
|
/**< |
136 |
|
|
* Calls yy_delete_buffer on the 0th file buffer that we get at |
137 |
aw0a |
1 |
* startup. Call this only at the final shutdown of the scanner. |
138 |
|
|
*/ |
139 |
jds |
54 |
|
140 |
johnpye |
304 |
#endif /* ASC_SCANNER_H */ |
141 |
jds |
54 |
|