From b08ae23d0d6974a1bcab2bbf542ff728208245b9 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 8 Jan 2016 15:41:29 +0100 Subject: [PATCH] vhdlpp: line feed character (LF). --- vhdlpp/parse.y | 6 +++++- vhdlpp/parse_misc.cc | 12 ++++++++++++ vhdlpp/parse_misc.h | 8 ++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/vhdlpp/parse.y b/vhdlpp/parse.y index 99b97ca7a..37a914a38 100644 --- a/vhdlpp/parse.y +++ b/vhdlpp/parse.y @@ -1675,7 +1675,11 @@ mode_opt : mode {$$ = $1;} | {$$ = PORT_NONE;} ; name /* IEEE 1076-2008 P8.1 */ : IDENTIFIER /* simple_name (IEEE 1076-2008 P8.2) */ - { Expression*tmp = new ExpName(lex_strings.make($1)); + { Expression*tmp; + /* Check if the IDENTIFIER is one of CHARACTER enums (LF, CR, etc.) */ + tmp = parse_char_enums($1); + if(!tmp) + tmp = new ExpName(lex_strings.make($1)); FILE_NAME(tmp, @1); delete[]$1; $$ = tmp; diff --git a/vhdlpp/parse_misc.cc b/vhdlpp/parse_misc.cc index cc9de0a1e..eefe5296b 100644 --- a/vhdlpp/parse_misc.cc +++ b/vhdlpp/parse_misc.cc @@ -29,6 +29,7 @@ # include "compiler.h" # include # include +# include using namespace std; @@ -153,3 +154,14 @@ const VType* calculate_subtype_range(const YYLTYPE&loc, const char*base_name, return subtype; } + +ExpString*parse_char_enums(const char*str) +{ + if(!strcasecmp(str, "LF")) + return new ExpString("\\n"); + + if(!strcasecmp(str, "CR")) + return new ExpString("\\r"); + + return NULL; +} diff --git a/vhdlpp/parse_misc.h b/vhdlpp/parse_misc.h index 195264298..d15a8d445 100644 --- a/vhdlpp/parse_misc.h +++ b/vhdlpp/parse_misc.h @@ -27,6 +27,7 @@ class Architecture; class Expression; class Package; class ExpRange; +class ExpString; class ScopeBase; class VType; @@ -63,4 +64,11 @@ extern void library_import(const YYLTYPE&loc, const std::list*names extern void library_use(const YYLTYPE&loc, ActiveScope*res, const char*libname, const char*pack, const char*ident); +/* + * Converts CHARACTER enums to an ExpString* if applicable. + * See the standard VHDL library (package STANDARD) or VHDL-2008/16.3 + * for more details). + */ +extern ExpString*parse_char_enums(const char*str); + #endif /* IVL_parse_misc_H */