1. 19
  1.  

  2. 2

    the PEG seems maybe a little overkill, but it’s still a cool demonstration of what you can do in a few lines of code. I’ve never considered writing a parser for a small task like this but now I sort of want to because it looks so powerful and simple

    1. 1

      The built-in PEG parser is neat, but for such simple parsing tasks, a regular expression seems to be easier to write to me.

      I’m also wondering: Why is (import sh) necessary? Isn’t it implied that you want the shell functions by running janetsh?

      1. 1

        The built-in PEG parser is neat, but for such simple parsing tasks, a regular expression seems to be easier to write to me.

        When the parsing task get’s more complicated I think the PEG module will scale better. This post is just an educational demonstration intended to be understandable.

        I’m also wondering: Why is (import sh) necessary? Isn’t it implied that you want the shell functions by running janetsh?

        I agree, I may fix this in the future. It is just an implementation detail/limitation currently.

        1. 1

          When the parsing task get’s more complicated I think the PEG module will scale better. This post is just an educational demonstration intended to be understandable.

          Yeah, alright. I was mostly writing that because Janet doesn’t appear to support regex (yet?) and I’m wondering whether that’s an intentional omission to make people use PEG.

          1. 1

            We were discussing adding regex via a non core but possibly official library.

            Actually in janetsh you could also pipe the output of ls-remote to grep too.