parser: use GetPositionalLength() on TextParser.Discard() and TextParser.Emit()
Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
+6
-5
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user