Skip to content

Commit

Permalink
add float support hax
Browse files Browse the repository at this point in the history
  • Loading branch information
JothamWong committed Apr 4, 2024
1 parent 25390fd commit 0ed2f09
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/parser/ooga.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ InitType
switch(type[0]) {
case "int":
return "Integer";
case "float":
return "Integer";
case "bool":
return "Boolean";
case "string":
Expand Down Expand Up @@ -148,7 +150,10 @@ NumericLiteral "number"
}

DecimalLiteral
= DecimalIntegerLiteral {
= DecimalIntegerLiteral "." DecimalDigit* {
return { tag: "Integer", value: parseFloat(text()) };
}
/ DecimalIntegerLiteral {
return { tag: "Integer", value: parseFloat(text()) };
}

Expand Down Expand Up @@ -226,7 +231,7 @@ ReturnToken = "return" !IdentifierPart
ThisToken = "this" !IdentifierPart
TrueToken = "true" !IdentifierPart
VarToken = "var" !IdentifierPart
IntegerToken = "int" !IdentifierPart
IntegerToken = "int"/"float" !IdentifierPart
BooleanToken = "bool" !IdentifierPart
StringToken = "string" !IdentifierPart
GoroutineToken = "go" !IdentifierPart
Expand Down
2 changes: 1 addition & 1 deletion src/vm/oogavm-typechecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const types = {
const StructTable = {};

function is_integer(x) {
return typeof x === 'number' && x % 1 === 0;
return typeof x === 'number';
}

function is_boolean(x) {
Expand Down

0 comments on commit 0ed2f09

Please sign in to comment.