vhdlpp: line feed character (LF).

This commit is contained in:
Maciej Suminski 2016-01-08 15:41:29 +01:00
parent 054dfdf0cf
commit b08ae23d0d
3 changed files with 25 additions and 1 deletions

View File

@ -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;

View File

@ -29,6 +29,7 @@
# include "compiler.h"
# include <iostream>
# include <cassert>
# include <cstring>
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;
}

View File

@ -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<perm_string>*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 */