support C++ in build
This commit is contained in:
parent
600d01193c
commit
8733911e82
@ -3,6 +3,10 @@
|
||||
|
||||
#include "String.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int type;
|
||||
@ -24,4 +28,8 @@ enum
|
||||
|
||||
Node * Node_new(int type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -3,6 +3,10 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char * value;
|
||||
@ -17,4 +21,8 @@ static inline char * String_cstr(const String * st) { return st->value; }
|
||||
static inline size_t String_size(const String * st) { return st->size; }
|
||||
void String_free(String * st);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -10,6 +10,7 @@ extern FILE * yyin;
|
||||
|
||||
static const char * input_fname;
|
||||
|
||||
extern "C" {
|
||||
void parse(const char * filename)
|
||||
{
|
||||
input_fname = filename;
|
||||
@ -25,6 +26,7 @@ void parse(const char * filename)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static char * read_file(const char * filename, size_t * length)
|
||||
{
|
@ -2,11 +2,20 @@
|
||||
#define PARSER_H
|
||||
|
||||
#include "Node.h"
|
||||
#include "parser.tab.h"
|
||||
#include "parser.tab.hh"
|
||||
|
||||
#define YYSTYPE Node *
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void parse(const char * filename);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
void handle_parse_error(const char * str, const YYLTYPE * yylloc);
|
||||
|
||||
#endif
|
||||
|
10
wscript
10
wscript
@ -3,20 +3,24 @@ import sys
|
||||
APP_NAME = "cxlc"
|
||||
|
||||
def options(opt):
|
||||
opt.load("compiler_c");
|
||||
opt.load("compiler_c compiler_cxx");
|
||||
|
||||
def configure(conf):
|
||||
conf.load("compiler_c flex bison");
|
||||
conf.load("compiler_c compiler_cxx flex bison");
|
||||
|
||||
def build(bld):
|
||||
sources = bld.path.ant_glob("src/**/*.c")
|
||||
sources += bld.path.ant_glob("src/**/*.cc")
|
||||
lexer_source = "src/parser/parser.l"
|
||||
parser_source = "src/parser/parser.y"
|
||||
parser_source = "src/parser/parser.yc"
|
||||
sources += [lexer_source, parser_source]
|
||||
includes = ["src", "src/parser"]
|
||||
cflags = ["-Wall", "-O2"]
|
||||
cxxflags = cflags
|
||||
bld.program(
|
||||
features = ['c', 'cxx', 'cxxprogram'],
|
||||
source = sources,
|
||||
cflags = cflags,
|
||||
cxxflags = cxxflags,
|
||||
target = APP_NAME,
|
||||
includes = includes)
|
||||
|
Loading…
x
Reference in New Issue
Block a user