From 0c5016a7f39a6a70018949da90f3b9737bf945de Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 16 Dec 2013 23:19:31 -0800 Subject: * 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. --- ChangeLog | 11 +++++++++++ lib.c | 7 ++++--- parser.l | 18 +++++++----------- parser.y | 9 ++++----- 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 + + * 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 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; } -: { - if (yy_top_state() == INITIAL - || yy_top_state() == QSILIT) - yy_pop_state(); - yylval.lexeme = utf8_dup_from(""); - return SYMTOK; -} - \({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 { -- cgit v1.2.3