mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-01 21:21:10 +00:00
Merge pull request #313 from GreasySlug/main
Fix syntax is ignore after multi-line comment
This commit is contained in:
commit
68e0622efb
3 changed files with 20 additions and 4 deletions
|
@ -323,6 +323,8 @@ impl Lexer /*<'a>*/ {
|
||||||
(']', '#') => {
|
(']', '#') => {
|
||||||
nest_level -= 1;
|
nest_level -= 1;
|
||||||
if nest_level == 0 {
|
if nest_level == 0 {
|
||||||
|
self.consume(); // ]
|
||||||
|
self.consume(); // #
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -448,8 +450,7 @@ impl Lexer /*<'a>*/ {
|
||||||
if let Err(e) = self.lex_multi_line_comment() {
|
if let Err(e) = self.lex_multi_line_comment() {
|
||||||
return Some(Err(e));
|
return Some(Err(e));
|
||||||
}
|
}
|
||||||
}
|
} else if let Err(e) = self.lex_comment() {
|
||||||
if let Err(e) = self.lex_comment() {
|
|
||||||
return Some(Err(e));
|
return Some(Err(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1059,8 +1060,7 @@ impl Iterator for Lexer /*<'a>*/ {
|
||||||
if let Err(e) = self.lex_multi_line_comment() {
|
if let Err(e) = self.lex_multi_line_comment() {
|
||||||
return Some(Err(e));
|
return Some(Err(e));
|
||||||
}
|
}
|
||||||
}
|
} else if let Err(e) = self.lex_comment() {
|
||||||
if let Err(e) = self.lex_comment() {
|
|
||||||
return Some(Err(e));
|
return Some(Err(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
11
tests/should_ok/comment.er
Normal file
11
tests/should_ok/comment.er
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#[]#print! "hi"#[ if there isn't `;`, this code is evaluated `print! "hi"h print! "there"`
|
||||||
|
]#;print! "there"
|
||||||
|
print! #[]#0, 1#[]#, 2,#[]#3
|
||||||
|
a = {
|
||||||
|
#[first]#name #[second]#=#[third]#"John"#[fouth]#
|
||||||
|
}
|
||||||
|
Del a
|
||||||
|
#[]#print! 0
|
||||||
|
print!#[]#1
|
||||||
|
#[]#print! 2#[
|
||||||
|
]#
|
|
@ -224,3 +224,8 @@ fn exec_callable() -> Result<(), ()> {
|
||||||
fn exec_multiline_invalid_next() -> Result<(), ()> {
|
fn exec_multiline_invalid_next() -> Result<(), ()> {
|
||||||
expect_failure("tests/should_err/multi_line_invalid_nest.er", 1)
|
expect_failure("tests/should_err/multi_line_invalid_nest.er", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn exec_comment() -> Result<(), ()> {
|
||||||
|
expect_success("tests/should_ok/comment.er")
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue