(*tukaj je vse povezano s prvim prehodom zbirnika*) open SemanticAnalyzer let startAddr = ref 0 let locctr = ref 0 let prviPrehod (code : lineSemantic list) = let prviUkaz, ostaliUkazi = match code with | [] -> failwith "empty code" | x :: xs -> x, xs in (*if Opcode == start then*) if prviUkaz.opcode = START then let stAdr = get_string_from_mnemType prviUkaz.mnem in let stAdr = match stAdr with | Some s -> s | None -> "0" in startAddr := (int_of_string stAdr); locctr := !startAddr; (*TODO write line to intermediate file*) else (*initialize locctr to 0*) locctr := 0 ; (*while opcode != END loop*) let rec loop ostaliUkazi = match ostaliUkazi with | [] -> () (*smo konec*) | x :: _ when x.opcode = END -> () (*konec while loopa*) (*TODO write last line to intermediate file, save the locctr - st addr as prg len*) | x :: xs -> match x.opcode with | COMMENT -> loop xs (*if this is a comment line*) | _ -> (*if there is a symmbol in label field*) let s = match x.label with | None -> () | Some s -> () (*search simtab for s ...*) in (*search opcode -> smo ze naredili v semanticni analizi, tu bomo le ustrezno povečali locctr*) locctr := !locctr + x.len; (*TODO write line to intermediate file*) loop xs (*read nex input line end while*) in loop ostaliUkazi