diff --git a/Makefile b/Makefile index d1c37ee..9f06843 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ RM ?= rm -f RMDIR ?= rm -rf MKDIR ?= mkdir -p -WARFLAGS := -Wall -Wextra -pedantic +WARFLAGS := -Wall #-Wextra -pedantic CFLAGS_g := $(WARFLAGS) -std=gnu11 -O2 -msse2 -ffast-math -mfpmath=sse -DNDEBUG \ -MMD @@ -28,13 +28,13 @@ SRCS := $(wildcard *.c) OBJS_g := $(SRCS:.c=.o) # include dirs -CFLAGS_g += +CFLAGS_g += # libs ifdef ISWIN LDFLAGS_g += else - CFLAGS_g += + CFLAGS_g += LDFLAGS_g += endif diff --git a/compiler.c b/compiler.c index fbbe76e..07eff22 100644 --- a/compiler.c +++ b/compiler.c @@ -1,7 +1,7 @@ #include "compiler.h" -//#include "scanner.h" +#include "scanner.h" void compile( VM* vm, const char* src ) { - //initScanner( src ); + initScanner( src ); } diff --git a/main.c b/main.c index 329b98a..1b26f36 100644 --- a/main.c +++ b/main.c @@ -4,6 +4,7 @@ #include "vm.h" #include +#include static void repl( VM* vm ) { char line[512]; @@ -13,6 +14,7 @@ static void repl( VM* vm ) { if ( !fgets( line, sizeof(line), stdin ) ) { printf( "\n" ); break; } + printf( "= %s", line ); interpret( vm, line ); } } @@ -56,12 +58,6 @@ int main( int argc, char** argv ) { (void)argc; (void)argv; srand( time( NULL ) ); - double dfp = 22.0 / 7.0; - printf( "DFP: %.64g\n", dfp ); - - float ffp = 22.0f / 7.0f; - printf( "FFP: %.64f\n", ffp ); - VM vm; initVM( &vm ); @@ -71,44 +67,9 @@ int main( int argc, char** argv ) { runFile( &vm, argv[1] ); } else { fprintf( stderr, "Usage: clox [path]\n" ); - exit( EXIT_FAILURE ); + //exit( EXIT_FAILURE ); } - /*Chunk c; - initChunk( &c ); - //c.bDebug = false; - - writeConstant( &c, 4.2f, 1 ); - writeConstant( &c, rand()/(float)RAND_MAX, 2 ); - - //for ( int i = 0; i < 10; ++i ) - // writeChunk( &c, rand() % NUM_OP, 5 ); - - // const overload - for ( int i = 2; i < 6; ++i ) { - writeConstant( &c, (float)rand()/RAND_MAX, 6 ); - } - - writeConstant( &c, 69069, 9 ); - writeChunk( &c, OP_NEGATE, 9 ); - - writeConstant( &c, 22, 9 ); - writeChunk( &c, OP_ADD, 9 ); - - writeConstant( &c, 42, 9 ); - writeChunk( &c, OP_DIVIDE, 9 ); - - writeChunk( &c, OP_RETURN, 10 ); - - //disassembleChunk( &c, "test" ); - - interpret( &vm, &c ); - printChunkInfo( &c, "test" ); - - printf( "vm %u chunk %u valar %u\n", sizeof(VM), sizeof(Chunk), sizeof(ValueArray) ); - - freeChunk( &c );*/ - freeVM( &vm ); return EXIT_SUCCESS; diff --git a/scanner.c b/scanner.c new file mode 100644 index 0000000..cd169aa --- /dev/null +++ b/scanner.c @@ -0,0 +1,7 @@ +#include "scanner.h" + +void initScanner( const char* src ) { +} + + + diff --git a/scanner.h b/scanner.h new file mode 100644 index 0000000..1633a77 --- /dev/null +++ b/scanner.h @@ -0,0 +1,7 @@ +#ifndef __SCANNER_H +#define __SCANNER_H + +void initScanner( const char* src ); + +#endif +