Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

Commit

Permalink
Merge pull request #218 from hit9/fix-215
Browse files Browse the repository at this point in the history
Add word boundary for true/false literal lexing, close #215
  • Loading branch information
lxyu authored Jul 21, 2016
2 parents f13657b + 115b8a8 commit e9c087f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tests/parser-cases/issue_215.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
struct Test {
1: required i64 trueNum;
}

const bool abool = true
const i32 falseValue = 123
6 changes: 6 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion thriftpy/parser/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e9c087f

Please sign in to comment.