From 3409a7dbe08bdc98d7663e5dcafaee5792d12139 Mon Sep 17 00:00:00 2001 From: sanine Date: Wed, 18 Jan 2023 13:18:13 -0600 Subject: working prefixes --- yy/kalmia.h | 2 ++ yy/kalmia.l | 3 +++ yy/kalmia.y | 5 +++-- yy/main.c | 8 ++++---- yy/makefile | 4 +++- 5 files changed, 15 insertions(+), 7 deletions(-) (limited to 'yy') diff --git a/yy/kalmia.h b/yy/kalmia.h index 6259956..98afd13 100644 --- a/yy/kalmia.h +++ b/yy/kalmia.h @@ -1,2 +1,4 @@ +#define YYLTYPE KALMIALTYPE +#define YYSTYPE KALMIASTYPE #include "kalmia.tab.h" #include "kalmia.lex.h" diff --git a/yy/kalmia.l b/yy/kalmia.l index 916f576..697d6ac 100644 --- a/yy/kalmia.l +++ b/yy/kalmia.l @@ -1,9 +1,12 @@ %option noinput nounput noyywrap 8bit nodefault %option reentrant bison-bridge bison-locations +%option prefix="kalmia" %start STRING %{ #include +#define YYLTYPE KALMIALTYPE +#define YYSTYPE KALMIASTYPE #include "kalmia.tab.h" #define YY_USER_ACTION \ yylloc->first_line = yylloc->last_line; \ diff --git a/yy/kalmia.y b/yy/kalmia.y index 78bf895..f1d77f9 100644 --- a/yy/kalmia.y +++ b/yy/kalmia.y @@ -1,4 +1,5 @@ %define api.pure full +%define api.prefix {kalmia} %locations %define parse.error verbose %param { yyscan_t scanner } @@ -77,8 +78,8 @@ attribute: integers: - INTEGER { printf("%d\n", $1); } - | integers INTEGER { printf("%d\n", $2); } + INTEGER { printf("%ld\n", $1); } + | integers INTEGER { printf("%ld\n", $2); } ; doubles: diff --git a/yy/main.c b/yy/main.c index d53a598..52ee955 100644 --- a/yy/main.c +++ b/yy/main.c @@ -14,9 +14,9 @@ int main(int argc, char **argv) } yyscan_t scanner; - yylex_init(&scanner); - yyset_in(in, scanner); - yyparse(scanner); - yylex_destroy(scanner); + kalmialex_init(&scanner); + kalmiaset_in(in, scanner); + kalmiaparse(scanner); + kalmialex_destroy(scanner); return 0; } diff --git a/yy/makefile b/yy/makefile index 5c9ce5f..76b5c77 100644 --- a/yy/makefile +++ b/yy/makefile @@ -1,3 +1,5 @@ +WARNINGS = -Wall -Wextra -Wpedantic + all: kalmia kalmia.tab.c: kalmia.y @@ -7,7 +9,7 @@ kalmia.lex.c: kalmia.l flex -o "$@" --header-file="kalmia.lex.h" kalmia.l kalmia: kalmia.tab.c kalmia.lex.c main.c kalmia.h - gcc -o kalmia main.c kalmia.tab.c kalmia.lex.c -lfl + gcc -o kalmia ${WARNINGS} main.c kalmia.tab.c kalmia.lex.c clean: rm kalmia.lex.c kalmia.lex.h kalmia.tab.c kalmia.tab.h kalmia -- cgit v1.2.1