diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2014-01-04 10:03:55 +1100 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2014-01-04 10:03:55 +1100 |
commit | cfc6523619c62d3eee505f53e7a18b253742961a (patch) | |
tree | 328d3ecc4e0c9e46388386c2ba35d84aded4f398 /dtc-parser.y | |
parent | b82b9776140a077db723f13832afd7e279a45184 (diff) | |
download | dtc-cfc6523619c62d3eee505f53e7a18b253742961a.zip dtc-cfc6523619c62d3eee505f53e7a18b253742961a.tar.gz dtc-cfc6523619c62d3eee505f53e7a18b253742961a.tar.bz2 |
Move character literal processing to the lexer
To match the processing of integer literals, character literals are passed
as a string from lexer to parser then interpreted there. This is just as
awkward as it was for integer literals, without the excuse that we used to
need the information about the dts version to process them correctly.
So, move character literal processing back to the lexer as well, cleaning
things up.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'dtc-parser.y')
-rw-r--r-- | dtc-parser.y | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/dtc-parser.y b/dtc-parser.y index 0ce0815..efe81dd 100644 --- a/dtc-parser.y +++ b/dtc-parser.y @@ -32,13 +32,10 @@ extern void yyerror(char const *s); extern struct boot_info *the_boot_info; extern bool treesource_error; - -static unsigned char eval_char_literal(const char *s); %} %union { char *propnodename; - char *literal; char *labelref; unsigned int cbase; uint8_t byte; @@ -65,7 +62,7 @@ static unsigned char eval_char_literal(const char *s); %token DT_DEL_NODE %token <propnodename> DT_PROPNODENAME %token <integer> DT_LITERAL -%token <literal> DT_CHAR_LITERAL +%token <integer> DT_CHAR_LITERAL %token <cbase> DT_BASE %token <byte> DT_BYTE %token <data> DT_STRING @@ -336,9 +333,6 @@ arrayprefix: integer_prim: DT_LITERAL | DT_CHAR_LITERAL - { - $$ = eval_char_literal($1); - } | '(' integer_expr ')' { $$ = $2; @@ -482,29 +476,3 @@ void print_error(char const *fmt, ...) void yyerror(char const *s) { print_error("%s", s); } - -static unsigned char eval_char_literal(const char *s) -{ - int i = 1; - char c = s[0]; - - if (c == '\0') - { - print_error("empty character literal"); - return 0; - } - - /* - * If the first character in the character literal is a \ then process - * the remaining characters as an escape encoding. If the first - * character is neither an escape or a terminator it should be the only - * character in the literal and will be returned. - */ - if (c == '\\') - c = get_escape_char(s, &i); - - if (s[i] != '\0') - print_error("malformed character literal"); - - return c; -} |