fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

9.8K
active users

#peg

0 posts0 participants0 posts today

🌖 珍妮特 PEG 模組運作原理
➤ 探索 Janet 語言中解析表達式文法的實作細節
bakpakin.com/writing/how-janet
本文深入探討了 Janet 程式語言中 PEG(Parsing Expression Grammars)模組的實作方式。作者受到 REBOL Parse 模組和 LPeg 的啟發,設計了一個基於 PEG 的文本和位元序列解析庫,並解釋了 PEG 相對於正規表達式的優勢,例如可讀性更強、易於捕捉錯誤位置等。文章詳細描述了 PEG 引擎的實作細節,從基本運算子到遞迴語法的支援,並提供範例程式碼演示瞭如何使用 PEG 解析 ISO 8601 日期格式。
+ 這篇文章寫得非常清楚,即使我對 PEG 不太熟悉,也能理解它的核心概念和優點。範例程式碼也很有幫助!
+ 瞭解 Janet 團隊是如何用如此簡潔的程式碼實現 PEG 引擎,真是令人印象深刻!這篇文章讓我對 Janet 這門語言更感興趣了。
#程式設計 #解析器 #PEG

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

🚀 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

"Using neutron reflectometry measurements & #molecular dynamics simulations of poly(ethylene glycol) (PEG) polymers of different molecular weights near charged & neutral membranes, we demonstrate the roles of surface dielectrophoresis & counterion pressure in repelling #PEG from charged #membrane surfaces. The..depletion zone is expected to have consequences for drug design & delivery, the activity of proteins near membrane surfaces, and the transport of small molecules"

pubs.acs.org/doi/full/10.1021/

Left Recursion in Parsing Expression Grammars:

arxiv.org/pdf/1207.0443v1.pdf

"A frequently missed feature of PEGs is left #recursion, which is commonly used in Context-Free Grammars (#CFGs) to encode left-associative operations. We present a simple conservative extension to the semantics of #PEGs that gives useful meaning to direct and indirect left-recursive rules, and show that our extensions make it easy to express left-recursive idioms from CFGs in PEGs, with similar results."

Continued thread

Took my spouse nearly an hour to ask what I was doing… & I wasn’t exactly quiet😂

Me: I read an article so now I’m moving your crème de corps into a glass bottle

I do not like #loreal & they just bought another really great company #aesop & this lotion has #PEG but they do sell it in refillable form, my product usage is bare minimal so & not learning to make lotion

Everything should be refillable & sold in glass containers but what do I know🙄 #climatecatastophe

#scotland #uk #england #peg #johnbull

John Bull, that stout yeoman of distilled Englishness was, it might surprise you to know, created by a Scot called John Arbuthnot. A contemporary and friend of Jonathan Swift, Arbuthnot satirised the inter-union relationship between England and Scotland around the turn of the 18th century, personifying the two countries as siblings John and Peg.

For whatever reasons Peg slowly faded into obscurity, while Bull was embellished and reused by other later authors and cartoonists. The excerpt below, taken from Arbutnot's
THE HISTORY OF JOHN BULL describes the awkward sororal/fraternal relations:

John had a sister, a poor girl that had been starved at nurse. Anybody would have guessed Miss to have been bred up under the influence of a cruel stepdame, and John to be the fondling of a tender mother. John looked ruddy and plump, with a pair of cheeks like a trumpeter; Miss looked pale and wan, as if she had the green sickness; and no wonder, for John was the darling: he had all the good bits, was crammed with good pullet, chicken, pig, goose, and capon; while Miss had only a little oatmeal and water, or a dry crust without butter. John had his golden pippins, peaches, and nectarines; poor Miss, a crab-apple, sloe, or a blackberry. Master lay in the best apartment, with his bedchamber towards the south sun. Miss lodged in a garret exposed to the north wind, which shrivelled her countenance. However, this usage, though it stunted the girl in her growth, gave her a hardy constitution; she had life and spirit in abundance, and knew when she was ill-used. Now and then she would seize upon John's commons, snatch a leg of a pullet, or a bit of good beef, for which they were sure to go to fisticuffs. Master was indeed too strong for her, but Miss would not yield in the least point; but even when Master had got her down, she would scratch and bite like a tiger; when he gave her a cuff on the ear, she would prick him with her knitting-needle. John brought a great chain one day to tie her to the bedpost, for which affront Miss aimed a penknife at his heart
www.gutenberg.org The History of John Bull, by John Arbuthnot, M.D.