Fix parser type safety for stricter AST types
- Handle token.value being str | None by using `or ""` fallback
- Fix parse_variable_definition to not use `and` for side effects
- Use properly typed variable in parse_nullability_assertion
- These fixes prepare for stricter type checking in frozen dataclasses
Make visitor immutable-friendly
Modifies the AST visitor to use copy-on-write semantics when applying
edits. Instead of mutating nodes in place, the visitor now creates new
node instances with the edited values. This prepares for frozen AST
nodes while maintaining backwards compatibility.
The visitor accumulates edits and applies them by constructing new
nodes, enabling the transition to immutable data structures.