Fixed empty inputs breaking the interactive repl

Also tweaked README.md and CONTRIBUTING.md
This commit is contained in:
2024-10-08 23:11:27 +11:00
parent 0779798347
commit 9f45925072
3 changed files with 13 additions and 4 deletions

View File

@@ -26,10 +26,10 @@ These data structures should be as independent as they can be, but there are som
```mermaid ```mermaid
graph TB graph TB
Toy_Value ---> Toy_Stack
Toy_Value ---> Toy_String
Toy_Value ---> Toy_Table
Toy_Bucket ---> Toy_String Toy_Bucket ---> Toy_String
Toy_Value ---> Toy_String
Toy_Value ---> Toy_Stack
Toy_Value ---> Toy_Table
Toy_Array Toy_Array
``` ```

View File

@@ -23,7 +23,11 @@ This repository holds the reference implementation for Toy version 2.x, written
# Syntax # Syntax
```toy ```toy
print 42; //print is a built-in keyword //print is a built-in keyword, that can handle complex expressions
print 6 * 7;
//strings can be concatenated with the .. operator
print "Hello" .. "world!";
//more examples to be added as the features are implemented //more examples to be added as the features are implemented
``` ```

View File

@@ -186,6 +186,11 @@ int repl(const char* name) {
inputBuffer[--length] = '\0'; inputBuffer[--length] = '\0';
} }
if (length == 0) {
printf("%s> ", name); //shows the terminal prompt
continue;
}
//end //end
if (strlen(inputBuffer) == 4 && (strncmp(inputBuffer, "exit", 4) == 0 || strncmp(inputBuffer, "quit", 4) == 0)) { if (strlen(inputBuffer) == 4 && (strncmp(inputBuffer, "exit", 4) == 0 || strncmp(inputBuffer, "quit", 4) == 0)) {
break; break;