32 lines
No EOL
1 KiB
OCaml
32 lines
No EOL
1 KiB
OCaml
(*naloga instruction modula je ustvarjanje instructionLista, torej vsebine T zapisa*)
|
|
(*sem spada izbira nacina naslavljanja, dolocanje ali je operand simbol itd..*)
|
|
|
|
open SemanticAnalyzer
|
|
|
|
|
|
let string_is_symbol (s : string) : bool * string =
|
|
try
|
|
let _ = int_of_string s in
|
|
true, ""
|
|
with Failure _ -> false, s
|
|
|
|
(*preveri ali je operand iz mnemonic_type simbol ali stevilo*)
|
|
let operand_is_symbol (operand : mnemonic_type) : bool * string = (*vrne isSymbol in symbol*)
|
|
match operand with
|
|
| MnemonicD -> false, ""
|
|
| MnemonicDn s -> string_is_symbol s
|
|
| MnemonicF1 -> false, ""
|
|
| MnemonicF2n _ -> false, ""
|
|
| MnemonicF2r _ -> false, ""
|
|
| MnemonicF2rn (_, _) -> false, ""
|
|
| MnemonicF2rr (_, _) -> false, ""
|
|
| MnemonicF3 -> false, ""
|
|
| MnemonicF3m s -> string_is_symbol s
|
|
| MnemonicF4m s -> string_is_symbol s
|
|
| MnemonicSd s -> string_is_symbol s
|
|
| MnemonicSn _ -> false, ""
|
|
| COMMENT -> false, ""
|
|
|
|
|
|
let create_opcode_symbol (opcode : mnemonic) (locSimbola : int) : string =
|
|
(*izberi nacin naslavljanja in naredi string ukaza*) |