Afaik, stdlib peg is designed for nim compiler itself and somewhat limited. So, 
you may consider using [npeg :](https://github.com/zevv/npeg)
    
    
    import npeg
    
    let parser = peg("example"):
      example <- >?word * >?number
      word <- +Alpha
      number <- +Digit
    
    echo parser.match("abc").captures # @["abc", ""]
    echo parser.match("123").captures # @["", "123"]
    
    
    Run

Reply via email to