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

Add word boundary for true/false literal lexing, close #215 #218

Merged
merged 1 commit into from
Jul 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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