forked from cosmonaut/wraith-lang
add cmake build process + switch to bison
parent
5861d07b07
commit
a849fa73c4
|
@ -0,0 +1,2 @@
|
|||
build/
|
||||
CMakeCache.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}
|
||||
)
|
|
@ -1,3 +1,7 @@
|
|||
%{
|
||||
#include "y.tab.h"
|
||||
%}
|
||||
|
||||
%option noyywrap
|
||||
|
||||
%%
|
||||
|
|
10
wraith.y
10
wraith.y
|
@ -2,7 +2,6 @@
|
|||
#include <stdio.h>
|
||||
#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)
|
||||
|
|
Loading…
Reference in New Issue