From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.help Subject: Re: how to use parsing expressing grammar Date: Sat, 20 Dec 2008 10:34:45 +0100 Message-ID: References: <6b8a1070-1a89-48b0-9287-343b673b5758@a29g2000pra.googlegroups.com> <098ddc5b-7074-41fb-a921-caee3bddddff@t39g2000prh.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1229770730 21238 80.91.229.12 (20 Dec 2008 10:58:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 20 Dec 2008 10:58:50 +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:57 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 1LDzYp-0006di-B3 for geh-help-gnu-emacs@m.gmane.org; Sat, 20 Dec 2008 11:59:56 +0100 Original-Received: from localhost ([127.0.0.1]:50641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LDzXc-0002wm-52 for geh-help-gnu-emacs@m.gmane.org; Sat, 20 Dec 2008 05:58:40 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.kpnqwest.it!news.kpnqwest.it.POSTED!not-for-mail Original-NNTP-Posting-Date: Sat, 20 Dec 2008 03:35:18 -0600 Original-Newsgroups: gnu.emacs.help,comp.emacs User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:FWbeZCXJ1tWKOOJZK+0ToAoVux8= Original-Lines: 59 X-Usenet-Provider: http://www.giganews.com Original-NNTP-Posting-Host: 195.254.226.103 Original-X-Trace: sv3-V9L+1YrikvZoRcRbLsKEhXUCcKzN5L68VT1YOCLdj313SFhegckq7BqUO1Zkpo4LdNn6WfXkvfEgodm!K2fHOHx9UBSxhQ3+Ex+l7+FKsixu9RdbcX2u2hRsA97yHgYewE02ZTFv+ie5eS40 X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.39 Original-Xref: news.stanford.edu gnu.emacs.help:165538 comp.emacs:97504 X-Mailman-Approved-At: Sat, 20 Dec 2008 05:55:22 -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:60869 Archived-At: * Xah Lee [2008-12-20 09:42+0100] writes: > 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 ¡°a¡±. The filePath rule only matches the first character. You probably want to write (+ [a-z "."]). Same issue for whitespace. > 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 " "src=" "\"" filePath "\"" whitespace > "alt=" "\"" (replace altStr "¡ï") "\"" whitespace > "height=" "\"" digits "\"" whitespace > "width=" "\"" digits "\"" > ">") > (whitespace ["\n "]) > (digits [0-9]) > (filePath [A-Z a-z "./_"]) > (altStr [A-Z a-z "./ '"]) > ) > ) Same problem here. If the basics work you can try to generalize this a bit. E.g. (imgTag "") (attribute (or src height width alt)) (src "src" whitespace "=" whitespace "\"" filePath \"\"") etc. > 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. So far only 2 people asked questions. If there are some more we can set up a mailing list. Helmut.