janet-lang / janet-lang.org

Website for janet
https://janet-lang.org
MIT License
90 stars 59 forks source link

lenprefix docs mention a tag, but feature unsupported #227

Closed sogaiu closed 2 months ago

sogaiu commented 2 months ago

The table in this section suggests that lenprefix supports an optional tag argument:

(lenprefix n patt ?tag)

However, the current implementation of lenprefix seems to accept only two arguments, e.g.

(peg/match ~(* (lenprefix (/ (* '(any (if-not ":" 1)) ":")
                             ,scan-number)
                          1
                          :tag)
                -1)
            "3:xyz")

results in:

error: grammar error in (lenprefix (/ (* (quote (any (if-not ":" 1))) ":") <cfunction scan-number>) 1 :tag), expected 2 arguments, got 3
  in peg/match [src/core/peg.c] on line 1795
  in thunk [repl] (tail call) on line 8, column 1

whereas the following works:

(peg/match ~(* (lenprefix (/ (* '(any (if-not ":" 1)) ":")
                             ,scan-number)
                          1)
                -1)
            "3:xyz")
# =>
@[]