override def exitSyn()

in nlpcraft/src/main/scala/org/apache/nlpcraft/internal/makro/NCMacroCompiler.scala [151:211]


        override def exitSyn(ctx: NCMacroDslParser.SynContext): Unit =
            val syn = (
                if ctx.TXT() != null then ctx.TXT()
                else if ctx.REGEX_TXT() != null then ctx.REGEX_TXT()
                else ctx.IDL_TXT()
            ).getText

            val buf = stack.top.buffer
            require(buf.nonEmpty)
            for (i <- buf.indices) buf.update(i, concat(buf(i), syn))

        override def exitList(ctx: NCMacroDslParser.ListContext): Unit = if ctx.UNDERSCORE() != null then stack.top.buffer += ""
        override def exitMakro(ctx: NCMacroDslParser.MakroContext): Unit = expandedSyns = stack.pop().buffer.map(_.trim).toSet

        /**
          *
          */
        def getExpandedMacro: Set[String] =
            require(expandedSyns != null)
            expandedSyns

    /**
      * Custom error handler.
      */
    class CompilerErrorListener(in: String) extends BaseErrorListener:
        /**
          *
          * @param recognizer
          * @param offendingSymbol
          * @param line
          * @param charPos
          * @param msg
          * @param e
          */
        override def syntaxError(
            recognizer: Recognizer[_, _],
            offendingSymbol: scala.Any,
            line: Int, // 1, 2, ...
            charPos: Int, // 1, 2, ...
            msg: String,
            e: RecognitionException): Unit = E(mkCompilerError(msg, line, charPos - 1, in))

    /**
      *
      * @param line
      * @param charPos
      * @param in
      * @param msg
      */
    private def mkCompilerError(
        msg: String,
        line: Int, // 1, 2, ...
        charPos: Int, // 0, 1, 2, ...
        in: String
    ): String =
        val hldr = NCCompilerUtils.mkErrorHolder(in, charPos)
        val aMsg = NCUtils.decapitalize(msg) match
            case s: String if s.last == '.' => s
            case s: String => s"$s."
        s"""Macro compiler error at line $line - $aMsg
            |-- ${"Macro:"} ${hldr.origStr}