diff --git a/.gitignore b/.gitignore index e69de29..1cda6f3 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,2 @@ +build/ +CMakeCache.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..26ee1cc --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 2.8.12) +project(WRAITH_LANG C) + +set(CMAKE_C_STANDARD 99) + +find_package(BISON) +find_package(FLEX) + +include_directories(${CMAKE_SOURCE_DIR}) + +BISON_TARGET(Parser wraith.y ${CMAKE_CURRENT_BINARY_DIR}/y.tab.c COMPILE_FLAGS -d) +FLEX_TARGET(Scanner wraith.lex ${CMAKE_CURRENT_BINARY_DIR}/lex.yy.c) + +ADD_FLEX_BISON_DEPENDENCY(Scanner Parser) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) +add_executable( + wraith_compile + ${BISON_Parser_OUTPUTS} + ${FLEX_Scanner_OUTPUTS} +) diff --git a/wraith.lex b/wraith.lex index 2dec2b4..8137c48 100644 --- a/wraith.lex +++ b/wraith.lex @@ -1,3 +1,7 @@ +%{ + #include "y.tab.h" +%} + %option noyywrap %% diff --git a/wraith.y b/wraith.y index 0ab63de..2020b6a 100644 --- a/wraith.y +++ b/wraith.y @@ -2,7 +2,6 @@ #include #include "ast.h" #include "stack.h" -#define YYSTYPE struct Node* void yyerror(FILE *fp, char *s) { fprintf (stderr, "%s\n", s); @@ -10,10 +9,13 @@ void yyerror(FILE *fp, char *s) Stack *stack; -#define YYDEBUG 1 -int yydebug=1; +extern char *yytext; +extern int yylex (void); +extern FILE *yyin; %} +%define api.value.type {struct Node*} + %token NUMBER %token INT %token UINT @@ -234,8 +236,6 @@ Declarations : Declaration Declarations } %% -#include "lex.yy.c" - int main(int argc, char *argv[]) { if (argc < 2)