You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/08/15 04:25:33 UTC

[GitHub] [netbeans] lkishalmi commented on a diff in pull request #4503: Some support for TOML files

lkishalmi commented on code in PR #4503:
URL: https://github.com/apache/netbeans/pull/4503#discussion_r945417959


##########
ide/languages.toml/src/org/netbeans/modules/languages/toml/TomlLexer.java:
##########
@@ -0,0 +1,168 @@
+/*
+ * 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.netbeans.modules.languages.toml;
+
+import org.antlr.v4.runtime.misc.IntegerList;
+import org.netbeans.api.lexer.Token;
+import org.netbeans.spi.lexer.Lexer;
+import org.netbeans.spi.lexer.LexerRestartInfo;
+import org.netbeans.spi.lexer.TokenFactory;
+
+import static org.tomlj.internal.TomlLexer.*;
+import static org.netbeans.modules.languages.toml.TomlTokenId.*;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public final class TomlLexer implements Lexer<TomlTokenId> {
+
+    private final TokenFactory<TomlTokenId> tokenFactory;
+    private org.tomlj.internal.TomlLexer lexer;
+
+    public TomlLexer(LexerRestartInfo<TomlTokenId> info) {
+        this.tokenFactory = info.tokenFactory();
+        try {
+            this.lexer = new org.tomlj.internal.TomlLexer(new LexerInputCharStream(info.input()));
+            if (info.state() != null) {
+                ((LexerState) info.state()).restore(lexer);
+            }
+        } catch (Throwable ex) {
+            ex.printStackTrace();

Review Comment:
   Well, I probably should return an ERROR token, than maybe make sure than an EOF is returned. 
   The TOML lexre was able to produce an ArrayIndexOutOfBounds exception and IAE on wrong input, though it might be because I was wrong about the state saving. Anyway. Thanks for spotting this one. Need to check what shall I really do.



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists