I've used your problem for trying [npeg](https://github.com/zevv/npeg) out . I
guess I have too much time :)
Disclaimer: This is my first try using Npeg. Use at your own risk
Here you're:
import npeg, strutils, tables
type Dict = Table[string, string]
let parser = peg("pad", d: Dict):
pad <- ?padstr * sep * x1 * sep * y1 * sep * x2 * sep * y2 * sep *
?radius * sep * ?dx * sep * ?dy * sep * ?n * sep * ?number * sep * ?name
padstr <- >*Alnum:
d["pad"] = $1
sep <- *' ' * ?{',',';'} * *' '
integer <- +Digit
real <- +Digit * '.' * +Digit
numeric <- real | integer
x1 <- >numeric:
d["x1"] = $1
y1 <- >numeric:
d["y1"] = $1
x2 <- >(?'+' * numeric ):
d["x2"] = $1
y2 <- >(?'+' * numeric):
d["y2"] = $1
radius <- >numeric:
d["radius"] = $1
dx <- >numeric:
d["dx"] = $1
dy <- >numeric:
d["dy"] = $1
n <- >numeric:
d["n"] = $1
number <- >*Alnum:
d["number"] = $1
name <- >*Alnum:
d["name"] = $1
var data: Table[string, string]
data["pad"] = "pad"
data["radius"] = "0.0"
data["dx"] = "0.0"
data["dy"] = "0.0"
doAssert parser.match("Pad 100, 100 120.5,140.5 7.5 100 0 8 0 PAD", data).ok
echo data
Run