This commit is contained in:
Jaka Furlan 2025-12-07 20:13:19 +01:00
parent 586a58fd94
commit c707e3253c
53 changed files with 500 additions and 27 deletions

28
ass3/zbirnik/bin/main.ml Normal file
View file

@ -0,0 +1,28 @@
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") )