From fad0b0c506f2d7cb1158a3dac53139b8dec7a04e Mon Sep 17 00:00:00 2001 From: William Speirs Date: Tue, 14 Oct 2014 17:06:02 -0400 Subject: [PATCH] Updated lexers & parsers to include prefixes --- frontends/ilang/Makefile.inc | 22 ++++++++--------- frontends/ilang/{lexer.l => ilang_lexer.l} | 8 +++++-- frontends/ilang/{parser.y => ilang_parser.y} | 0 frontends/verilog/Makefile.inc | 24 +++++++++---------- .../verilog/{lexer.l => verilog_lexer.l} | 8 +++++-- .../verilog/{parser.y => verilog_parser.y} | 0 6 files changed, 35 insertions(+), 27 deletions(-) rename frontends/ilang/{lexer.l => ilang_lexer.l} (95%) rename frontends/ilang/{parser.y => ilang_parser.y} (100%) rename frontends/verilog/{lexer.l => verilog_lexer.l} (98%) rename frontends/verilog/{parser.y => verilog_parser.y} (100%) diff --git a/frontends/ilang/Makefile.inc b/frontends/ilang/Makefile.inc index e832cfed8..984d436c6 100644 --- a/frontends/ilang/Makefile.inc +++ b/frontends/ilang/Makefile.inc @@ -1,18 +1,18 @@ -GENFILES += frontends/ilang/parser.tab.cc -GENFILES += frontends/ilang/parser.tab.h -GENFILES += frontends/ilang/parser.output -GENFILES += frontends/ilang/lexer.cc +GENFILES += frontends/ilang/ilang_parser.tab.cc +GENFILES += frontends/ilang/ilang_parser.tab.h +GENFILES += frontends/ilang/ilang_parser.output +GENFILES += frontends/ilang/ilang_lexer.cc -frontends/ilang/parser.tab.cc: frontends/ilang/parser.y - $(P) bison -d -r all -b frontends/ilang/parser frontends/ilang/parser.y - $(Q) mv frontends/ilang/parser.tab.c frontends/ilang/parser.tab.cc +frontends/ilang/ilang_parser.tab.cc: frontends/ilang/ilang_parser.y + $(P) bison -d -r all -b frontends/ilang/ilang_parser frontends/ilang/ilang_parser.y + $(Q) mv frontends/ilang/ilang_parser.tab.c frontends/ilang/ilang_parser.tab.cc -frontends/ilang/parser.tab.h: frontends/ilang/parser.tab.cc +frontends/ilang/ilang_parser.tab.h: frontends/ilang/ilang_parser.tab.cc -frontends/ilang/lexer.cc: frontends/ilang/lexer.l - $(P) flex -o frontends/ilang/lexer.cc frontends/ilang/lexer.l +frontends/ilang/ilang_lexer.cc: frontends/ilang/ilang_lexer.l + $(P) flex -o frontends/ilang/ilang_lexer.cc frontends/ilang/ilang_lexer.l -OBJS += frontends/ilang/parser.tab.o frontends/ilang/lexer.o +OBJS += frontends/ilang/ilang_parser.tab.o frontends/ilang/ilang_lexer.o OBJS += frontends/ilang/ilang_frontend.o diff --git a/frontends/ilang/lexer.l b/frontends/ilang/ilang_lexer.l similarity index 95% rename from frontends/ilang/lexer.l rename to frontends/ilang/ilang_lexer.l index 9669f0924..dcbc6b6d7 100644 --- a/frontends/ilang/lexer.l +++ b/frontends/ilang/ilang_lexer.l @@ -30,12 +30,16 @@ #endif #include "ilang_frontend.h" -#include "parser.tab.h" +#include "ilang_parser.tab.h" USING_YOSYS_NAMESPACE #define YY_INPUT(buf,result,max_size) \ - result = readsome(*ILANG_FRONTEND::lexin, buf, max_size); + do { \ + ILANG_FRONTEND::lexin->read(buf, max_size-1); \ + result = ILANG_FRONTEND::lexin->gcount(); \ + if (result >= 0) buf[result] = '\0'; \ + } while (0) %} diff --git a/frontends/ilang/parser.y b/frontends/ilang/ilang_parser.y similarity index 100% rename from frontends/ilang/parser.y rename to frontends/ilang/ilang_parser.y diff --git a/frontends/verilog/Makefile.inc b/frontends/verilog/Makefile.inc index 49eb320ec..1b6854bb5 100644 --- a/frontends/verilog/Makefile.inc +++ b/frontends/verilog/Makefile.inc @@ -1,20 +1,20 @@ -GENFILES += frontends/verilog/parser.tab.cc -GENFILES += frontends/verilog/parser.tab.h -GENFILES += frontends/verilog/parser.output -GENFILES += frontends/verilog/lexer.cc +GENFILES += frontends/verilog/verilog_parser.tab.cc +GENFILES += frontends/verilog/verilog_parser.tab.h +GENFILES += frontends/verilog/verilog_parser.output +GENFILES += frontends/verilog/verilog_lexer.cc -frontends/verilog/parser.tab.cc: frontends/verilog/parser.y - $(P) bison -d -r all -b frontends/verilog/parser frontends/verilog/parser.y - $(Q) mv frontends/verilog/parser.tab.c frontends/verilog/parser.tab.cc +frontends/verilog/verilog_parser.tab.cc: frontends/verilog/verilog_parser.y + $(P) bison -d -r all -b frontends/verilog/verilog_parser frontends/verilog/verilog_parser.y + $(Q) mv frontends/verilog/verilog_parser.tab.c frontends/verilog/verilog_parser.tab.cc -frontends/verilog/parser.tab.h: frontends/verilog/parser.tab.cc +frontends/verilog/verilog_parser.tab.h: frontends/verilog/verilog_parser.tab.cc -frontends/verilog/lexer.cc: frontends/verilog/lexer.l - $(P) flex -o frontends/verilog/lexer.cc frontends/verilog/lexer.l +frontends/verilog/verilog_lexer.cc: frontends/verilog/verilog_lexer.l + $(P) flex -o frontends/verilog/verilog_lexer.cc frontends/verilog/verilog_lexer.l -OBJS += frontends/verilog/parser.tab.o -OBJS += frontends/verilog/lexer.o +OBJS += frontends/verilog/verilog_parser.tab.o +OBJS += frontends/verilog/verilog_lexer.o OBJS += frontends/verilog/preproc.o OBJS += frontends/verilog/verilog_frontend.o OBJS += frontends/verilog/const2ast.o diff --git a/frontends/verilog/lexer.l b/frontends/verilog/verilog_lexer.l similarity index 98% rename from frontends/verilog/lexer.l rename to frontends/verilog/verilog_lexer.l index 98f360885..0d28e2e7f 100644 --- a/frontends/verilog/lexer.l +++ b/frontends/verilog/verilog_lexer.l @@ -42,7 +42,7 @@ #include "kernel/log.h" #include "verilog_frontend.h" #include "frontends/ast/ast.h" -#include "parser.tab.h" +#include "verilog_parser.tab.h" USING_YOSYS_NAMESPACE using namespace AST; @@ -64,7 +64,11 @@ YOSYS_NAMESPACE_END return TOK_ID; #define YY_INPUT(buf,result,max_size) \ - result = readsome(*lexin, buf, max_size); + do { \ + lexin->read(buf, max_size-1); \ + result = lexin->gcount(); \ + if (result >= 0) buf[result] = '\0'; \ + } while (0) %} diff --git a/frontends/verilog/parser.y b/frontends/verilog/verilog_parser.y similarity index 100% rename from frontends/verilog/parser.y rename to frontends/verilog/verilog_parser.y -- 2.30.2