diff --git a/tests/parser-cases/issue_215.thrift b/tests/parser-cases/issue_215.thrift new file mode 100644 index 0000000..f154985 --- /dev/null +++ b/tests/parser-cases/issue_215.thrift @@ -0,0 +1,6 @@ +struct Test { + 1: required i64 trueNum; +} + +const bool abool = true +const i32 falseValue = 123 diff --git a/tests/test_parser.py b/tests/test_parser.py index 75c12e7..291851a 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -254,3 +254,9 @@ def test_recursive_union(): 6: (TType.MAP, 'object', (TType.STRING, (TType.STRUCT, thrift.Dynamic)), False) } + + +def test_issue_215(): + thrift = load('parser-cases/issue_215.thrift') + assert thrift.abool is True + assert thrift.falseValue == 123 diff --git a/thriftpy/parser/lexer.py b/thriftpy/parser/lexer.py index ef4653d..2533e48 100644 --- a/thriftpy/parser/lexer.py +++ b/thriftpy/parser/lexer.py @@ -191,7 +191,7 @@ def t_ignore_COMMENT(t): def t_BOOLCONSTANT(t): - r'true|false' + r'\btrue\b|\bfalse\b' t.value = t.value == 'true' return t