add initial empty C, flex, and bison sources
This commit is contained in:
parent
8d8c08cd85
commit
3ead22e0cf
8
src/main.c
Normal file
8
src/main.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(int argc, char * argv[])
|
||||||
|
{
|
||||||
|
printf("coming soon...\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
4
src/parser/parser.h
Normal file
4
src/parser/parser.h
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#ifndef PARSER_H
|
||||||
|
#define PARSER_H
|
||||||
|
|
||||||
|
#endif
|
15
src/parser/parser.l
Normal file
15
src/parser/parser.l
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
%option nounput
|
||||||
|
%option bison-locations
|
||||||
|
|
||||||
|
%{
|
||||||
|
|
||||||
|
#include "parser.h"
|
||||||
|
#include "parser.tab.h"
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
%x str
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
%%
|
38
src/parser/parser.y
Normal file
38
src/parser/parser.y
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
%{
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "parser.h"
|
||||||
|
#include "parser.tab.h"
|
||||||
|
|
||||||
|
#define yyerror(msg) handle_error(msg, &yyloc)
|
||||||
|
|
||||||
|
int yylex(YYSTYPE *, YYLTYPE *);
|
||||||
|
static void handle_error(const char * str, const YYLTYPE * yylloc);
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
%pure-parser
|
||||||
|
%locations
|
||||||
|
%error-verbose
|
||||||
|
|
||||||
|
%token PLUS;
|
||||||
|
%token MINUS;
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
translation_unit: PLUS;
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
static void handle_error(const char * str, const YYLTYPE * yylloc)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "error: %s (line %d, column %d)\n",
|
||||||
|
str,
|
||||||
|
yylloc->first_line,
|
||||||
|
yylloc->first_column);
|
||||||
|
}
|
||||||
|
|
||||||
|
int yywrap(void)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
21
wscript
21
wscript
@ -1,5 +1,22 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
APP_NAME = "cxlc"
|
||||||
|
|
||||||
|
def options(opt):
|
||||||
|
opt.load("compiler_c");
|
||||||
|
|
||||||
def configure(conf):
|
def configure(conf):
|
||||||
pass
|
conf.load("compiler_c flex bison");
|
||||||
|
|
||||||
def build(bld):
|
def build(bld):
|
||||||
pass
|
sources = bld.path.ant_glob("src/**/*.c")
|
||||||
|
lexer_source = "src/parser/parser.l"
|
||||||
|
parser_source = "src/parser/parser.y"
|
||||||
|
sources += [lexer_source, parser_source]
|
||||||
|
includes = ["src", "src/parser"]
|
||||||
|
cflags = ["-Wall", "-O2"]
|
||||||
|
bld.program(
|
||||||
|
source = sources,
|
||||||
|
cflags = cflags,
|
||||||
|
target = APP_NAME,
|
||||||
|
includes = includes)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user