aboutsummaryrefslogtreecommitdiff
path: root/src/lexer
diff options
context:
space:
mode:
authorChristopher Durham <[email protected]>2018-01-28 10:08:25 +0000
committerChristopher Durham <[email protected]>2018-01-28 10:08:25 +0000
commitf4f79038d103c77e36b9b4eb74f532a7f9598234 (patch)
treee315526832ad8380e78c9bd45d92ae1a871e0b3f /src/lexer
parenteafb9c3ab4fa53697c5ce4e595b26e91c5d79126 (diff)
Block Comments
closes #7
Diffstat (limited to 'src/lexer')
-rw-r--r--src/lexer/comments.rs25
1 files changed, 24 insertions, 1 deletions
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 {
14 } 14 }
15} 15}
16 16
17pub(crate) fn scan_block_comment(ptr: &mut Ptr) -> Option<SyntaxKind> {
18 if ptr.next_is('*') {
19 ptr.bump();
20 let mut depth: u32 = 1;
21 while depth > 0 {
22 if ptr.next_is('*') && ptr.nnext_is('/') {
23 depth -= 1;
24 ptr.bump();
25 ptr.bump();
26 } else if ptr.next_is('/') && ptr.nnext_is('*') {
27 depth += 1;
28 ptr.bump();
29 ptr.bump();
30 } else if ptr.bump().is_none() {
31 break;
32 }
33 }
34 Some(COMMENT)
35 } else {
36 None
37 }
38}
39
17pub(crate) fn scan_comment(ptr: &mut Ptr) -> Option<SyntaxKind> { 40pub(crate) fn scan_comment(ptr: &mut Ptr) -> Option<SyntaxKind> {
18 if ptr.next_is('/') { 41 if ptr.next_is('/') {
19 bump_until_eol(ptr); 42 bump_until_eol(ptr);
20 Some(COMMENT) 43 Some(COMMENT)
21 } else { 44 } else {
22 None 45 scan_block_comment(ptr)
23 } 46 }
24} 47}
25 48