Lexing and layout
The lexer is the first simplifier. It turns characters into a flat row of pieces: func, a name, parentheses, a colon, a newline, and an indent. Parsing and semantic analysis use that row to build and validate the program.
From source to layout tokens
func main():
let answer = 40 + 2
print(str(answer))The colon announces a possible suite. Exactly four additional spaces open it. Both body statements remain at that level. End-of-file closes the open suite with dedent.
Indentation is a language rule
The step is exactly four columns, and a tab produces a diagnostic. Blank and comment-only lines are skipped for layout. Inside parentheses or map-literal braces, a newline acts as spacing. A nesting limit turns deeply generated input into a bounded diagnostic.
Accepted
A block opens exactly four spaces deeper than its parent and returns to an earlier stack entry.
Indentation diagnostic
Two spaces, a tab, or a dedent to a column that was never an open block.
Source must read the way it runs
Bidirectional controls are rejected everywhere, including comments and string literals. Raw controls inside text are rejected. Unicode look-alikes for language punctuation are diagnosed with the ASCII character to write. These checks live at the lexical boundary because letting a deceptive spelling become an ordinary token would erase the evidence.
Reporting several lexical errors
After a malformed byte, the lexer emits a luce.lex.* diagnostic and continues with the closest usable token stream. A recovery token can stand where a value was clearly intended. Identical diagnostic runs collapse, total reports are capped, and structural truncation marks synthetic closing tokens for the parser.
Diagnostic ownership: when the lexer reports a stray character or unterminated string, it marks the recovery position so the parser can continue from the next useful construct.
Information carried into parsing
name and TypeName are identifier tokens. A minus sign and an integer are separate tokens. Parsing turns those tokens into syntax, then semantic analysis resolves declarations, types, visibility, and worker sendability.