Skip to content

Commit

Permalink
Update operand validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Linda-Njau committed Aug 1, 2024
1 parent 300079a commit 5908e18
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/sail_json_backend/json.ml
Original file line number Diff line number Diff line change
Expand Up @@ -239,29 +239,31 @@ let filter_non_operands components =
in
aux [] components

let extract_operands k regex components =
let extract_operands k components =
let rec aux acc = function
| [] -> List.rev acc
| hd :: tl ->
if Str.string_match regex hd 0 then (
if Str.string_match (Str.regexp ".+(\\(.*\\))") hd 0 then (
let operand = Str.matched_group 1 hd in
let elements = Str.split (Str.regexp ",") operand in
try
let comma_index = String.index operand ',' in
debug_print ("Operand before trimming: " ^ operand);
let trimmed = String.sub operand 0 comma_index in
debug_print ("Final trimmed operand: " ^ trimmed);
let inputl = Hashtbl.find inputs k in
if List.mem trimmed inputl then aux (trimmed :: acc) tl else aux acc tl

This comment has been minimized.

Copy link
@ThinkOpenly

ThinkOpenly Aug 1, 2024

Owner

I think you deleted trimmed in this last commit, so I'm not sure how you can use it here? :-)

with Not_found -> aux (operand :: acc) tl
let acc =
List.fold_left (fun acc element -> if List.mem element inputl then element :: acc else acc) acc elements
in

aux acc tl
with Not_found -> aux acc tl
)
else aux acc tl
in
aux [] components

let extract_and_map_operands k components =
let regex = Str.regexp ".+(\\(.*\\))" in
let filtered_components = filter_non_operands components in
let operandl = extract_operands k regex filtered_components in
let operandl = extract_operands k filtered_components in
let opmap = List.combine (Hashtbl.find inputs k) (Hashtbl.find sigs k) in
let operand_with_type =
List.map
Expand Down

0 comments on commit 5908e18

Please sign in to comment.