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