home.social

#parse — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #parse, aggregated by home.social.

  1. I'm trying to #parse a string into an int in an #esphome lambda. I can use std::stoi() and it works, but I'm struggling at error management. It raises an #exception if the string is not parseable (i.e. "text" instead of "2"), but ESPHome disables the exceptions, so I can't simply try-catch it...
    ATM the code is mostly working, but if the string isn't a valid int, the entire device crashes D:
    How am I supposed to implement this?
  2. Context free grammars (CFG) are better than parsing expression grammars (PEG), because CFGs represent how we think.

    Parser combinators are similar to PEGs, so they are worse than CFGs, too.

    So, don't use Rust libraries nom, combine. Use lalrpop.

    Don't use Haskell libraries parsec, gigaparsec, attoparsec, megaparsec, trifecta. Use Earley, happy.

    See more detailed story in my new article safinaskar.writeas.com/this-is .

    The story also includes some cases, where PEG and parser combinators may still be useful. Also, the article gives links to my Haskell parsing libraries.

    #haskell #rust #parsing #parse #cfg #peg #combinators #parsercombinators #parsingcombinators #nom #combine #lalrpop #parsec #earley #happy

  3. Epsilon is sometimes represented in (Plain Old ) as the Greek letter
    itselff, the letter 'E' or 'e' or sometimes as '...' Different
    BNF authors write it according to their own internal rules, apparently.
    The fact of the symbol in BNF shows the rather tight coupling between a
    notation and the underlying finite state machine tech used to actually
    the strings in the . Really, it is just multiple states returned from the delta function.