diff --git a/bin/.jq-1.7.pkg b/bin/.jq-1.7.pkg deleted file mode 120000 index 383f4511..00000000 --- a/bin/.jq-1.7.pkg +++ /dev/null @@ -1 +0,0 @@ -hermit \ No newline at end of file diff --git a/bin/jq b/bin/jq deleted file mode 120000 index f3d25875..00000000 --- a/bin/jq +++ /dev/null @@ -1 +0,0 @@ -.jq-1.7.pkg \ No newline at end of file diff --git a/lexer/api.go b/lexer/api.go index 5e732f5c..2784dd87 100644 --- a/lexer/api.go +++ b/lexer/api.go @@ -114,6 +114,20 @@ func (p *Position) Advance(span string) { } } +// Add returns a new Position that is the sum of this position and "pos". +// +// This is useful when parsing values from a parent grammar. +func (p Position) Add(pos Position) Position { + p.Line += pos.Line - 1 + if pos.Line > 1 { + p.Column = pos.Column + } else { + p.Column += pos.Column - 1 + } + p.Offset += pos.Offset + return p +} + func (p Position) GoString() string { return fmt.Sprintf("Position{Filename: %q, Offset: %d, Line: %d, Column: %d}", p.Filename, p.Offset, p.Line, p.Column)