emit comments inside @if
rule
This commit is contained in:
parent
1a660c7aa8
commit
839f101829
@ -29,11 +29,10 @@ impl<'a> Parser<'a> {
|
||||
return Err(("expected \"}\".", self.span_before).into());
|
||||
}
|
||||
|
||||
self.whitespace_or_comment();
|
||||
|
||||
if init_cond.is_true() {
|
||||
self.scopes.enter_new_scope();
|
||||
found_true = true;
|
||||
|
||||
body = Parser {
|
||||
toks: self.toks,
|
||||
map: self.map,
|
||||
@ -53,6 +52,7 @@ impl<'a> Parser<'a> {
|
||||
module_config: self.module_config,
|
||||
}
|
||||
.parse_stmt()?;
|
||||
|
||||
self.scopes.exit_scope();
|
||||
} else {
|
||||
self.throw_away_until_closing_curly_brace()?;
|
||||
@ -108,6 +108,7 @@ impl<'a> Parser<'a> {
|
||||
module_config: self.module_config,
|
||||
}
|
||||
.parse_stmt()?;
|
||||
|
||||
self.scopes.exit_scope();
|
||||
} else {
|
||||
self.throw_away_until_closing_curly_brace()?;
|
||||
|
27
tests/if.rs
27
tests/if.rs
@ -184,6 +184,33 @@ test!(
|
||||
}",
|
||||
""
|
||||
);
|
||||
test!(
|
||||
comment_inside_if_body,
|
||||
"@if true {
|
||||
/* a */
|
||||
}",
|
||||
"/* a */\n"
|
||||
);
|
||||
test!(
|
||||
comment_inside_if_else_body,
|
||||
"@if false {
|
||||
/* a */
|
||||
} @else if true {
|
||||
/* b */
|
||||
}",
|
||||
"/* b */\n"
|
||||
);
|
||||
test!(
|
||||
comment_inside_else_body,
|
||||
"@if false {
|
||||
/* a */
|
||||
} @else if false {
|
||||
/* b */
|
||||
} @else {
|
||||
/* c */
|
||||
}",
|
||||
"/* c */\n"
|
||||
);
|
||||
error!(
|
||||
nothing_after_escape,
|
||||
"@if \\", "Error: Expected expression."
|
||||
|
Loading…
x
Reference in New Issue
Block a user