From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: Re: Trouble with the PEG parser Date: Sun, 30 Dec 2018 22:41:28 +0100 Message-ID: <871s5yheuv.fsf@elephly.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:39839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gdiqN-0005dL-72 for guix-devel@gnu.org; Sun, 30 Dec 2018 16:41:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gdiqI-0003Uc-8A for guix-devel@gnu.org; Sun, 30 Dec 2018 16:41:59 -0500 Received: from sender-of-o53.zoho.com ([135.84.80.218]:21730) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gdiqH-00039i-SM for guix-devel@gnu.org; Sun, 30 Dec 2018 16:41:54 -0500 In-reply-to: List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: swedebugia Cc: guix-devel Hi swedebugia, It=E2=80=99s not clear to me what kind of output you=E2=80=99re expecting. = Let=E2=80=99s take this example: (define-peg-string-patterns "comment <- entry* !. entry <-- (! NL .)* NL* NL < '\n'") This works fine, but not on your =E2=80=9C*test*=E2=80=9D string, which con= tains the character =E2=80=9C\(=E2=80=9D. Note that you are in a Guile string here, = so e.g. =E2=80=9C\n=E2=80=9D represents the actual newline character, not a two-character string. Your attempt to escape an opening parenthesis led to the character =E2=80= =9C\(=E2=80=9D. This is what the string should look like: (define *test* ";; test ;;test2 ; test3 ;test4 (define %tor-accounts ;; User account and groups for Tor.") Here=E2=80=99s what I see: scheme@(guile-user)> (peg:tree (match-pattern comment *test*)) $18 =3D ((entry ";; test") (entry ";;test2") (entry "; test3") (entry ";tes= t4") (entry "(define %tor-accounts") (entry " ;; User account and groups f= or Tor.")) Is this what you expect? It certainly is not the #F that you=E2=80=99re se= eing. FWIW, I suggest using s-expression patterns instead of string patterns. -- Ricardo