diff --git a/examples/comments.ion b/examples/comments.ion index 30f3a442372522a6e5c2ce77c940a32017a201e4..733163e01672607e99f796c88f4444b84ddf0216 100644 --- a/examples/comments.ion +++ b/examples/comments.ion @@ -1,3 +1,6 @@ echo Hello world # End of line comments are ignored #echo Goodbye world + #echo Nada +echo tabs ok #comment +echo not#a#comment \ No newline at end of file diff --git a/examples/comments.out b/examples/comments.out index 802992c4220de19a90767f3000a79a31b98d0df7..615dff6bd6c9be3b8258f3b7d060b72b62efbf8d 100644 --- a/examples/comments.out +++ b/examples/comments.out @@ -1 +1,3 @@ Hello world +tabs ok +not#a#comment diff --git a/src/parser/statements.rs b/src/parser/statements.rs index 23f9975379f981f092f24539a11222d47ed18f60..e6638f719abb87ec6101b7eb08bfc86cf94f75ab 100644 --- a/src/parser/statements.rs +++ b/src/parser/statements.rs @@ -113,6 +113,7 @@ impl<'a> Iterator for StatementSplitter<'a> { self.read += 1; match character { _ if self.flags.contains(POST_MATHEXPR) => (), + // [^A-Za-z0-9_}] 0...47 | 58...64 | 91...94 | 96 | 123...124 | 126...127 if self.flags.contains(VBRACE) => { // If we are just ending the braced section continue as normal if error.is_none() { @@ -219,7 +220,15 @@ impl<'a> Iterator for StatementSplitter<'a> { None => Some(Ok(self.data[start..self.read-1].trim())) }; }, - b'#' if !self.flags.intersects(SQUOTE | DQUOTE) && self.process_level == 0 && self.array_process_level == 0 => { + b'#' if self.read == 1 || ( + !self.flags.intersects(SQUOTE | DQUOTE) && + self.process_level == 0 && + self.array_process_level == 0 && + match self.data.as_bytes()[self.read - 2] { + b' ' | b'\t' => true, + _ => false + } + ) => { let output = self.data[start..self.read-1].trim(); self.read = self.data.len(); return match error { @@ -249,6 +258,7 @@ impl<'a> Iterator for StatementSplitter<'a> { } } } + // [^A-Za-z0-9_] 0...47 | 58...64 | 91...94 | 96 | 123...127 => self.flags -= VARIAB | ARRAY, _ => () }