This repository has been archived by the owner on Dec 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 286
字段名以true开头将出现语法错误 #215
Comments
test.thrift struct Test {
1:required i64 trueNum;
} test.py import sys
import thriftpy
from thriftpy.rpc import make_client
def main():
as_thrift = thriftpy.load('test.thrift', module_name='test_thrift')
if __name__ == '__main__':
main() 执行python3 test.py,报错如下: Traceback (most recent call last):
File "test.py", line 9, in <module>
main()
File "test.py", line 6, in main
as_thrift = thriftpy.load('test.thrift', module_name='test_thrift')
File "/usr/local/lib/python3.5/site-packages/thriftpy/parser/__init__.py", line 30, in load
include_dir=include_dir)
File "/usr/local/lib/python3.5/site-packages/thriftpy/parser/parser.py", line 502, in parse
parser.parse(data)
File "/usr/local/lib/python3.5/site-packages/ply/yacc.py", line 331, in parse
return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
File "/usr/local/lib/python3.5/site-packages/ply/yacc.py", line 1181, in parseopt_notrack
tok = call_errorfunc(self.errorfunc, errtoken, self)
File "/usr/local/lib/python3.5/site-packages/ply/yacc.py", line 193, in call_errorfunc
r = errorfunc(token)
File "/usr/local/lib/python3.5/site-packages/thriftpy/parser/parser.py", line 24, in p_error
(p.value, p.lineno))
thriftpy.parser.exc.ThriftGrammerError: Grammer error True at line 2 修改test.thrift 不以 true开头,在之前字段名前面加一个a,可以正常运行 struct Test {
1:required i64 atrueNum;
} |
尝试改了一下源文件 def t_BOOLCONSTANT(t):
r'true\W|false\W'
t.value = t.value == 'true'
return t |
Confirmed. |
lxyu
added a commit
that referenced
this issue
Jul 21, 2016
Add word boundary for true/false literal lexing, close #215
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
比如require i64 trueNum,这样将出现语法错误
The text was updated successfully, but these errors were encountered: