Summary: In case of syntax errors in AL files, stdout will contain a JSON list with all files affected by the errors, including info like filename and line number. Reviewed By: dulmarod, jvillard Differential Revision: D5640272 fbshipit-source-id: 569b16dmaster
parent
3576f2f7cc
commit
e8a0599850
@ -0,0 +1,37 @@
|
||||
(*
|
||||
* Copyright (c) 2017 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
open Ctl_lexer
|
||||
open Lexing
|
||||
|
||||
let parse_al_file fname channel =
|
||||
let parse_with_error lexbuf =
|
||||
try Some (Ctl_parser.al_file token lexbuf) with
|
||||
| CTLExceptions.ALParserInvariantViolationException s
|
||||
-> raise CTLExceptions.(ALFileException (create_exc_info s lexbuf))
|
||||
| SyntaxError _ | Ctl_parser.Error
|
||||
-> raise CTLExceptions.(ALFileException (create_exc_info "SYNTAX ERROR" lexbuf))
|
||||
in
|
||||
let lexbuf = Lexing.from_channel channel in
|
||||
lexbuf.lex_curr_p <- {lexbuf.lex_curr_p with pos_fname= fname} ;
|
||||
parse_with_error lexbuf
|
||||
|
||||
let validate_al_files () =
|
||||
let validate_al_file fname =
|
||||
try
|
||||
Utils.with_file_in ~f:(parse_al_file fname) fname |> ignore ;
|
||||
None
|
||||
with CTLExceptions.ALFileException exc_info -> Some (CTLExceptions.json_of_exc_info exc_info)
|
||||
in
|
||||
match List.filter_map ~f:validate_al_file Config.linters_def_file with
|
||||
| []
|
||||
-> Ok ()
|
||||
| _ as errors
|
||||
-> Error (Yojson.Basic.to_string (`List errors))
|
@ -0,0 +1,14 @@
|
||||
(*
|
||||
* Copyright (c) 2017 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
val parse_al_file : string -> In_channel.t -> CTL.al_file option
|
||||
|
||||
val validate_al_files : unit -> (unit, string) Result.t
|
@ -0,0 +1,10 @@
|
||||
(*
|
||||
* Copyright (c) 2017 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*)
|
||||
|
||||
let validate_al_files () = prerr_endline "ERROR: infer was built without clang support." ; exit 1
|
@ -0,0 +1,12 @@
|
||||
(*
|
||||
* Copyright (c) 2016 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
val validate_al_files : unit -> (unit, string) Result.t
|
Loading…
Reference in new issue