guile-devel
[Top][All Lists]
Advanced

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

Re: PEG Parser


From: Noah Lavine
Subject: Re: PEG Parser
Date: Wed, 26 Jan 2011 21:38:22 -0500

Hello,

> I'm the guy that originally wrote this for GSOC, so I figured I'd jump
> in.  I'd be happy to help with getting the PEG module merge-ready.

Great!

> keyword-flatten is described in api-peg.texi.  It's basically a
> special case of context-flatten which collapses S-expressions
> according to the symbol they start with.  From the documentation:
> @deffn {Scheme Procedure} keyword-flatten terms lst
> A less general form of @code{context-flatten}. Takes a list of
> terminal atoms @code{terms} and flattens @var{lst} until all elements
> are either atoms, or lists which have an atom from @code{terms} as
> their first element.
> @lisp
> (keyword-flatten '(a b) '(c a b (a c) (b c) (c (b a) (c a)))) @result{}
> (c a b (a c) (b c) c (b a) c a)
> @end lisp

Okay. I was confused about the behavior of keyword-flatten when the
car of its argument is not in its list of keywords. I expected that to
change, but it didn't. Looking at it now, is it true that the car of
the argument never changes? So keyword-flatten flattens the sublists,
but has to leave the overall one alone?

> peg-string-compile is a function that will compile PEGs expressed as
> strings into lambda expressions.  It does this by first parsing the
> string using the PEG-parsing-PEG, then turning the output into an
> S-expression representation of a PEG, compressing it, and passing the
> compressed S-expression to peg-sexp-compile.  It's used if you e.g.
> call peg-match with a string instead of an S-expression as the first
> argument.

I tried running peg-string-compile and then passing the result to
eval, but I got an error because there was no symbol 'Begin. (capital
B intended) Do you know what's going on with that? It might be
something weird involving memoized symbols. Also, just to make sure I
get it - this function produces Scheme code, right? (As opposed to
Tree-IL or any of Guile's other languages.)

Noah



reply via email to

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