summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2013-12-16 23:19:31 -0800
committerKaz Kylheku <kaz@kylheku.com>2013-12-16 23:19:31 -0800
commit0c5016a7f39a6a70018949da90f3b9737bf945de (patch)
tree2adf23155ec3684d04296a100a218f456a2c7afc
parent030ce483baef93392d54a4aec90bfa7b5906bc53 (diff)
downloadtxr-0c5016a7f39a6a70018949da90f3b9737bf945de.tar.gz
txr-0c5016a7f39a6a70018949da90f3b9737bf945de.tar.bz2
txr-0c5016a7f39a6a70018949da90f3b9737bf945de.zip
* lib.c (intern): fix the previous diagnostic bug once more with more
feeling. * parser.l (grammar): Recognize package prefixes in symbol tokens. Got rid of special rule for handling lone colon. * parser.y (sym_helper): Catch undefined package as a parsing error rather allowing intern function to throw exception.
-rw-r--r--ChangeLog11
-rw-r--r--lib.c7
-rw-r--r--parser.l18
-rw-r--r--parser.y9
4 files changed, 26 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 96962b7a..ddc5238a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2013-12-16 Kaz Kylheku <kaz@kylheku.com>
+
+ * lib.c (intern): fix the previous diagnostic bug once more with more
+ feeling.
+
+ * parser.l (grammar): Recognize package prefixes in symbol tokens.
+ Got rid of special rule for handling lone colon.
+
+ * parser.y (sym_helper): Catch undefined package as a parsing
+ error rather allowing intern function to throw exception.
+
2013-12-15 Kaz Kylheku <kaz@kylheku.com>
Changing the tokenizer to get rid of IDENT, KEYWORD and METAVAR
diff --git a/lib.c b/lib.c
index e95d72f8..0939bd9a 100644
--- a/lib.c
+++ b/lib.c
@@ -2561,9 +2561,10 @@ val intern(val str, val package)
if (nullp(package)) {
package = user_package;
} else if (stringp(package)) {
- package = find_package(str);
- if (!package)
- uw_throwf(error_s, lit("intern: ~s no such package"), str, nao);
+ val p = find_package(package);
+ if (!p)
+ uw_throwf(error_s, lit("intern: ~s no such package"), package, nao);
+ package = p;
}
type_check (package, PKG);
diff --git a/parser.l b/parser.l
index ef92db03..2ab713ab 100644
--- a/parser.l
+++ b/parser.l
@@ -166,9 +166,13 @@ BSYM {BSCHR}({BSCHR}|#)*
NSCHR [a-zA-Z0-9!$%&*+\-<=>?\\^_~/]
ID_END [^a-zA-Z0-9!$%&*+\-<=>?\\^_~/]
NSYM {NSCHR}({NSCHR}|#)*
-TOK :?{SYM}
-BTOK [:@]?{BSYM}
-NTOK [:@]?{NSYM}
+TOK {SYM}
+BTREG ({BSYM}|@)({BSYM}|#)*(:({BSYM}|#)*)?
+BTKEY @?:({BSYM}|#)*
+BTOK {BTREG}|{BTKEY}
+NTREG ({NSYM}|@)({NSYM}|#)*(:({NSYM}|#)*)?
+NTKEY @?:({NSYM}|#)*
+NTOK {NTREG}|{NTKEY}
WS [\t ]*
HEX [0-9A-Fa-f]
OCT [0-7]
@@ -264,14 +268,6 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
return SYMTOK;
}
-<BRACED,NESTED>: {
- if (yy_top_state() == INITIAL
- || yy_top_state() == QSILIT)
- yy_pop_state();
- yylval.lexeme = utf8_dup_from("");
- return SYMTOK;
-}
-
<SPECIAL>\({WS}all{WS}\) {
yy_pop_state();
yylval.lineno = lineno;
diff --git a/parser.y b/parser.y
index 928ae457..a3f28079 100644
--- a/parser.y
+++ b/parser.y
@@ -902,9 +902,7 @@ static val sym_helper(wchar_t *lexeme, val meta_allowed)
int leading_at = *lexeme == L'@';
wchar_t *tokfree = lexeme;
wchar_t *colon = wcschr(lexeme, L':');
- val sym_name = nil;
- val package = nil;
- val sym;
+ val sym_name = nil, pkg_name = nil, package = nil, sym;
if (leading_at) {
if (!meta_allowed) {
@@ -923,11 +921,12 @@ static val sym_helper(wchar_t *lexeme, val meta_allowed)
sym_name = string(colon + 1);
free(tokfree);
} else if (colon != 0) {
- package = string(lexeme);
+ pkg_name = string(lexeme);
+ package = find_package(pkg_name);
sym_name = string(colon + 1);
free(tokfree);
if (!package) {
- yyerrorf(lit("~a:~a: package ~a not found"), package, sym_name, package, nao);
+ yyerrorf(lit("~a:~a: package ~a not found"), pkg_name, sym_name, pkg_name, nao);
return nil;
}
} else {