aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile11
-rw-r--r--properties.l6
-rw-r--r--properties.y22
4 files changed, 34 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index 6be102b..61cf493 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@ properties
*.core
a.out
*-lexer.c
+y.*
+*-parser.* \ No newline at end of file
diff --git a/Makefile b/Makefile
index 85e0bb8..de0f79f 100644
--- a/Makefile
+++ b/Makefile
@@ -3,10 +3,10 @@ LEX = lex
YACC = yacc
CC = cc
-OBJ = properties-lexer.o
+OBJ = properties-parser.o properties-lexer.o
CFLAGS = -DVERSION=${VER}
-LFLAGS = -ll
+LFLAGS = -ll -ly
all: properties
@@ -17,6 +17,12 @@ properties-lexer.o: properties.l
@mv lex.yy.c properties-lexer.c
${CC} ${CFLAGS} -c properties-lexer.c
+properties-parser.o properties-parser.h: properties.y
+ ${YACC} -d properties.y
+ @mv y.tab.c properties-parser.c
+ @mv y.tab.h properties-parser.h
+ ${CC} ${CFLAGS} -c properties-parser.c
+
properties: ${OBJ}
${CC} ${OBJ} -o $@ ${LFLAGS}
@@ -24,3 +30,4 @@ clean:
@rm -f ${OBJ} *.core a.out
@rm -f properties-lexer.c lex.*
@rm -f properties
+ @rm -f properties-parser.* y.*
diff --git a/properties.l b/properties.l
index 653c358..73803fc 100644
--- a/properties.l
+++ b/properties.l
@@ -1,9 +1,5 @@
%{
-enum {
- KEY = 1,
- DIV,
- VALUE
-};
+#include "properties-parser.h"
%}
%%
diff --git a/properties.y b/properties.y
new file mode 100644
index 0000000..69d683d
--- /dev/null
+++ b/properties.y
@@ -0,0 +1,22 @@
+%{
+
+#include <stdio.h>
+#include <stdlib.h>
+
+%}
+
+%token KEY DIV VALUE
+
+%%
+
+value: VALUE
+ | VALUE value
+ ;
+
+%%
+
+void
+yyerror(char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}