From mboxrd@z Thu Jan 1 00:00:00 1970
Path: news.gmane.org!not-for-mail
From: Xah Lee
Newsgroups: gmane.emacs.help
Subject: Re: how to use parsing expressing grammar
Date: Sat, 20 Dec 2008 00:42:18 -0800 (PST)
Organization: http://groups.google.com
Message-ID: <098ddc5b-7074-41fb-a921-caee3bddddff@t39g2000prh.googlegroups.com>
References: <6b8a1070-1a89-48b0-9287-343b673b5758@a29g2000pra.googlegroups.com>
NNTP-Posting-Host: lo.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1229770676 21111 80.91.229.12 (20 Dec 2008 10:57:56 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 20 Dec 2008 10:57:56 +0000 (UTC)
To: help-gnu-emacs@gnu.org
Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Dec 20 11:59:03 2008
Return-path:
Envelope-to: geh-help-gnu-emacs@m.gmane.org
Original-Received: from lists.gnu.org ([199.232.76.165])
by lo.gmane.org with esmtp (Exim 4.50)
id 1LDzXx-0006Su-9O
for geh-help-gnu-emacs@m.gmane.org; Sat, 20 Dec 2008 11:59:01 +0100
Original-Received: from localhost ([127.0.0.1]:50150 helo=lists.gnu.org)
by lists.gnu.org with esmtp (Exim 4.43)
id 1LDzWk-0002b9-UQ
for geh-help-gnu-emacs@m.gmane.org; Sat, 20 Dec 2008 05:57:47 -0500
Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!t39g2000prh.googlegroups.com!not-for-mail
Original-Newsgroups: gnu.emacs.help,comp.emacs
Original-Lines: 118
Original-NNTP-Posting-Host: 76.102.50.240
Original-X-Trace: posting.google.com 1229762539 1651 127.0.0.1 (20 Dec 2008 08:42:19
GMT)
Original-X-Complaints-To: groups-abuse@google.com
Original-NNTP-Posting-Date: Sat, 20 Dec 2008 08:42:19 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: t39g2000prh.googlegroups.com; posting-host=76.102.50.240;
posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en)
AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1,
gzip(gfe), gzip(gfe)
Original-Xref: news.stanford.edu gnu.emacs.help:165537 comp.emacs:97503
X-Mailman-Approved-At: Sat, 20 Dec 2008 05:56:14 -0500
X-BeenThere: help-gnu-emacs@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Users list for the GNU Emacs text editor
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org
Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org
Xref: news.gmane.org gmane.emacs.help:60868
Archived-At:
more questions on parsing expression grammar.
let's say i want to change tags of the form
=E2=80=9C=E2=80=9D
into
=E2=80=9C=E2=80=9D
I tried the following:
(defun doMyReplace ()
(interactive)
(peg-parse
(start imgTag)
(imgTag "")
(whitespace [" "])
(filePath [a-z "."])
)
)
then placed my cursor at the beginning of the tag, then call
doMyReplace. It doesn't seems to work, except moving cursor to after
the =E2=80=9Ca=E2=80=9D.
I spent about 20 min but couldn't see what's wrong with my code?
----------------
in general, i wanted to use PEG to do transformation from html 4
transitional to html 4 strict. I have maybe 3 hundred files to do
this. One of the primary change from html 4 trans to html 4 strict is
that any image tag now needs to be wrapped with =E2=80=9Cdiv=E2=80=9D.
So basically,
needs to become
The first job i tried to do to as a simplification, is to try to write
a img tag matcher to test with. here's my code:
(defun doMyReplace ()
(interactive)
(peg-parse
(imgTag "")
(whitespace ["\n "])
(digits [0-9])
(filePath [A-Z a-z "./_"])
(altStr [A-Z a-z "./ '"])
)
)
but then couldn't get it to work.
Any help appreciated.
Btw, would you be interested in starting a mailing list on PEG in
emacs? e.g. yasnippet has one thru google, nxml has one in yahoo
group, ljupdate has one in livejournal. I think it'd be helpful.
Xah
=E2=88=91 http://xahlee.org/
=E2=98=84
On Dec 19, 3:27=C2=A0pm, Xah Lee wrote:
> On Dec 17, 10:22=C2=A0am, Helmut Eller wrote:
>
>
>
> > * Helmut Eller [2008-12-17 16:21+0100] writes:
>
> > > Recording positions in this manner is obviously tedious and it just
> > > shows that the package hasn't received much battle testing. =C2=A0As =
a little
> > > improvement we could define a custom "region" operator which acts
> > > similarly as the *list operator, but instead of collecting a list we
> > > push the start and end positions. =C2=A0E.g.:
>
> > I released a new version of peg.el and added a replace operator.
> > We can now match and replace without helper function:
>
> > (defun parse3 ()
> > =C2=A0 (peg-parse
> > =C2=A0 =C2=A0(start _ "
" _ title _ ul)
> > =C2=A0 =C2=A0(title "" (replace (* (not "
") (any)) "See also:") =
"
")
> > =C2=A0 =C2=A0(ul (replace ""=
""))
> > =C2=A0 =C2=A0(li (replace "" "") (* (not "") (any)) (replace "=
" "
"))
> > =C2=A0 =C2=A0(_ (* (or whitespace comment)))
> > =C2=A0 =C2=A0(whitespace ["\n\t "])
> > =C2=A0 =C2=A0(comment "<-- " (* (not "-->") (any)) "-->")))
>
> > Helmut.
>
> Holy cow. This worked! LOL!
>
> Thanks!
>
> =C2=A0 Xah
> =E2=88=91http://xahlee.org/
>
> =E2=98=84