diff options
author | 2024-07-22 17:19:33 +0200 | |
---|---|---|
committer | 2024-07-22 17:19:33 +0200 | |
commit | 2a20043edb282dff05c9832b1576bf8894dd6473 (patch) | |
tree | 572638a56b46cbd90534ea6ba562b544f7273ec7 | |
parent | 2fd810be649548de92b7b34900205555250fab3b (diff) | |
download | properties-2a20043edb282dff05c9832b1576bf8894dd6473.tar.gz properties-2a20043edb282dff05c9832b1576bf8894dd6473.zip |
Add a first draft of the parser
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | properties.l | 6 | ||||
-rw-r--r-- | properties.y | 22 |
4 files changed, 34 insertions, 7 deletions
@@ -3,3 +3,5 @@ properties *.core a.out *-lexer.c +y.* +*-parser.*
\ No newline at end of file @@ -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); +} |