converted jlc.y -> jlc.yy for C++ support

git-svn-id: svn://anubis/misc/llvm@73 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
josh 2008-11-07 04:31:38 +00:00
parent e223ffa733
commit 416f9a3b8e
3 changed files with 28 additions and 14 deletions

View File

@ -3,17 +3,24 @@ FLEX := flex
BISON := bison BISON := bison
TARGET := jlc TARGET := jlc
LDFLAGS := -lfl
all: $(TARGET) all: $(TARGET)
$(TARGET): lex.yy.c $(TARGET).tab.c $(TARGET): lex.yy.o $(TARGET).tab.o
$(CC) -o $@ $^ $(CXX) -o $@ $^ $(LDFLAGS)
$(TARGET).tab.c $(TARGET).tab.h: $(TARGET).y lex.yy.o: lex.yy.c $(TARGET).tab.hh
$(CC) -c -o $@ $<
$(TARGET).tab.o: $(TARGET).tab.cc
$(CXX) -c -o $@ $<
$(TARGET).tab.cc $(TARGET).tab.hh: $(TARGET).yy
$(BISON) -d $< $(BISON) -d $<
lex.yy.c: $(TARGET).lex lex.yy.c: $(TARGET).lex
$(FLEX) $< $(FLEX) $<
clean: clean:
-rm -f lex.yy.c $(TARGET).tab.c $(TARGET).tab.h *~ *.o $(TARGET) -rm -f lex.yy.c $(TARGET).tab.cc $(TARGET).tab.hh *~ *.o $(TARGET)

View File

@ -1,6 +1,6 @@
%{ %{
#include "jlc.tab.h" #include "jlc.tab.hh"
%} %}
%% %%

View File

@ -2,6 +2,10 @@
%{ %{
#include <stdio.h> #include <stdio.h>
extern "C" {
int yylex(void);
}
extern FILE * yyin; extern FILE * yyin;
void yyerror(const char * str) void yyerror(const char * str)
@ -14,15 +18,6 @@ int yywrap()
return 1; return 1;
} }
int main(int argc, char * argv[])
{
if (argc > 0)
{
yyin = fopen(argv[1], "r");
}
yyparse();
}
%} %}
%token ASSIGN; %token ASSIGN;
@ -150,3 +145,15 @@ number: BIN_NUMBER
; ;
assignment: ID ASSIGN number SEMICOLON ; assignment: ID ASSIGN number SEMICOLON ;
%%
int main(int argc, char * argv[])
{
if (argc > 0)
{
yyin = fopen(argv[1], "r");
}
yyparse();
}