spmallette commented on code in PR #3091: URL: https://github.com/apache/tinkerpop/pull/3091#discussion_r2033829193
########## gremlin-language/src/main/java/org/apache/tinkerpop/gremlin/language/corpus/GrammarReader.java: ########## @@ -0,0 +1,63 @@ +/* + * 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. + */ +package org.apache.tinkerpop.gremlin.language.corpus; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Reads ANTLR grammar file to extract Gremlin keyword string representations. + */ +public class GrammarReader { + + // Pattern to match token definitions like: TADDALL: 'addAll'; + private static final Pattern tokenPattern = Pattern.compile("T[A-Z0-9_]+:\\s*'([^']+)'\\s*;"); + + /** + * Parse a grammar file to extract all keyword string representations. + * + * @param grammarFilePath The path to the ANTLR grammar file + * @return A set of keyword string representations + * @throws IOException If there's an error reading the file + */ + public static Set<String> parse(final String grammarFilePath) throws IOException { Review Comment: oh....we shouldn't do that 🙂 i was shooting for just some basic good faith testing here rather than complete coverage. i cant say i feel like we need the latter for this. -- 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]
