mas.to is one of the many independent Mastodon servers you can use to participate in the fediverse.
Hello! mas.to is a fast, up-to-date and fun Mastodon server.

Administered by:

Server stats:

12K
active users

#peg

2 posts2 participants0 posts today

🚀 Behold the epic tale of Janet's #PEG #module, where the author heroically excludes regular expressions like they're yesterday's news. 💥 Marvel at the labyrinth of #parsing magic that claims to be more readable, but only if you have a PhD in arcane text processing. 📜✨
bakpakin.com/writing/how-janet #Janet #readability #textprocessing #regex #HackerNews #ngated

bakpakin.comHow Janet's PEG module worksAn in depth explanation of pegs and how they work.

Практика использования парсер-комбинаторов peco и оператора match для создания простых DSL на языке Python

Задачи разработки компиляторов и интерпретаторов конфигурационных языков или даже полноценных Тьюринг-полных языков программирования время от времени встают перед разработчиками программного обеспечения. На практике, как правило, речь идёт о разработке предметно-ориентированных языков (англ. Domain Specific Language, DSL), проектируемых специально для решения узкого класса прикладных задач. В настоящей статье рассматривается один из способов реализации DSL-компиляторов на примере разработки системы символьного дифференцирования, с использованием парсер-комбинаторов peco и структурного сопоставления с образцом по PEP 636 . Материал рассчитан на прикладных разработчиков, уже знакомых с Python, но, надеюсь, может быть полезен и продолжающим компиляторщикам.

habr.com/ru/articles/866646/

ХабрПрактика использования парсер-комбинаторов peco и оператора match для создания простых DSL на языке Pythonpeco -грамматика и правила переписывания AST по PEP 636 системы символьного дифференцирования Задачи разработки компиляторов и интерпретаторов конфигурационных языков или даже полноценных...
Continued thread

Side questing into PEGs and #EBNF grammars (that I only barely understand) to parse #CSS.

pypi.org/project/pyparsing/ looks useful, but I found this rudimentary CSS #PEG (gist.github.com/erikrose/56241) which can be used by pypi.org/project/parsimonious/ and it… appears to work?

I was already re-writing the current CSS processing (remove the recusion, add in dataclasses to encapsulate domains, etc), but maybe using a more formal grammar would be a good idea. #python

PyPIpyparsingpyparsing module - Classes and methods to define and execute parsing grammars

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.

Askar Safin · This is why you should never use parser combinators and PEGLet me tell you why you should (nearly) never use PEG (parsing expression grammars). Nearly everything I will say applies to parser combi...
#haskell#rust#parsing
Continued thread

#Peg

"I like what you say about the old myth of Theseus and Ariande. Theseus says to Ariande, "I'll love you forever if you can show me a way to come out of the labyrinth." So she gives him a ball of string, which he unwinds as he goes into the labyrinth, and then follows to find the way out. You say, "All he had was the string. That's all you need." - #SkywalkerRanch California, 1986