jt2594838 commented on code in PR #304:
URL: https://github.com/apache/tsfile/pull/304#discussion_r1877433998


##########
cpp/src/parser/PathNodesGenerator.cpp:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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 <string>
+#include <vector>
+
+#include "PathNodesGenerator.h"
+#include "utils/errno_define.h"
+#include "PathLexer.h"
+#include "PathParser.h"
+#include "PathParserError.h"
+#include "path_visitor.h"
+
+namespace storage {
+    std::vector<std::string> PathNodesGenerator::invokeParser(const 
std::string& path) {
+        antlr4::ANTLRInputStream inputStream(path);
+        PathLexer lexer(&inputStream);
+        lexer.removeErrorListeners(); 
+        // lexer.addErrorListener(&PathParseError::getInstance());

Review Comment:
   Remove or uncomment.



##########
cpp/src/parser/CMakeLists.txt:
##########
@@ -0,0 +1,22 @@
+#[[
+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
+
+    https://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.
+]]
+message("Running in src/storage/tsfile/Parser directory")

Review Comment:
   Where is "storage/tsfile" from?



##########
cpp/src/parser/PathParserError.h:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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 <antlr4-runtime.h>
+#include <stdexcept>
+#include <string>
+#include <set>
+#include <sstream>
+
+class PathParseError : public antlr4::BaseErrorListener {
+public:
+    static PathParseError& getInstance() {
+        static PathParseError instance;
+        return instance;
+    }
+
+    void syntaxError(antlr4::Recognizer* recognizer,
+                     antlr4::Token* offending_symbol,
+                     size_t line,
+                     size_t char_position_inLine,
+                     const std::string& msg,
+                     std::exception_ptr e) override {
+        std::string modified_msg = msg;
+
+        auto* parser = dynamic_cast<antlr4::Parser*>(recognizer);
+        if (parser != nullptr) {
+            auto expectedTokens = parser->getExpectedTokens();
+            auto vocabulary = parser->getVocabulary();
+
+            std::set<std::string> expectedTokenNames;
+            for (auto token : expectedTokens.toSet()) {
+                expectedTokenNames.insert(vocabulary.getDisplayName(token));
+            }
+
+            // 修改错误消息

Review Comment:
   Mind this



##########
cpp/test/parser/path_name_test.cc:
##########


Review Comment:
   Add some tests of illegal paths.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to