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

commit 8e65fe76e9939659f7cab47c84e9d4112f3a0fbe
Merge: 61e6d16 91a2fbe
Author: Aaron Radzinski <[email protected]>
AuthorDate: Mon Jan 31 17:04:22 2022 -0800

    Merge branch 'master' of https://github.com/apache/incubator-nlpcraft

 .../nlpcraft/internal/antlr4/NCCompilerUtils.scala |  20 +-
 .../nlpcraft/internal/impl/NCModelScanner.scala    | 482 +++++++++------------
 .../internal/impl/scan/NCIntentImportSpec.scala    |  30 --
 .../impl/scan/NCModelIntentsInvalidArgsSpec.scala  |   6 +-
 .../scan/NCModelIntentsInvalidIntentsSpec.scala    | 124 ++++++
 .../impl/scan/NCModelIntentsNestedSpec.scala       |   8 +-
 .../internal/impl/scan/NCModelIntentsSpec.scala    |   2 +-
 .../intent/compiler/NCIDLCompilerSpec.scala        |  16 +
 8 files changed, 370 insertions(+), 318 deletions(-)

diff --cc 
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/antlr4/NCCompilerUtils.scala
index f4963be,e301c2a..bb13bd0
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/antlr4/NCCompilerUtils.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/antlr4/NCCompilerUtils.scala
@@@ -32,16 -32,17 +32,16 @@@ object NCCompilerUtils
        * @return
        */
      def mkErrorHolder(in: String, charPos: Int): CompilerErrorHolder =
-         require(charPos >= 0)
- 
-         val charPos0 = charPos - (in.length - in.stripLeading().length)
          val in0 = in.strip()
-         val pos = Math.max(0, charPos0)
-         val dash = "-" * in0.length
 -
+         if in0.isEmpty || charPos < 0 then CompilerErrorHolder("<empty>", 
"<empty>")
+         else
+             val charPos0 = charPos - (in.length - in.stripLeading().length)
+             val pos = Math.max(0, charPos0)
+             val dash = "-" * in0.length
  
-         var ptrStr = s"${dash.substring(0, pos)}^"
-         if pos < dash.length - 1 then ptrStr = s"$ptrStr${dash.substring(pos 
+ 1)}"
-         else ptrStr = s"$ptrStr${dash.substring(pos + 1)}"
+             var ptrStr = s"${dash.substring(0, pos)}^"
+             if pos < dash.length - 1 then ptrStr = 
s"$ptrStr${dash.substring(pos + 1)}"
+             else ptrStr = s"$ptrStr${dash.substring(pos + 1)}"
  
-         val origStr = s"${in0.substring(0, 
pos)}${in0.charAt(pos)}${in0.substring(pos + 1)}"
-         CompilerErrorHolder(ptrStr, origStr)
+             val origStr = s"${in0.substring(0, 
pos)}${in0.charAt(pos)}${in0.substring(pos + 1)}"
+             CompilerErrorHolder(ptrStr, origStr)

Reply via email to