File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ pub enum Token {
2828
2929pub fn translate_line ( line : & str ) -> Result < Vec < MaybeUnresolvedInstr > > {
3030 let ( instruction, comment) = line. split_once ( ';' ) . unwrap ( ) ;
31+ // The UNCA examples don't use spaces between instruction args, so we should always just add a
32+ // space after a comma to make sure we're able to parse properly
33+ let instruction = instruction. replace ( ',' , ", " ) ;
3134 let splits = instruction. split_ascii_whitespace ( ) ;
3235 let mut token_chain: Vec < Token > = Vec :: new ( ) ;
3336
@@ -58,4 +61,13 @@ mod test {
5861 assert_eq ! ( machine_code. len( ) , 1 ) ;
5962 assert_eq ! ( machine_code. first( ) . unwrap( ) . value, 0b0101000001000000 ) ;
6063 }
64+
65+ #[ test]
66+ fn translate_instr_no_space ( ) {
67+ let instruction: & str = "AND R0,R1,R0;" ;
68+ let machine_code = translate_line ( instruction) . unwrap ( ) ;
69+
70+ assert_eq ! ( machine_code. len( ) , 1 ) ;
71+ assert_eq ! ( machine_code. first( ) . unwrap( ) . value, 0b0101000001000000 ) ;
72+ }
6173}
You can’t perform that action at this time.
0 commit comments