Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to Write Parser in PHP

How to Write Parser in PHP

Jan Tvrdík

April 12, 2018
Tweet

More Decks by Jan Tvrdík

Other Decks in Programming

Transcript

  1. can be optimized to a single preg_* call by using

    a smart trick David Grudl has taught me
  2. always start by writing a grammar EBNF simple not standardized

    ABNF slightly less friendly than EBNF standardized by IETF PEG the coolest not standardized
  3. JsonValue = JsonBool / JsonNull / JsonNumber / JsonString /

    JsonArray / JsonObject JsonBool = TokenTrue / TokenFalse JsonNull = TokenNull
  4. JsonNumber = TokenNumber JsonString = TokenString JsonArray = TokenSquareBracketOpen JsonArrayItems?

    TokenSquareBracketClose JsonArrayItems = JsonValue (TokenComma JsonValue)* ...