Fixed log on floats
This commit is contained in:
parent
3daa431ec3
commit
b25838a1a8
@ -16,7 +16,11 @@ pub fn interpret(ast: Program) {
|
|||||||
Literal::StringLiteral(s) => args.push(s),
|
Literal::StringLiteral(s) => args.push(s),
|
||||||
Literal::IntLiteral(i) => args.push(format!("{}i", i)),
|
Literal::IntLiteral(i) => args.push(format!("{}i", i)),
|
||||||
Literal::FloatLiteral(f) => {
|
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)),
|
Literal::BooleanLiteral(b) => args.push(format!("{}", b)),
|
||||||
},
|
},
|
||||||
|
@ -75,9 +75,16 @@ pub fn tokenize(source: &str) -> Vec<Token> {
|
|||||||
'comment: loop {
|
'comment: loop {
|
||||||
if chars.get(current) == Some(&'*')
|
if chars.get(current) == Some(&'*')
|
||||||
&& chars.get(current + 1) == Some(&'/')
|
&& chars.get(current + 1) == Some(&'/')
|
||||||
&& depth == 1
|
|
||||||
{
|
{
|
||||||
|
depth -= 1;
|
||||||
|
if depth == 0 {
|
||||||
break 'comment;
|
break 'comment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if chars.get(current) == Some(&'/')
|
||||||
|
&& chars.get(current + 1) == Some(&'*')
|
||||||
|
{
|
||||||
|
depth += 1;
|
||||||
} else if chars.get(current) == None {
|
} else if chars.get(current) == None {
|
||||||
break 'comment;
|
break 'comment;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user