[svn:parrot] r42079 - trunk/compilers/pirc/src
kjs at svn.parrot.org
kjs at svn.parrot.org
Sat Oct 24 15:04:17 UTC 2009
Author: kjs
Date: Sat Oct 24 15:04:16 2009
New Revision: 42079
URL: https://trac.parrot.org/parrot/changeset/42079
Log:
[pirc] check duplicate declarations of .lex'icals. Implementation of TT1073
Modified:
trunk/compilers/pirc/src/pircompunit.c
Modified: trunk/compilers/pirc/src/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/src/pircompunit.c Sat Oct 24 14:40:11 2009 (r42078)
+++ trunk/compilers/pirc/src/pircompunit.c Sat Oct 24 15:04:16 2009 (r42079)
@@ -1973,6 +1973,8 @@
void
set_lex_flag(lexer_state * const lexer, target * const t, char const * const name) {
lexical *lex = (lexical *)pir_mem_allocate(lexer, sizeof (lexical));
+ lexical *iter;
+
lex->name = name;
/* get a pointer to the "color" field, so that the lexical struct knows
@@ -1980,6 +1982,14 @@
*/
lex->color = &t->info->color;
+ /* check whether there is already a target marked as .lex with the specified name */
+ iter = CURRENT_SUB(lexer)->info.lexicals;
+ while (iter != NULL) {
+ if (STREQ(iter->name, name)) {
+ yypirerror(lexer->yyscanner, lexer, "lexical '%s' was already declared", name);
+ }
+ iter = iter->next;
+ }
/* link this lex node in the list of lexicals at the front; order doesn't matter. */
lex->next = CURRENT_SUB(lexer)->info.lexicals;
CURRENT_SUB(lexer)->info.lexicals = lex;
More information about the parrot-commits
mailing list