|
|
|
@ -39,9 +39,10 @@ func (p *TextParser) InitString(s string) {
|
|
|
|
|
|
|
|
|
|
// Discard shadows [lexer.Reader]'s, and takes in consideration
|
|
|
|
|
// new lines on the discarded data when moving the position
|
|
|
|
|
func (*TextParser) Discard() { |
|
|
|
|
// TODO: consider new lines
|
|
|
|
|
panic("not implemented") |
|
|
|
|
func (p *TextParser) Discard() { |
|
|
|
|
s := p.Reader.Emit() |
|
|
|
|
l := GetPositionalLength(s) |
|
|
|
|
p.pos.Add(l) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Emit returns the accepted text, its position, and
|
|
|
|
@ -49,8 +50,8 @@ func (*TextParser) Discard() {
|
|
|
|
|
func (p *TextParser) Emit() (lexer.Position, string) { |
|
|
|
|
pos := p.pos |
|
|
|
|
s := p.Reader.Emit() |
|
|
|
|
// TODO: consider new lines
|
|
|
|
|
p.pos.StepN(len(s)) |
|
|
|
|
l := GetPositionalLength(s) |
|
|
|
|
p.pos.Add(l) |
|
|
|
|
|
|
|
|
|
return pos, s |
|
|
|
|
} |
|
|
|
|