Merge pull request #313 from GreasySlug/main

Fix syntax is ignore after multi-line comment
This commit is contained in:
Slug 2022-12-26 21:03:15 +09:00 committed by GitHub
commit 68e0622efb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 4 deletions

View file

@ -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));
} }
} }

View 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#[
]#

View file

@ -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")
}