From ffb3d05864f231dba579d47b1c68972c323dcd5f Mon Sep 17 00:00:00 2001 From: Christian Rinderknecht Date: Mon, 13 Apr 2020 14:19:56 +0200 Subject: [PATCH] Changed a bit how syntax error messages are formulated. Resolved a warning. --- src/passes/1-parser/shared/ParserAPI.ml | 8 ++++---- src/passes/1-parser/shared/ParserUnit.ml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/passes/1-parser/shared/ParserAPI.ml b/src/passes/1-parser/shared/ParserAPI.ml index ad525c1a9..2b4d7c87e 100644 --- a/src/passes/1-parser/shared/ParserAPI.ml +++ b/src/passes/1-parser/shared/ParserAPI.ml @@ -100,14 +100,14 @@ module Make (IO: IO) None -> if Lexer.Token.is_eof invalid then "" else let invalid_lexeme = Lexer.Token.to_lexeme invalid in - Printf.sprintf ", before \"%s\"" invalid_lexeme + Printf.sprintf ", at \"%s\"" invalid_lexeme | Some valid -> let valid_lexeme = Lexer.Token.to_lexeme valid in - let s = Printf.sprintf ", after \"%s\"" valid_lexeme in - if Lexer.Token.is_eof invalid then s + let valid = Printf.sprintf ", after \"%s\"" valid_lexeme in + if Lexer.Token.is_eof invalid then valid else let invalid_lexeme = Lexer.Token.to_lexeme invalid in - Printf.sprintf "%s and before \"%s\"" s invalid_lexeme in + Printf.sprintf "at \"%s\", before %s" invalid_lexeme valid in let header = header ^ trailer in let msg = header ^ (if msg = "" then ".\n" else ":\n" ^ msg) diff --git a/src/passes/1-parser/shared/ParserUnit.ml b/src/passes/1-parser/shared/ParserUnit.ml index 948837c75..3cc9022b4 100644 --- a/src/passes/1-parser/shared/ParserUnit.ml +++ b/src/passes/1-parser/shared/ParserUnit.ml @@ -273,8 +273,8 @@ module Make (Lexer: Lexer.S) let cin = open_in source in let lexbuf = Lexing.from_channel cin in let () = - lexbuf.Lexing.lex_curr_p <- - {lexbuf.Lexing.lex_curr_p with pos_fname = source} + let open Lexing in + lexbuf.lex_curr_p <- {lexbuf.lex_curr_p with pos_fname=source} and options = (options :> Preprocessor.EvalOpt.options) in match Preprocessor.Preproc.lex options lexbuf with Stdlib.Ok _ as ok -> ok