lang: lex: add support for kebab-case identifiers and negative numbers

identifiers can now contain hyphens, with the following restrictions:
 * an identifier cannot start or end with a hyphen.
 * an identifier cannot contain more than one hyphen in a row.

kebab-case identifiers can be used for type and variable names, as well
as message identifiers and labels.

to avoid ambiguity, the lexer now enforces whitespace around most binary
operators (with a few exceptions, such as semicolons). trying to
compile a "compact" arithmetic expression, such as

	y=1+2

will now result in a "missing whitespace" error.
This commit is contained in:
2025-11-07 09:49:29 +00:00
parent 1a544b6411
commit b0cbe42fc4
4 changed files with 185 additions and 117 deletions

View File

@@ -14,8 +14,10 @@ static void print_symbol_node(struct ivy_lexer_symbol_node *node, int depth)
b_printf("[cyan]%c[reset]", node->s_char);
if (node->s_id != IVY_SYM_NONE) {
b_printf(" ([magenta]%s[reset])", ivy_symbol_to_string(node->s_id));
if (node->s_def != NULL) {
b_printf(
" ([magenta]%s[reset])",
ivy_symbol_to_string(node->s_def->id));
}
b_printf("\n");