Пример #1
0
        /// New creates and initializes a new instance of Scanner using src as
        /// its source content.
        public static Scanner New(slice <byte> src)
        {
            // even though we accept a src, we read from a io.Reader compatible type
            // (*bytes.Buffer). So in the future we might easily change it to streaming
            // read.
            var b = GoBuffer.NewBuffer(src);
            var s = new Scanner
            {
                _buf = b,
                _src = src,
            };

            // srcPosition always starts with 1
            s._srcPos.Line = 1;
            return(s);
        }