open Zbirnik.Parser
open Zbirnik.SemanticAnalyzer


(* Helper functions to print optional values *)
let print_opt_string = function
  | Some s -> s
  | None -> ""

let print_opt_int = function
  | Some n -> Printf.sprintf "%04X" n
  | None -> "----"


(* Main function to print a list of lineSemantic *)
let print_lineSemantic_list (lines : lineSemantic list) =
  List.iter (fun l ->
      Printf.printf "%4d | %8s | %6s | %20s | %s | %s\n"
        l.line_no
        (print_opt_string l.label)
        (string_of_mnemonic l.opcode)
        (string_of_mnemonic_type l.mnem)
        (print_opt_string l.comment)
        (print_opt_int l.loc)
    ) lines


let () = print_lineSemantic_list (checkLineSemanticOfCode (parser "../../ass1/horner.asm") )
