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 <andrew.p.boie@intel.com>
diff --git a/scripts/expr_parser.py b/scripts/expr_parser.py
index 1d3eb3a..e0fbf17 100644
--- a/scripts/expr_parser.py
+++ b/scripts/expr_parser.py
@@ -173,7 +173,11 @@
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):