From f4f79038d103c77e36b9b4eb74f532a7f9598234 Mon Sep 17 00:00:00 2001 From: Christopher Durham Date: Sun, 28 Jan 2018 05:08:25 -0500 Subject: Block Comments closes #7 --- src/lexer/comments.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lexer/comments.rs b/src/lexer/comments.rs index b70f2c6c6..d388561bf 100644 --- a/src/lexer/comments.rs +++ b/src/lexer/comments.rs @@ -14,12 +14,35 @@ pub(crate) fn scan_shebang(ptr: &mut Ptr) -> bool { } } +pub(crate) fn scan_block_comment(ptr: &mut Ptr) -> Option { + if ptr.next_is('*') { + ptr.bump(); + let mut depth: u32 = 1; + while depth > 0 { + if ptr.next_is('*') && ptr.nnext_is('/') { + depth -= 1; + ptr.bump(); + ptr.bump(); + } else if ptr.next_is('/') && ptr.nnext_is('*') { + depth += 1; + ptr.bump(); + ptr.bump(); + } else if ptr.bump().is_none() { + break; + } + } + Some(COMMENT) + } else { + None + } +} + pub(crate) fn scan_comment(ptr: &mut Ptr) -> Option { if ptr.next_is('/') { bump_until_eol(ptr); Some(COMMENT) } else { - None + scan_block_comment(ptr) } } -- cgit v1.2.3 From 5982e6d73b600e00d4eb72800e30c3c0700eb75b Mon Sep 17 00:00:00 2001 From: Christopher Durham Date: Sun, 28 Jan 2018 05:51:39 -0500 Subject: Update comments.rs --- src/lexer/comments.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lexer/comments.rs b/src/lexer/comments.rs index d388561bf..d1e958817 100644 --- a/src/lexer/comments.rs +++ b/src/lexer/comments.rs @@ -14,7 +14,7 @@ pub(crate) fn scan_shebang(ptr: &mut Ptr) -> bool { } } -pub(crate) fn scan_block_comment(ptr: &mut Ptr) -> Option { +fn scan_block_comment(ptr: &mut Ptr) -> Option { if ptr.next_is('*') { ptr.bump(); let mut depth: u32 = 1; -- cgit v1.2.3