From de07408e43ac50c2b9f71ab26cf71ee517573763 Mon Sep 17 00:00:00 2001 From: Carl Yeksigian Date: Tue, 4 Jun 2013 04:28:31 -0400 Subject: [PATCH] THRIFT-1995: IDL can generate uncompilable ocde Patch: Carl Yeksigian --- compiler/cpp/src/thriftl.ll | 4 ++-- test/Include.thrift | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 test/Include.thrift diff --git a/compiler/cpp/src/thriftl.ll b/compiler/cpp/src/thriftl.ll index 0a048406..8accf4cd 100644 --- a/compiler/cpp/src/thriftl.ll +++ b/compiler/cpp/src/thriftl.ll @@ -89,7 +89,7 @@ void unexpected_token(char* text) { intconstant ([+-]?[0-9]+) hexconstant ("0x"[0-9A-Fa-f]+) dubconstant ([+-]?[0-9]*(\.[0-9]+)?([eE][+-]?[0-9]+)?) -identifier ([a-zA-Z_][\.a-zA-Z_0-9]*) +identifier ([a-zA-Z_](\.[a-zA-Z_0-9]|[a-zA-Z_0-9])*) whitespace ([ \t\r\n]*) sillycomm ("/*""*"*"*/") multicomm ("/*"[^*]"/"*([^*/]|[^*]"/"|"*"[^/])*"*"*"*/") @@ -97,7 +97,7 @@ doctext ("/**"([^*/]|[^*]"/"|"*"[^/])*"*"*"*/") comment ("//"[^\n]*) unixcomment ("#"[^\n]*) symbol ([:;\,\{\}\(\)\=<>\[\]]) -st_identifier ([a-zA-Z-][\.a-zA-Z_0-9-]*) +st_identifier ([a-zA-Z-](\.[a-zA-Z_0-9-]|[a-zA-Z_0-9-])*) literal_begin (['\"]) %% diff --git a/test/Include.thrift b/test/Include.thrift new file mode 100644 index 00000000..562319b2 --- /dev/null +++ b/test/Include.thrift @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +include "ThriftTest.thrift" + +struct IncludeTest { + 1: required ThriftTest.Bools bools +} \ No newline at end of file -- 2.17.1