Hey!
I'm confused on writing a "command line argument" parser with honeycomb
.
here's my code:
import honeycomb, print
const text = "make global -orient RXY -name vff"
let parser = (
(many(letter) << whitespace) &
many((many(c('-') | alphanumeric) << whitespace) & (many(letter) << optional(whitespace))) <<
eof
)
print parser.parse text
I was trying to parse a command line input like make global -orient RXY -name vff
and expected to get something like this:
["make", "global" , "-orient", "RXY", "-name", "vff"] # or
["make", "global" , @["-orient", "RXY"], @["-name", "vff"]]
but I get:
ParseResult[seq[seq[char]]](
kind: "success",
value: @[
@['m', 'a', 'k', 'e'],
@['g', 'l', 'o', 'b', 'a', 'l'],
@['-', 'o', 'r', 'i', 'e', 'n', 't', 'R', 'X', 'Y'],
@['-', 'n', 'a', 'm', 'e', 'v', 'f', 'f']
],
tail: "",
fromInput: "make global -orient RXY -name vff"
)
I tried to read the tests, but it lacks more advanced examples like this.