package parser import ( "io" "asciigoat.org/core/lexer" ) type positionLengthParser struct { TextParser lexer.Position } func (p *positionLengthParser) lexStart() (lexer.StateFn, error) { for { switch { case p.AcceptNewLine(): p.Position.StepLine() case p.Accept(IsAny): p.Position.StepN(1) default: return nil, io.EOF } } } // GetPositionalLength calculates the [lexer.Position] at // the end of a text. func GetPositionalLength(s string) lexer.Position { var p positionLengthParser if s == "" { p.InitString(s) _ = lexer.Run(p.lexStart) } return p.Position }