From 31e772de20f5dbd889edddcc9362579cb3aee33c Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Tue, 18 Apr 2017 11:22:50 -0700 Subject: [PATCH] expr_parser: fix issue with hex values in environment Hex mumeric values directly in the expression were cast correctly via the t_HEX rule, but ValueErrors would occur if a hex value was looked up due to the expansion of some environment symbol. Change-Id: Ia98dfea91eff4ed95778922d38d2967284f4e31b Signed-off-by: Andrew Boie --- scripts/expr_parser.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/expr_parser.py b/scripts/expr_parser.py index 1d3eb3a8ddd..e0fbf1768e8 100644 --- a/scripts/expr_parser.py +++ b/scripts/expr_parser.py @@ -173,7 +173,11 @@ def ast_sym(ast, env): def ast_sym_int(ast, env): if ast in env: - return int(env[ast]) + v = env[ast] + if v.startswith("0x") or v.startswith("0X"): + return int(v, 16) + else: + return int(v, 10) return 0 def ast_expr(ast, env):