~tim-ats-d/Postem-markup

01094744603749c207bf4e4a48a6e9a07bcc1294 — Tim-ats-d 2 years ago 373c831 master
Fix group parsing and allow newline in group.
3 files changed, 9 insertions(+), 2 deletions(-)

M src/common/err.ml
M src/syntax/lexer.ml
M src/syntax/parser.mly
M src/common/err.ml => src/common/err.ml +1 -0
@@ 14,6 14,7 @@ let get_line ic n =
    input_line ic
  with End_of_file -> assert false

(* TODO: Fix Sys_error exception in REPL error. *)
let rec pp_loc ?hint ~msg (spos, epos) =
  let schar = Lexing.(spos.pos_cnum - spos.pos_bol) in
  let echar = Lexing.(epos.pos_cnum - epos.pos_bol) in

M src/syntax/lexer.ml => src/syntax/lexer.ml +3 -1
@@ 6,7 6,9 @@ let op = [%sedlex.regexp? Plus op_char]
let unformat = [%sedlex.regexp? "{{", Star any, "}}"]
let white_char = [%sedlex.regexp? zs]
let white = [%sedlex.regexp? Plus white_char]
let text = [%sedlex.regexp? Plus (Compl (op_char | '\n' | white_char))]

let text =
  [%sedlex.regexp? Plus (Compl (op_char | '\n' | white_char | '[' | ']'))]
(* TODO: Windows newline support (\r\n) *)

let newline = [%sedlex.regexp? '\n' | "\r\n"]

M src/syntax/parser.mly => src/syntax/parser.mly +5 -1
@@ 37,7 37,11 @@ let terminal ==
  | u=UNFORMAT; { LUnformat u }

let group ==
  | LBRACKET; grp=expr*; RBRACKET; { LGroup grp }
  | LBRACKET; grp=group_aux*; RBRACKET; { LGroup grp }

let group_aux ==
  | expr
  | n=NEWLINE; { LNewline n }

let unary_op ==
  | op=OP; t=TEXT;