emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Make peg.el a built-in library?


From: tomas
Subject: Re: Make peg.el a built-in library?
Date: Thu, 10 Nov 2022 06:25:55 +0100

On Wed, Nov 09, 2022 at 11:04:48PM -0500, Richard Stallman wrote:
> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> 
> Would someone like to tell me in 10 lines what job peg.el does?

PEG (Parsing Expression Grammars [1]) is a grammar notation which can
be automatically translated into a parser (think regular expressions).

The notation is actually similar to that of regexps. The main difference
is that the "alternative" operator is an "ordered" choice instead of an
ambiguous choice. To compensate for this, the notation provides for a
(potential) lookahead mechanism, which, in the naive implementation would
lead to exponential running time in the worst case. The canonical
implementation (nicknamed "packrat") addresses that by memoizing.

Basically they can do what a recursive descent parser can, are thus
slightly more powerful than regexps. They lead to nice little grammars,
but they do take some practice to be useful.

Cheers
-- 
t

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]