Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
labs
BIRD Internet Routing Daemon
Commits
c8f61a01
Commit
c8f61a01
authored
Nov 04, 1999
by
Martin Mareš
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Symbols are not scoped.
parent
91447965
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
conf/cf-lex.l
conf/cf-lex.l
+30
-1
conf/conf.h
conf/conf.h
+3
-0
No files found.
conf/cf-lex.l
View file @
c8f61a01
...
...
@@ -35,6 +35,13 @@ static struct keyword {
static struct keyword *kw_hash[KW_HASH_SIZE];
static struct symbol **sym_hash;
struct sym_scope {
struct sym_scope *next; /* Next on scope stack */
struct symbol *name; /* Name of this scope */
int active; /* Currently entered */
};
static struct sym_scope *conf_this_scope;
int conf_lino;
static int cf_hash(byte *c);
...
...
@@ -184,7 +191,7 @@ cf_find_sym(byte *c, unsigned int h0)
sym_hash = cfg_allocz(SYM_HASH_SIZE * sizeof(struct keyword *));
else
for(s = sym_hash[h]; s; s=s->next)
if (!strcmp(s->name, c))
if (!strcmp(s->name, c)
&& s->scope->active
)
return s;
l = strlen(c);
if (l > SYM_MAX_LEN)
...
...
@@ -192,6 +199,7 @@ cf_find_sym(byte *c, unsigned int h0)
s = cfg_alloc(sizeof(struct symbol) + l);
s->next = sym_hash[h];
sym_hash[h] = s;
s->scope = conf_this_scope;
s->class = SYM_VOID;
s->def = NULL;
s->aux = 0;
...
...
@@ -240,6 +248,8 @@ cf_lex_init(int is_cli)
BEGIN(CLI);
else
BEGIN(INITIAL);
conf_this_scope = cfg_allocz(sizeof(struct sym_scope));
conf_this_scope->active = 1;
}
void
...
...
@@ -254,3 +264,22 @@ cf_lex_init_tables(void)
kw_hash[h] = k;
}
}
void
cf_push_scope(struct symbol *sym)
{
struct sym_scope *s = cfg_alloc(sizeof(struct sym_scope));
s->next = conf_this_scope;
conf_this_scope = s;
s->active = 1;
s->name = sym;
}
void
cf_pop_scope(void)
{
conf_this_scope->active = 0;
conf_this_scope = conf_this_scope->next;
ASSERT(conf_this_scope);
}
conf/conf.h
View file @
c8f61a01
...
...
@@ -50,6 +50,7 @@ extern int (*cf_read_hook)(byte *buf, unsigned int max);
struct
symbol
{
struct
symbol
*
next
;
struct
sym_scope
*
scope
;
int
class
;
int
aux
;
void
*
aux2
;
...
...
@@ -75,6 +76,8 @@ void cf_lex_init(int is_cli);
struct
symbol
*
cf_find_symbol
(
byte
*
c
);
struct
symbol
*
cf_default_name
(
char
*
prefix
,
int
*
counter
);
void
cf_define_symbol
(
struct
symbol
*
symbol
,
int
type
,
void
*
def
);
void
cf_push_context
(
struct
symbol
*
);
void
cf_pop_context
(
void
);
/* Parser */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment