instaparse

If you're not trampolining your parser, why bother getting up in the morning?
fabrao 2018-05-30T04:06:47.000021Z

Hello all, I´m doing parser for fixed width with instaparse and the code is

(->>
   ((insta/parser
     "VALOR = CODIGO BARRAS
CODIGO = 2DIGIT
BARRAS = 3DIGIT
" :input-format :abnf) "12334")
   (insta/transform {:DIGIT (comp str)}))
How do I concat the "DIGITs" and keep CODIGO and BARRAS?

aengelberg 2018-05-30T06:21:22.000018Z

@fabrao try adding transform entries for :CODIGO (partial apply str) :BARRAS (partial apply str)

fabrao 2018-05-30T12:29:42.000132Z

@aengelberg it did not work, this keep showing [:VALOR [:DIGIT "1"]:DIGIT2 [:DIGIT "3"][:DIGIT "3"]:DIGIT4]

fabrao 2018-05-30T12:31:13.000203Z

I had to change to

((insta/parser
     "VALOR = CODIGO BARRAS
CODIGO = #'.{3}'
BARRAS = #'.{2}'
") "12334")