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