Fixed a scrolling bug, added C-style comments to Forge
This commit is contained in:
@@ -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(),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// C++-style whitespace and comments
|
// C++-style whitespace and comments
|
||||||
WHITESPACE = _{ " " | "\t" | NEWLINE }
|
WHITESPACE = _{ " " | "\t" | NEWLINE }
|
||||||
COMMENT = _{ "//" ~ (!"\n" ~ ANY)* }
|
COMMENT = _{ ("//" ~ (!"\n" ~ ANY)*) | ("/*" ~ (!"*/" ~ ANY)* ~ "*/") }
|
||||||
|
|
||||||
// C-style names
|
// C-style names
|
||||||
name_char = { ASCII_ALPHA_LOWER | ASCII_ALPHA_UPPER | "_" | "$" }
|
name_char = { ASCII_ALPHA_LOWER | ASCII_ALPHA_UPPER | "_" | "$" }
|
||||||
|
|||||||
+1
-1
@@ -92,7 +92,7 @@ fn init_palette<P: PeekPoke>(machine: &mut P) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn to_byte_address((x, y): (Word, Word), reg: DisplayRegisters) -> Word {
|
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
|
((x + reg.col_offset) % reg.width) + row_start
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user