[Top][All Lists]

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

Re: Trouble with the PEG parser

From: Ricardo Wurmus
Subject: Re: Trouble with the PEG parser
Date: Sun, 30 Dec 2018 22:41:28 +0100
User-agent: mu4e 1.0; emacs 26.1

Hi swedebugia,

It’s not clear to me what kind of output you’re expecting.  Let’s take
this example:

  "comment <- entry* !.
entry <-- (! NL .)* NL*
NL < '\n'")

This works fine, but not on your “*test*” string, which contains the
character “\(”.  Note that you are in a Guile string here, so e.g. “\n”
represents the actual newline character, not a two-character string.
Your attempt to escape an opening parenthesis led to the character “\(”.

This is what the string should look like:

(define *test*
  ";; test
; test3
(define %tor-accounts
  ;; User account and groups for Tor.")

Here’s what I see:

scheme@(guile-user)> (peg:tree
                      (match-pattern comment *test*))
$18 = ((entry ";; test") (entry ";;test2") (entry "; test3") (entry ";test4") 
(entry "(define %tor-accounts") (entry "  ;; User account and groups for Tor."))

Is this what you expect?  It certainly is not the #F that you’re seeing.

FWIW, I suggest using s-expression patterns instead of string patterns.


reply via email to

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