xo-tokenizer: fix duplicate case statements

This commit is contained in:
Roland Conybeare 2024-09-15 12:56:36 -05:00
commit 4fb94bc2d6

View file

@ -157,7 +157,6 @@ namespace xo {
case '*': case '*':
/* not punctuation -- allowed in symbol */ /* not punctuation -- allowed in symbol */
return false; return false;
case '*':
case '/': case '/':
/* not punctuation -- for symmetry with +,- */ /* not punctuation -- for symmetry with +,- */
return false; return false;
@ -346,12 +345,20 @@ namespace xo {
if (token_text.size() == 1) { if (token_text.size() == 1) {
/* standalone '*' */ /* standalone '*' */
tk_type = tokentype::tk_star; tk_type = tokentype::tk_star;
++ix;
} else {
/* '*' isn't punctuation -- but may allow appearance in a longer token
*
* thinking that x*y is a symbol with an embedded '*' character;
* in particular want to support kebab-case symbols like 'foo-config'
*/
} }
break; break;
case '/': case '/':
if (token_text.size() == 1) { if (token_text.size() == 1) {
/* standalone '/' */ /* standalone '/' */
tk_type = tokentype::tk_slash; tk_type = tokentype::tk_slash;
++ix;
} }
break; break;
case '"': case '"':
@ -530,13 +537,6 @@ namespace xo {
tk_type = tokentype::tk_semicolon; tk_type = tokentype::tk_semicolon;
++ix; ++ix;
break; break;
case '*':
/* '*' isn't punctuation, since can appear within symbol.
* However it cannot begin a symbol..
*/
tk_type = tokentype::tk_star;
++ix;
break;
case ':': case ':':
{ {
log && log("colon or assignment token"); log && log("colon or assignment token");