3 ms·
Hey that's cool. Are you willing to instead share an example snippet of what the DSL itself looks like?
by 2pEXgD0fZ5cF 2y ago
Hey that's cool.
Are you willing to instead share an example snippet of what the DSL itself looks like?
- afranchuk 2y agoHere's an excerpt (which is in a map passed to peg/compile) for numeric parsing: :nonzero-int (* (range "19") (any (range "09"))) :int (+ "0" :nonzero-int) :decimal (cmt (* (? (<- :int)) "." (<- (some (range "09")))) ,parse-decimal) :fraction (cmt (\* (? (\* (number :nonzero-int) :s+)) (number :nonzero-int) "/" (number :nonzero-int)) ,parse-fraction) :integer (cmt (number :nonzero-int) ,parse-integer) :num (+ :decimal :fraction :integer)