1.1
This commit is contained in:
parent
858db4dc0e
commit
7810346819
1 changed files with 34 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
open Zbirnik.Parser
|
open Zbirnik.Parser
|
||||||
open Zbirnik.SemanticAnalyzer
|
open Zbirnik.SemanticAnalyzer
|
||||||
|
open Zbirnik.PrehodPrvi
|
||||||
|
open Zbirnik.Simtab
|
||||||
|
|
||||||
|
|
||||||
(* Helper functions to print optional values *)
|
(* Helper functions to print optional values *)
|
||||||
|
|
@ -13,7 +15,7 @@ let print_opt_int = function
|
||||||
|
|
||||||
|
|
||||||
(* Main function to print a list of lineSemantic *)
|
(* Main function to print a list of lineSemantic *)
|
||||||
let print_lineSemantic_list (lines : lineSemantic list) =
|
let print_lineSemantic_list (lines : lineSemantic list) : unit =
|
||||||
List.iter (fun l ->
|
List.iter (fun l ->
|
||||||
Printf.printf "%4d | %8s | %6s | %20s | %s | %s\n"
|
Printf.printf "%4d | %8s | %6s | %20s | %s | %s\n"
|
||||||
l.line_no
|
l.line_no
|
||||||
|
|
@ -24,5 +26,35 @@ let print_lineSemantic_list (lines : lineSemantic list) =
|
||||||
(print_opt_int l.loc)
|
(print_opt_int l.loc)
|
||||||
) lines
|
) lines
|
||||||
|
|
||||||
|
let print_intermediate_file_list (lines : lineSemantic list) : unit =
|
||||||
|
List.iter (fun l ->
|
||||||
|
Printf.printf "%s | %8s | %6s | %20s | %s\n"
|
||||||
|
(print_opt_int l.loc)
|
||||||
|
(print_opt_string l.label)
|
||||||
|
(string_of_mnemonic l.opcode)
|
||||||
|
(string_of_mnemonic_type l.mnem)
|
||||||
|
(print_opt_string l.comment)
|
||||||
|
) lines
|
||||||
|
|
||||||
let () = print_lineSemantic_list (checkLineSemanticOfCode (parser "../../ass1/horner.asm") )
|
let print_symtab (tab : symtab) : unit =
|
||||||
|
Printf.printf "\nSYMBOL TABLE\n";
|
||||||
|
Printf.printf "----------------------\n";
|
||||||
|
Printf.printf "%-12s %s\n" "Symbol" "Address";
|
||||||
|
Printf.printf "----------------------\n";
|
||||||
|
Hashtbl.iter (fun sym addr ->
|
||||||
|
Printf.printf "%-12s %04X\n" sym addr
|
||||||
|
) tab;
|
||||||
|
Printf.printf "----------------------\n"
|
||||||
|
|
||||||
|
let run () =
|
||||||
|
let lineSemantic = (checkLineSemanticOfCode (parser "../../ass1/horner.asm") ) in
|
||||||
|
print_lineSemantic_list lineSemantic;
|
||||||
|
let prlen, prehod1, simtab = prviPrehod lineSemantic in
|
||||||
|
Printf.printf "----------------------------------";
|
||||||
|
Printf.printf "Program Length je: %d\n" prlen;
|
||||||
|
print_intermediate_file_list prehod1;
|
||||||
|
print_symtab simtab;
|
||||||
|
()
|
||||||
|
|
||||||
|
|
||||||
|
let () = run ()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue