[Top][All Lists]

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

Re: how to use parsing expressing grammar

From: Helmut Eller
Subject: Re: how to use parsing expressing grammar
Date: Sun, 21 Dec 2008 10:49:44 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

* Xah Lee [2008-12-20 22:41+0100] writes:

> I have another question, hopefully this one is not a dumb one.
> In summary, if i have
>    (imgTag "<img" whitespace (+ attributes whitespace) ">")
> how to tell PEG that if a attribute is the last item, then the
> whitespace following it is optional?

Hmm, good question.  Perhaps something like

(imgTag "<img" (+ whitespace attribute) (opt whitespace) ">")

This does a bit of backtracking, but easy to read.

>> So far only 2 people asked questions.  If there are some more we can set
>> up a mailing list.
> I'm pretty sure if you create it, more and more people will join it.
> I'm very interested in PEG and think it is of critical importance. 

I'll try to set up project at savannah.

> If say emacs 24 has it built in as C code, with all its regex
> functions such as search-forward-regexp, query-replace-regexp etc
> having PEG version, it would make emacs a killer app.

I don't think that PEGs are easy to use interactively, like
query-replace-regexp.  Regexps have a more concise notation, which is
crucial when used interactively.

> From Wikipedia, it appears that people have already wrote PEG lib for
> most major langs. There is already a C lib for PEG. The problem with
> them is that most comes with a background of computer lang parsing, as
> opposed to practical use for text processing like regex. (note: regex
> itself came from computer science background as a way to determine
> languages with “regular” grammar, but today it is far
> removed from theoretical parsing. The process of this transmutation
> took i think 10 years, and it took another 10 or so years until it
> become a widely popular tool in langs, starting with Perl in the
> 1990s) I don't forsee that in the next 10 years that practicing
> programers will all know about computer science of parsing or that
> major langs will all have formal grammar spec. I'm pretty certain
> people are already seeing the potential of PEG as regex replacement
> and working towards creatings such practical goal.

I think that the Lua language uses PEGs for text processing and
apparently implements it's regexp library on top of PEGs.


reply via email to

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