Feat: add mutable pointer type *mut T and *mut opaque
- Grammar: update pointer_type to support optional mut keyword; LL(1) verified (56 named rules, no conflicts) - AST: update Type enum with mutable: bool field for Pointer and OpaquePointer variants - Parser: consume optional mut token in parse_type; update all existing pointer tests; add 4 new mut pointer tests (85 pass) - VSCode extension: add *mut capture-group pattern for syntax highlighting; update SYNTAX.md with pointer mutability table Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
17
GRAMMAR.ebnf
17
GRAMMAR.ebnf
@@ -271,13 +271,20 @@ named_type = IDENT ;
|
||||
|
||||
(* --- Pointer types --- *)
|
||||
(* *)
|
||||
(* "*" type — typed pointer; the pointee type is known. *)
|
||||
(* "*opaque" — untyped/opaque pointer (no pointee type info). *)
|
||||
(* "*" type — immutable typed pointer (read-only through ptr) *)
|
||||
(* "*mut" type — mutable typed pointer (read-write through ptr) *)
|
||||
(* "*opaque" — immutable untyped pointer (like C's const void* *)
|
||||
(* "*mut opaque" — mutable untyped pointer (like C's void* *)
|
||||
(* *)
|
||||
(* LL(1) note: after "*", "opaque" is not in FIRST(type), so the *)
|
||||
(* two alternatives are always distinguishable with one token. *)
|
||||
(* LL(1) note: after "*", peek at next token: *)
|
||||
(* "mut" → mutable pointer; consume "mut", then parse *)
|
||||
(* "opaque" | type *)
|
||||
(* "opaque" → immutable opaque pointer *)
|
||||
(* other → immutable typed pointer; parse type directly *)
|
||||
(* "mut" is a keyword; it is not in FIRST(type) and is distinct *)
|
||||
(* from "opaque", so all three cases are unambiguous with one token.*)
|
||||
|
||||
pointer_type = "*" , ( "opaque" | type ) ;
|
||||
pointer_type = "*" , [ "mut" ] , ( "opaque" | type ) ;
|
||||
|
||||
|
||||
(* --- Array types --- *)
|
||||
|
||||
Reference in New Issue
Block a user