mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
Add support for decimal, octal and binary based cell values.
New syntax d#, b#, o# and h# allow for an explicit prefix on cell values to specify their base. Eg: <d# 123> Signed-off-by: Jon Loeliger <jdl@freescale.com>
This commit is contained in:
parent
c226ddcabc
commit
af0278a3a0
4 changed files with 51 additions and 8 deletions
21
dtc-lexer.l
21
dtc-lexer.l
|
@ -83,15 +83,24 @@ REFCHAR ({PROPCHAR}|{UNITCHAR}|[/@])
|
|||
BEGIN(INITIAL);
|
||||
return ';';
|
||||
}
|
||||
<CELLDATA>[bodh]# {
|
||||
yylloc.first_line = yylineno;
|
||||
if (*yytext == 'b')
|
||||
yylval.cbase = 2;
|
||||
else if (*yytext == 'o')
|
||||
yylval.cbase = 8;
|
||||
else if (*yytext == 'd')
|
||||
yylval.cbase = 10;
|
||||
else
|
||||
yylval.cbase = 16;
|
||||
DPRINT("Base: %d\n", yylval.cbase);
|
||||
return DT_BASE;
|
||||
}
|
||||
|
||||
<CELLDATA>[0-9a-fA-F]+ {
|
||||
yylloc.first_line = yylineno;
|
||||
if (yyleng > 2*sizeof(yylval.cval)) {
|
||||
fprintf(stderr,
|
||||
"Cell value %s too long\n", yytext);
|
||||
}
|
||||
yylval.cval = strtoul(yytext, NULL, 16);
|
||||
DPRINT("Cell: %x\n", yylval.cval);
|
||||
yylval.str = strdup(yytext);
|
||||
DPRINT("Cell: '%s'\n", yylval.str);
|
||||
return DT_CELL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue