diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2013-12-16 23:19:31 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2013-12-16 23:19:31 -0800 |
commit | 0c5016a7f39a6a70018949da90f3b9737bf945de (patch) | |
tree | 2adf23155ec3684d04296a100a218f456a2c7afc | |
parent | 030ce483baef93392d54a4aec90bfa7b5906bc53 (diff) | |
download | txr-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-- | ChangeLog | 11 | ||||
-rw-r--r-- | lib.c | 7 | ||||
-rw-r--r-- | parser.l | 18 | ||||
-rw-r--r-- | parser.y | 9 |
4 files changed, 26 insertions, 19 deletions
@@ -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 @@ -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); @@ -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; @@ -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 { |