aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2017-12-31 13:56:33 +0000
committerAleksey Kladov <[email protected]>2017-12-31 13:56:33 +0000
commit98a58bf806ffda1b4d3352ed0f3e494fa25c8c74 (patch)
tree7f309dee323e04dde12683bfa118d16c55249ea8 /src
parentcb6f07618440859a26fd6adea63bd030da375952 (diff)
Lexer: basic comments
Diffstat (limited to 'src')
-rw-r--r--src/lexer/comments.rs29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/lexer/comments.rs b/src/lexer/comments.rs
index c61c85824..79782cc5b 100644
--- a/src/lexer/comments.rs
+++ b/src/lexer/comments.rs
@@ -1,11 +1,36 @@
1use lexer::ptr::Ptr; 1use lexer::ptr::Ptr;
2 2
3use {SyntaxKind}; 3use {SyntaxKind};
4use syntax_kinds::*;
4 5
5pub(crate) fn scan_shebang(ptr: &mut Ptr) -> bool { 6pub(crate) fn scan_shebang(ptr: &mut Ptr) -> bool {
6 false 7 if ptr.next_is('!') && ptr.nnext_is('/') {
8 ptr.bump();
9 ptr.bump();
10 bump_until_eol(ptr);
11 true
12 } else {
13 false
14 }
7} 15}
8 16
9pub(crate) fn scan_comment(ptr: &mut Ptr) -> Option<SyntaxKind> { 17pub(crate) fn scan_comment(ptr: &mut Ptr) -> Option<SyntaxKind> {
10 None 18 if ptr.next_is('/') {
19 bump_until_eol(ptr);
20 Some(COMMENT)
21 } else {
22 None
23 }
24}
25
26
27fn bump_until_eol(ptr: &mut Ptr) {
28 loop {
29 if ptr.next_is('\n') || ptr.next_is('\r') && ptr.nnext_is('\n') {
30 return;
31 }
32 if ptr.bump().is_none() {
33 break;
34 }
35 }
11} \ No newline at end of file 36} \ No newline at end of file