This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/master by this push:
new 3daeaff WIP
3daeaff is described below
commit 3daeaff56c6d707fcd6893e54bcaa83e38dd6f37
Author: Aaron Radzinski <[email protected]>
AuthorDate: Tue Oct 5 11:57:32 2021 -0700
WIP
---
.../nlpcraft/common/ansi/NCAnsiProgressBar.scala | 6 +--
.../nlpcraft/common/antlr4/NCCompilerUtils.scala | 49 ++++++++++++++++++++++
.../org/apache/nlpcraft/common/util/NCUtils.scala | 6 +--
.../apache/nlpcraft/common/version/NCVersion.scala | 2 +-
4 files changed, 56 insertions(+), 7 deletions(-)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/ansi/NCAnsiProgressBar.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/ansi/NCAnsiProgressBar.scala
index dc8e5f2..64b5705 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/ansi/NCAnsiProgressBar.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/ansi/NCAnsiProgressBar.scala
@@ -18,10 +18,10 @@
package org.apache.nlpcraft.common.ansi
import java.io.PrintWriter
-import org.apache.nlpcraft.common._
-import NCAnsi._
+import org.apache.nlpcraft.common.*
+import NCAnsi.*
import org.apache.commons.lang3.StringUtils
-import org.apache.nlpcraft.common.ansi.NCAnsiProgressBar._
+import org.apache.nlpcraft.common.ansi.NCAnsiProgressBar.*
/**
* Forward-only, bound ANSI-based progress bar.
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/antlr4/NCCompilerUtils.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/antlr4/NCCompilerUtils.scala
new file mode 100644
index 0000000..cf4975c
--- /dev/null
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/antlr4/NCCompilerUtils.scala
@@ -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
+ *
+ * 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.
+ */
+
+package org.apache.nlpcraft.common.antlr4
+
+import org.apache.nlpcraft.common.*
+import org.apache.nlpcraft.common.ansi.NCAnsi.*
+
+case class CompilerErrorHolder(
+ ptrStr: String,
+ origStr: String
+)
+
+object NCCompilerUtils:
+ /**
+ *
+ * @param in
+ * @param charPos
+ * @return
+ */
+ def mkErrorHolder(in: String, charPos: Int): CompilerErrorHolder =
+ val charPos0 = charPos - (in.length - in.stripLeading().length)
+ val in0 = in.strip()
+ val pos = Math.max(0, charPos0)
+ val dash = "-" * in0.length
+ var ptrStr = dash.substring(0, pos) + r("^")
+
+ if pos < dash.length - 1 then
+ ptrStr = ptrStr + y("~") + y(dash.substring(pos + 2))
+ else
+ ptrStr = ptrStr + y(dash.substring(pos + 1))
+
+ val origStr = in0.substring(0, pos) + r(in0.charAt(pos)) +
y(in0.substring(pos + 1))
+
+ CompilerErrorHolder(ptrStr, origStr)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
index daa3313..f9d8385 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
@@ -17,12 +17,12 @@
package org.apache.nlpcraft.common.util
-import com.typesafe.scalalogging.{LazyLogging, Logger}
+import com.typesafe.scalalogging.*
import org.apache.nlpcraft.common.NCException
import org.apache.nlpcraft.common.ansi.NCAnsi.*
-import java.io.{IOException, InputStream, OutputStream}
-import java.net.{ServerSocket, Socket}
+import java.io.*
+import java.net.*
import java.util.Random
import java.util.regex.Pattern
import scala.annotation.tailrec
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/version/NCVersion.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/version/NCVersion.scala
index 9c9470d..5f74f15 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/version/NCVersion.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/version/NCVersion.scala
@@ -17,7 +17,7 @@
package org.apache.nlpcraft.common.version
-import java.time.{LocalDate, Year}
+import java.time.*
import com.typesafe.scalalogging.LazyLogging
import org.apache.nlpcraft.common.*
import org.apache.nlpcraft.common.util.NCUtils