diff --git a/scripts/small.toy b/scripts/small.toy index 8070b92..f3e002a 100644 --- a/scripts/small.toy +++ b/scripts/small.toy @@ -1,25 +1,2 @@ -import standard; //for a bunch of utility functions +/* -print "Hello world"; //"print" is a keyword - -var msg = "foobar"; //declare a variable like this - -assert true, "This message won't be seen"; //assert is another keyword - -//------------------------- - -fn makeCounter() { //declare a function like this - var total: int = 0; //declare a variable with a type like this - - fn counter(): int { //declare a return type like this - return ++total; - } - - return counter; //closures are explicitly supported -} - -var tally = makeCounter(); - -print tally(); //1 -print tally(); //2 -print tally(); //3 diff --git a/source/toy_lexer.c b/source/toy_lexer.c index 3ed3b42..333592a 100644 --- a/source/toy_lexer.c +++ b/source/toy_lexer.c @@ -61,7 +61,7 @@ static void eatWhitespace(Toy_Lexer* lexer) { //eat the line if (peekNext(lexer) == '/') { - while (advance(lexer) != '\n' && !isAtEnd(lexer)); + while (!isAtEnd(lexer) && advance(lexer) != '\n'); break; } @@ -69,7 +69,7 @@ static void eatWhitespace(Toy_Lexer* lexer) { if (peekNext(lexer) == '*') { advance(lexer); advance(lexer); - while(!(peek(lexer) == '*' && peekNext(lexer) == '/')) advance(lexer); + while(!isAtEnd(lexer) && !(peek(lexer) == '*' && peekNext(lexer) == '/')) advance(lexer); advance(lexer); advance(lexer); break;