diff --git a/src/interpreter.rs b/src/interpreter.rs index 59ff13d..e7d5e2f 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -16,7 +16,11 @@ pub fn interpret(ast: Program) { Literal::StringLiteral(s) => args.push(s), Literal::IntLiteral(i) => args.push(format!("{}i", i)), Literal::FloatLiteral(f) => { - args.push(format!("{}.{}f", f.trunc(), f.fract())) + if f.fract() == 0.0 { + args.push(format!("{}.0f", f)); + } else { + args.push(format!("{}f", f)); + } } Literal::BooleanLiteral(b) => args.push(format!("{}", b)), }, diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 687e77a..b9f4b30 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -75,9 +75,16 @@ pub fn tokenize(source: &str) -> Vec { 'comment: loop { if chars.get(current) == Some(&'*') && chars.get(current + 1) == Some(&'/') - && depth == 1 { - break 'comment; + 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 {