pub fn parse_program(src: &str) -> Result<Program, ProgramErrors>Expand description
Parse the program source code into a list of instructions. If one or more errors are encountered during parsing, then the list of errors will be returned instead.
ยงExample
use tis_100::core::Instruction::*;
use tis_100::core::Source::*;
use tis_100::core::Register::*;
use tis_100::core::IoRegister::*;
use tis_100::core::Port::*;
use tis_100::parse::parse_program;
let src = "MOV UP ACC\nADD 1\nMOV ACC DOWN\n";
let prog = parse_program(src).unwrap();
assert_eq!(prog[0], Mov(REG(IO(DIR(UP))), ACC));
assert_eq!(prog[1], Add(VAL(1)));
assert_eq!(prog[2], Mov(REG(ACC), IO(DIR(DOWN))));