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
|
||||
WHITESPACE = _{ " " | "\t" | NEWLINE }
|
||||
COMMENT = _{ "//" ~ (!"\n" ~ ANY)* }
|
||||
COMMENT = _{ ("//" ~ (!"\n" ~ ANY)*) | ("/*" ~ (!"*/" ~ ANY)* ~ "*/") }
|
||||
|
||||
// C-style names
|
||||
name_char = { ASCII_ALPHA_LOWER | ASCII_ALPHA_UPPER | "_" | "$" }
|
||||
|
||||
Reference in New Issue
Block a user