Skip to content

Commit

Permalink
json_of_syntax: handle optional operands, trim constants
Browse files Browse the repository at this point in the history
Update json_of_syntax to handle optional operands and trim constants.
Previously, optional operands were displayed inline with other operands,
causing ambiguity in the syntax.
```
vd,vs2,vs1vm
```

Optional operands are now enclosed in square brackets for clarity.
```
vd,vs2,vs1[,vm]
```

Operands containing constants such as `hex_bits_8(uimm,0b000)` were included
in the syntax output as:
```
rdc,rsc,uimm,0b000
```

Constants are now trimmed resulting in a more readable output:
```
rd,rsc,uimm
```
  • Loading branch information
Linda-Njau authored and ThinkOpenly committed Oct 30, 2024
1 parent 7692de3 commit 39c73b8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/sail_json_backend/json.ml
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,8 @@ let json_of_syntax k =
if String.equal s "sep" then ","
else if String.equal s "\"(\"" then "("
else if String.equal s "\")\"" then ")"
else if String.starts_with ~prefix:"maybe_" s then "[," ^ remove_identity_funcs s ^ "]"
else if String.contains s ',' then List.hd (Str.split (Str.regexp ",") (remove_identity_funcs s))
else remove_identity_funcs s
)
(List.tl (Hashtbl.find assembly_clean k))
Expand Down

0 comments on commit 39c73b8

Please sign in to comment.