Fix orchestration.sx parse error, add parser line/col diagnostics
The parser was reporting "Unexpected char: )" with no position info.
Added line number, column, and byte position to all parse errors.
Root cause: bind-sse-swap had one extra close paren that naive paren
counting missed because a "(" exists inside a string literal on L1074
(starts-with? trimmed "("). Parse-aware counting (skipping strings
and comments) correctly identified the imbalance.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -95,7 +95,11 @@ let try_number str =
|
|||||||
|
|
||||||
let rec read_value s : value =
|
let rec read_value s : value =
|
||||||
skip_whitespace_and_comments s;
|
skip_whitespace_and_comments s;
|
||||||
if at_end s then raise (Parse_error "Unexpected end of input");
|
if at_end s then begin
|
||||||
|
let line = ref 1 in
|
||||||
|
String.iter (fun c -> if c = '\n' then incr line) s.src;
|
||||||
|
raise (Parse_error (Printf.sprintf "Unexpected end of input at line %d (pos %d)" !line s.pos))
|
||||||
|
end;
|
||||||
match s.src.[s.pos] with
|
match s.src.[s.pos] with
|
||||||
| '(' -> read_list s ')'
|
| '(' -> read_list s ')'
|
||||||
| '[' -> read_list s ']'
|
| '[' -> read_list s ']'
|
||||||
@@ -139,7 +143,14 @@ let rec read_value s : value =
|
|||||||
begin
|
begin
|
||||||
(* Symbol, keyword, number, or boolean *)
|
(* Symbol, keyword, number, or boolean *)
|
||||||
let token = read_symbol s in
|
let token = read_symbol s in
|
||||||
if token = "" then raise (Parse_error ("Unexpected char: " ^ String.make 1 s.src.[s.pos]));
|
if token = "" then begin
|
||||||
|
let line = ref 1 and col = ref 1 in
|
||||||
|
for i = 0 to s.pos - 1 do
|
||||||
|
if s.src.[i] = '\n' then (incr line; col := 1) else incr col
|
||||||
|
done;
|
||||||
|
raise (Parse_error (Printf.sprintf "Unexpected char: %c at line %d col %d (pos %d)"
|
||||||
|
s.src.[s.pos] !line !col s.pos))
|
||||||
|
end;
|
||||||
match token with
|
match token with
|
||||||
| "true" -> Bool true
|
| "true" -> Bool true
|
||||||
| "false" -> Bool false
|
| "false" -> Bool false
|
||||||
|
|||||||
@@ -1084,7 +1084,7 @@
|
|||||||
(with-transition use-transition
|
(with-transition use-transition
|
||||||
(fn ()
|
(fn ()
|
||||||
(swap-html-string target trimmed swap-style)
|
(swap-html-string target trimmed swap-style)
|
||||||
(post-swap target)))))))))
|
(post-swap target))))))))
|
||||||
|
|
||||||
|
|
||||||
;; --------------------------------------------------------------------------
|
;; --------------------------------------------------------------------------
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1084,7 +1084,7 @@
|
|||||||
(with-transition use-transition
|
(with-transition use-transition
|
||||||
(fn ()
|
(fn ()
|
||||||
(swap-html-string target trimmed swap-style)
|
(swap-html-string target trimmed swap-style)
|
||||||
(post-swap target)))))))))
|
(post-swap target))))))))
|
||||||
|
|
||||||
|
|
||||||
;; --------------------------------------------------------------------------
|
;; --------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user