1 /*****************************************************************************/
5 /* Parse a symbol name and search for it */
9 /* (C) 1998-2003 Ullrich von Bassewitz */
11 /* D-70794 Filderstadt */
12 /* EMail: uz@cc65.org */
15 /* This software is provided 'as-is', without any expressed or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
32 /*****************************************************************************/
47 /*****************************************************************************/
49 /*****************************************************************************/
53 /*****************************************************************************/
55 /*****************************************************************************/
59 SymEntry* ParseScopedSymName (int AllocNew)
60 /* Parse a (possibly scoped) symbol name, search for it in the symbol table
61 * and return the symbol table entry.
64 /* Get the starting table */
66 if (Tok == TOK_NAMESPACE) {
71 /* ### Need to walk up the tree */
77 /* An identifier must follow. Remember and skip it. */
78 char Name[sizeof (SVal)];
79 if (Tok != TOK_IDENT) {
80 Error ("Identifier expected");
86 /* If the next token is a namespace token, handle the name as the
87 * name of a scope, otherwise it's the name of a symbol in that
91 if (Tok == TOK_NAMESPACE) {
93 /* Search for the child scope */
94 Scope = SymFindScope (Scope, Name, AllocNew);
96 /* Skip the namespace token */
99 /* If we didn't find the scope, bail out */
106 /* Search for the symbol and return it */
107 return SymFind (Scope, Name, AllocNew);
115 SymTable* ParseScopedSymTable (int AllocNew)
116 /* Parse a (possibly scoped) symbol table (scope) name, search for it in the
117 * symbol space and return the symbol table struct.
120 /* Get the starting table */
122 if (Tok == TOK_NAMESPACE) {
126 Scope = CurrentScope;
127 if (Tok != TOK_IDENT) {
128 Error ("Identifier expected");
132 /* If no new scope should be allocated, the scope may specify any
133 * scope in any of the parent scopes, so search for it.
136 Scope = SymFindAnyScope (Scope, SVal);
138 if (Tok != TOK_NAMESPACE) {
145 /* Resolve scopes. */
146 while (Tok == TOK_IDENT) {
148 /* Search for the child scope if we have a valid parent */
150 Scope = SymFindScope (Scope, SVal, AllocNew);
153 /* Skip the name token */
156 /* If a namespace token follows, read on, otherwise bail out */
157 if (Tok == TOK_NAMESPACE) {
159 if (Tok != TOK_IDENT) {
160 Error ("Identifier expected");
167 /* Return the scope we found or created */