diff --git a/src/tokenizer.rs b/src/tokenizer.rs index e6b2e1c..687e77a 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -61,6 +61,43 @@ pub fn tokenize(source: &str) -> Vec { }); current += 1; } + '/' => { + if chars.get(current + 1) == Some(&'/') { + // A "// ..." comment. + 'comment: loop { + if chars.get(current) == Some(&'\n') || chars.get(current) == None { + break 'comment; + } + 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 + { + break 'comment; + } 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 { + current += 1; + } + } _ => current += 1, // Just skip it if it's incorrect. } } diff --git a/test.pvt b/test.pvt index 8893982..34cd009 100644 --- a/test.pvt +++ b/test.pvt @@ -1,7 +1,21 @@ -log(2); -log(5i); -log(3f); -log(2.5); -log(true, false); -log("Hello world!"); -log('Goodbye cruel world!') +// A comment + +/* A multi-line +comment! */ + +/* +A multi-line comment! + +/* +A nested multi-line comment! +*/ + +*/ + +log(2); // An implicit int. +log(5i); // An explicit int. +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.