Exemplo n.º 1
0
        // =================== End Nested classes =======================

        public Scanner(Stream file)
        {
            buffer    = TextBuff.NewTextBuff(file); // selected by /unicode option
            this.cNum = -1;
            this.chr  = '\n';                       // to initialize yyline, yycol and lineStart
            GetChr();
        }
Exemplo n.º 2
0
        public static int getPrevWordBreakForCache(TextBuff buff, int offset)
        {
            int len = buff.size;

            if (offset == 0)
            {
                return(0);
            }

            if (offset > len)
            {
                offset = len;
            }
            if (isWordBreakBefore(buff.charAt(offset - 1)))
            {
                return(offset - 1);
            }
            for (int i = offset - 1; i > 0; i--)
            {
                if (isWordBreakBefore(buff.charAt(i)) || isWordBreakAfter(buff.charAt(i - 1)))
                {
                    return(i);
                }
            }
            return(0);
        }
Exemplo n.º 3
0
 public void setText(TextBuff text)
 {
     this._text         = text;
     this._last         = 0;
     this._current      = 0;
     this._scanOffset   = 0;
     this._inEmailOrUrl = false;
     // this.nextUntilCodePoint();
 }
Exemplo n.º 4
0
        static uint preCode(TextBuff text, ref int index, int start)
        {
            --index;
            uint ch = text.charAt(index);

            if (isTrailSurrogate(ch))
            {
                if (index > start && isLeadSurrogate(text.charAt(index - 1)))
                {
                    ch = getSupplementary(text.charAt(index - 1), ch);
                    --index;
                }
            }

            return(ch);
        }
Exemplo n.º 5
0
        static uint nextCode(TextBuff text, ref int index, int end)
        {
            uint ch = text.charAt(index);

            index++;
            if (isLeadSurrogate(ch))
            {
                if (index < end && isTrailSurrogate(text.charAt(index)))
                {
                    char ch2 = text.charAt(index);
                    index++;
                    ch = getSupplementary(ch, ch2);
                }
            }

            return(ch);
        }
Exemplo n.º 6
0
        public static int getNextWordBreakForCache(TextBuff buff, int offset)
        {
            int len = buff.size;

            if (offset >= len)
            {
                return(len);
            }

            if (isWordBreakAfter(buff.charAt(offset)))
            {
                return(offset + 1);
            }

            for (int i = offset + 1; i < len; i++)
            {
                if (isWordBreakBefore(buff.charAt(i)))
                {
                    return(i);
                }
            }

            return(len);
        }
Exemplo n.º 7
0
 public void finish()
 {
     this._text = default;
 }
Exemplo n.º 8
0
 public void finish()
 {
     this._text = null;
 }