Refactor AL parser's exception into a separate module

Reviewed By: dulmarod

Differential Revision: D5639375

fbshipit-source-id: fc63892
master
Martino Luca 8 years ago committed by Facebook Github Bot
parent f821d8948f
commit 98b1f74071

@ -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.
*)
exception ALParsingException of string

@ -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.
*)
exception ALParsingException of string

@ -20,10 +20,10 @@ let parse_al_file fname channel : CTL.al_file option =
in
let parse_with_error lexbuf =
try Some (Ctl_parser.al_file token lexbuf) with
| Ctl_parser_types.ALParsingException s
-> raise (Ctl_parser_types.ALParsingException (s ^ " at " ^ pos_str lexbuf))
| CTLExceptions.ALParsingException s
-> raise (CTLExceptions.ALParsingException (s ^ " at " ^ pos_str lexbuf))
| SyntaxError _ | Ctl_parser.Error
-> raise (Ctl_parser_types.ALParsingException ("SYNTAX ERROR at " ^ pos_str lexbuf))
-> raise (CTLExceptions.ALParsingException ("SYNTAX ERROR at " ^ pos_str lexbuf))
in
let lexbuf = Lexing.from_channel channel in
lexbuf.lex_curr_p <- {lexbuf.lex_curr_p with pos_fname= fname} ;

@ -551,10 +551,10 @@ let type_ptr_equal_type type_ptr type_str =
L.(debug Linters Medium) "Starting parsing type string '%s'@\n" str ;
let lexbuf = Lexing.from_string str in
try Types_parser.abs_ctype token lexbuf with
| Ctl_parser_types.ALParsingException s
-> raise (Ctl_parser_types.ALParsingException ("Syntax Error when defining type" ^ s))
| CTLExceptions.ALParsingException s
-> raise (CTLExceptions.ALParsingException ("Syntax Error when defining type" ^ s))
| SyntaxError _ | Types_parser.Error
-> raise (Ctl_parser_types.ALParsingException ("SYNTAX ERROR at " ^ pos_str lexbuf))
-> raise (CTLExceptions.ALParsingException ("SYNTAX ERROR at " ^ pos_str lexbuf))
in
let abs_ctype =
match String.Map.find !parsed_type_map type_str with

@ -16,7 +16,7 @@
let is_not_infer_reserved_id id =
if Str.string_match (Str.regexp_string Ctl_parser_types.infer_prefix) id 0 then
raise (Ctl_parser_types.ALParsingException
raise (CTLExceptions.ALParsingException
("ERROR: " ^ id ^ " contains __infer_ctl_ that is a reserved keyword "
^ "which cannot be used in identifiers:"))
else ()
@ -25,7 +25,7 @@
if (List.mem ~equal:ALVar.equal !formal_params (ALVar.Var id)) then
L.(debug Linters Verbose) "\tParsed exp '%s' as variable" id
else
raise (Ctl_parser_types.ALParsingException
raise (CTLExceptions.ALParsingException
("ERROR: Variable '" ^ id ^ "' is undefined"))
%}

@ -83,8 +83,6 @@ let rec ast_node_name an =
let infer_prefix = "__infer_ctl_"
exception ALParsingException of string
(** Data structures for type parser.
Correspondence with clang types inferred from
StringRef BuiltinType::getName in

@ -21,8 +21,6 @@ val stmt_node_child_type : ast_node -> string
val ast_node_cast_kind : ast_node -> string
exception ALParsingException of string
val infer_prefix : string
(** Data structures for type parser.

@ -28,7 +28,7 @@
| [UInt; Long; Long] -> BuiltIn ULongLong
| [Long; Double] -> BuiltIn LongDouble
| [UInt; Int128] -> BuiltIn UInt128
| _ -> raise (Ctl_parser_types.ALParsingException
| _ -> raise (CTLExceptions.ALParsingException
("ERROR: syntax error on types"))

Loading…
Cancel
Save