diff options
author | A. Unique TensorFlower <nobody@tensorflow.org> | 2016-03-09 14:30:16 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-03-09 15:48:22 -0800 |
commit | 21be30413d9432e140a234873fa1111d3aa695dd (patch) | |
tree | ce69b2ba985c1cd08cb3d9ea747f0d04e014ec7d /tensorflow/core/framework/op_def_util.cc | |
parent | 11f4d83b064fd53b0d4063b3c40212e11710b051 (diff) |
Replace uses of RE2 with Scanner, for sources that are used on mobile.
This CL also adds the Scanner class to do simple scans over strings, to mimic
regexp behavior like [a-zA-Z][a-zA-Z0-9]* with:
Scanner scan(s);
scan.One(Scanner::LETTER);
scan.Any(Scanner::LETTER_DIGIT);
bool matched = scan.GetResult();
Change: 116803757
Diffstat (limited to 'tensorflow/core/framework/op_def_util.cc')
-rw-r--r-- | tensorflow/core/framework/op_def_util.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/tensorflow/core/framework/op_def_util.cc b/tensorflow/core/framework/op_def_util.cc index b94207e2e8..f7e4f1f05a 100644 --- a/tensorflow/core/framework/op_def_util.cc +++ b/tensorflow/core/framework/op_def_util.cc @@ -22,8 +22,8 @@ limitations under the License. #include "tensorflow/core/lib/core/errors.h" #include "tensorflow/core/lib/core/stringpiece.h" #include "tensorflow/core/lib/gtl/map_util.h" +#include "tensorflow/core/lib/strings/scanner.h" #include "tensorflow/core/platform/protobuf.h" -#include "tensorflow/core/platform/regexp.h" #include "tensorflow/core/platform/types.h" namespace tensorflow { @@ -221,8 +221,16 @@ static Status ValidateArg(const OpDef::ArgDef& arg, const OpDef& op_def, } Status ValidateOpDef(const OpDef& op_def) { - VALIDATE(RE2::FullMatch(op_def.name(), "(?:_.*|[A-Z][a-zA-Z0-9]*)"), - "Invalid name: ", op_def.name(), " (Did you use CamelCase?)"); + using ::tensorflow::strings::Scanner; + + if (!StringPiece(op_def.name()).starts_with("_")) { + VALIDATE(Scanner(op_def.name()) + .One(Scanner::UPPERLETTER) + .Any(Scanner::LETTER_DIGIT) + .Eos() + .GetResult(), + "Invalid name: ", op_def.name(), " (Did you use CamelCase?)"); + } std::set<string> names; // for detecting duplicate names for (const auto& attr : op_def.attr()) { |