Small fixes
This commit is contained in:
parent
d333cdfad5
commit
521bd9907a
|
|
@ -14,7 +14,6 @@
|
||||||
#include "sls/string.h"
|
#include "sls/string.h"
|
||||||
#include "sls/interpreter.h"
|
#include "sls/interpreter.h"
|
||||||
|
|
||||||
static const size_t BUFFER_SIZE = 256;
|
|
||||||
static const SlsStr REPL_FILE_NAME = SLS_STR_CONST("<STDIN>");
|
static const SlsStr REPL_FILE_NAME = SLS_STR_CONST("<STDIN>");
|
||||||
|
|
||||||
int repl(int argc, char *argv[]) {
|
int repl(int argc, char *argv[]) {
|
||||||
|
|
@ -28,8 +27,8 @@ int repl(int argc, char *argv[]) {
|
||||||
|
|
||||||
LexerInfo lexer_info;
|
LexerInfo lexer_info;
|
||||||
InterpreterState *interpreter_state = interpreter_create();
|
InterpreterState *interpreter_state = interpreter_create();
|
||||||
char buf[BUFFER_SIZE];
|
char buf[256];
|
||||||
while (fgets(buf, BUFFER_SIZE, stdin)) {
|
while (fgets(buf, sizeof buf, stdin)) {
|
||||||
size_t len = strlen(buf);
|
size_t len = strlen(buf);
|
||||||
if (len && buf[len - 1] == '\n') buf[len - 1] = '\0';
|
if (len && buf[len - 1] == '\n') buf[len - 1] = '\0';
|
||||||
if (strncmp(buf, "#exit", 5) == 0) {
|
if (strncmp(buf, "#exit", 5) == 0) {
|
||||||
|
|
@ -37,7 +36,7 @@ int repl(int argc, char *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SlsStr code = sls_str_malloc(buf, BUFFER_SIZE);
|
SlsStr code = sls_str_malloc(buf, sizeof buf);
|
||||||
init_lexer(&lexer_info, REPL_FILE_NAME, code);
|
init_lexer(&lexer_info, REPL_FILE_NAME, code);
|
||||||
LexerResult result = lexical_analysis(&lexer_info);
|
LexerResult result = lexical_analysis(&lexer_info);
|
||||||
if (result.type == SLS_ERROR) {
|
if (result.type == SLS_ERROR) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue