Skip to content

Commit

Permalink
fix: Fixed var expression statement
Browse files Browse the repository at this point in the history
  • Loading branch information
JothamWong committed Mar 28, 2024
1 parent e1ac97b commit 86d6d51
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
6 changes: 1 addition & 5 deletions src/parser/ooga.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,7 @@ function peg$parse(input, options) {
}
};
var peg$f59 = function(id, init) {
return {
tag: "Name",
id: id,
expression: extractOptional(init, 1)
}
return id;
};
var peg$f60 = function(id, type, init) {
return {
Expand Down
6 changes: 1 addition & 5 deletions src/parser/ooga.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -555,11 +555,7 @@ VariableStatement
}
}
/ id:Identifier init:(__ ShorthandInitialiser)? EOS {
return {
tag: "Name",
id: id,
expression: extractOptional(init, 1)
}
return id;
}

ConstantStatement
Expand Down
17 changes: 14 additions & 3 deletions src/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ export function testProgram(program: string, expectedValue: any) {
console.log('--------------------------------------------')
}

// Testing simple var expressions
testProgram(
`
var x = 5;
x;
`,
5
);



// Testing simple identity function
testProgram(
`
Expand All @@ -41,7 +52,7 @@ func foo(n) {
foo(5);
`,
5
)
);

// Testing recursive function
testProgram(
Expand All @@ -56,7 +67,7 @@ func factorial(n) {
factorial(5);
`,
120
)
);

// Testing goroutine
testProgram(
Expand All @@ -74,4 +85,4 @@ go func() {
a + b;
`,
5
)
);
3 changes: 0 additions & 3 deletions src/vm/oogavm-scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,11 @@ export class RoundRobinScheduler implements Scheduler {
}

runThread(): [ThreadId, number] | null {
console.log("Changing thread");
if (this._idleThreads.length === 0) {
return null;
} else {
// The ! is a non-null assertion operator
const nextThread = this._idleThreads.shift()!
console.log("nextThread inside scheduler is ");
console.log(nextThread);
// const timeQuanta = Math.ceil(0.5 + Math.random() * 0.5) * this._maxTimeQuanta;
const timeQuanta = this._maxTimeQuanta + 5;
this._currentThreads.add(nextThread);
Expand Down

0 comments on commit 86d6d51

Please sign in to comment.