multiline comments are hella gay

This commit is contained in:
ElementG9 2020-08-25 16:10:44 -06:00
parent b25838a1a8
commit 5062b3aebe
2 changed files with 14 additions and 47 deletions

View File

@ -70,37 +70,6 @@ pub fn tokenize(source: &str) -> Vec<Token> {
} }
current += 1; current += 1;
} }
} else if chars.get(current + 1) == Some(&'*') {
let mut depth = 1;
'comment: loop {
if chars.get(current) == Some(&'*')
&& chars.get(current + 1) == Some(&'/')
{
depth -= 1;
if depth == 0 {
break 'comment;
}
}
if chars.get(current) == Some(&'/')
&& chars.get(current + 1) == Some(&'*')
{
depth += 1;
} else if chars.get(current) == None {
break 'comment;
} else {
current += 1;
}
}
// 'comment: loop {
// if (chars.get(current) == Some(&'/')
// && chars.get(current - 1) == Some(&'*'))
// || chars.get(current) == None
// {
// current += 1;
// break 'comment;
// }
// current += 1;
// }
} else { } else {
current += 1; current += 1;
} }

View File

@ -1,21 +1,19 @@
// A comment // A comment
/* A multi-line // An implicit int.
comment! */ log(2);
// An explicit int.
log(5i);
/* // An implicit float.
A multi-line comment! log(2.5);
// An explicit float.
log(3f);
/* // Booleans and multiple arguments.
A nested multi-line comment! log(true, false);
*/
*/ // Strings.
log("Hello world!");
log(2); // An implicit int. // A string showing how different delimiters layer.
log(5i); // An explicit int. log("What's that over there?");
log(2.5); // An implicit float.
log(3f); // An explicit float.
log(true, false); // Logging two things in one log call, and booleans.
log("Hello world!"); // A string literal.
log("What's that over there?"); // A string showing how different delimiters layer.