This commit is contained in:
Dane Johnson 2021-11-26 12:14:07 -06:00
parent caabe8eb52
commit acf66e1816
10 changed files with 30 additions and 27 deletions

View File

@ -1,18 +1,7 @@
.PHONY: all clean
all: deelang
lexer.o lexer.h: parser.h lexer.l
flex -o lexer.c --header-file=lexer.h lexer.l
$(CC) -c lexer.c
rm lexer.c
parser.h parser.o: parser.y
bison -o parser.c --header=parser.h parser.y
$(CC) -c parser.c
rm parser.c
deelang: deelang.c lexer.o parser.o
$(CC) -o $@ $^
all:
$(MAKE) -C src
mv src/deelang .
clean:
rm -rf parser.o lexer.o parser.h lexer.h deelang
$(MAKE) -C src clean
rm -f deelang

View File

@ -1,11 +0,0 @@
#include "lexer.h"
#include "parser.h"
void main() {
int t;
while ((t = yylex()) != 0) {
printf("yylex=0x%x\n", t);
printf("yylval=%s\n", yylval.sym);
}
printf("Byebye!");
}

18
src/Makefile Normal file
View File

@ -0,0 +1,18 @@
.PHONY: all clean
all: deelang
lexer.o lexer.h: parser.h lexer.l
flex -o lexer.c --header-file=lexer.h lexer.l
$(CC) -c lexer.c
rm lexer.c
parser.h parser.o: parser.y
bison -o parser.c --header=parser.h parser.y
$(CC) -c parser.c
rm parser.c
deelang: deelang.c lexer.o parser.o
$(CC) -o $@ $^
clean:
rm -rf parser.o lexer.o parser.h lexer.h deelang

View File

@ -1,5 +1,6 @@
%{
#include <stdio.h>
#include "syntax.h"
int yylex();
int yyerror(const char* p) { fprintf(stderr, p); }
%}

6
src/syntax.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef SYNTAX_H
#define SYNTAX_H
#endif /* SYNTAX_H */