diff --git a/forge_core/src/parser/ast_nodes/program.rs b/forge_core/src/parser/ast_nodes/program.rs index 5a1748b..854f416 100644 --- a/forge_core/src/parser/ast_nodes/program.rs +++ b/forge_core/src/parser/ast_nodes/program.rs @@ -33,4 +33,18 @@ mod test { ] ) } + + #[test] + fn parse_comments() { + // No other good place to put this test... + let prog = Program::from_str("global /* I am a comment */ foo; const blah = 3; // also a comment").unwrap(); + let decls: Vec<_> = dislocate(prog.0); + assert_eq!( + decls, + vec![ + Declaration::from_str("global foo;").unwrap(), + Declaration::from_str("const blah = 3;").unwrap(), + ] + ) + } } \ No newline at end of file diff --git a/forge_core/src/parser/forge.pest b/forge_core/src/parser/forge.pest index 30c488e..4bef986 100644 --- a/forge_core/src/parser/forge.pest +++ b/forge_core/src/parser/forge.pest @@ -1,6 +1,6 @@ // C++-style whitespace and comments WHITESPACE = _{ " " | "\t" | NEWLINE } -COMMENT = _{ "//" ~ (!"\n" ~ ANY)* } +COMMENT = _{ ("//" ~ (!"\n" ~ ANY)*) | ("/*" ~ (!"*/" ~ ANY)* ~ "*/") } // C-style names name_char = { ASCII_ALPHA_LOWER | ASCII_ALPHA_UPPER | "_" | "$" } diff --git a/vgfx/src/display.rs b/vgfx/src/display.rs index fa9a091..794f406 100644 --- a/vgfx/src/display.rs +++ b/vgfx/src/display.rs @@ -92,7 +92,7 @@ fn init_palette(machine: &mut P) { } fn to_byte_address((x, y): (Word, Word), reg: DisplayRegisters) -> Word { - let row_start = (y + reg.row_offset % reg.height) * reg.width + reg.screen; + let row_start = ((y + reg.row_offset) % reg.height) * reg.width + reg.screen; ((x + reg.col_offset) % reg.width) + row_start }