Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Is there a trick so macrolet can't refer to itself?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
howard yeh  
View profile  
 More options Aug 19 2006, 8:04 pm
Newsgroups: comp.lang.lisp
From: "howard yeh" <hay...@gmail.com>
Date: 19 Aug 2006 17:04:49 -0700
Local: Sat, Aug 19 2006 8:04 pm
Subject: Re: Is there a trick so macrolet can't refer to itself?

> Though the expansion needn't be all *that* bad -- maybe something
> similar to the s-expr form of CL-PPCRE, but perhaps with shorter
> markers:

>     $foo       ==> (* foo)       ; Kleene star (zero or more)
>     [foo bar]  ==> (& foo bar)   ; Sequence [a.k.a. PROGN]
>     {foo bar}  ==> (/ foo bar)   ; Alternative or union ["pick 1"]
>     @(digit d) ==> (? (digit d)) ; Satisfies-p [a.k.a. TYPEP]
>     !(s-expr)  ==> (! (s-expr))  ; Emit normal Lisp code

That's what Peter Siebel's interpretation of META is doing. I find
it a more readable specification than Bakers'.

> What especially interesting to *me*, at least, is that these sorts
> of "lexers" can easily be intermingled with larger, "syntax parser"
> elements using top-down/recursive-descent to form full parsers and
> code generators. See section "C. CONTEXT-FREE GRAMMARS" in Baker's
> paper for a taste of how that works.

Siebel's META uses "^" as the return operator to get an annotated
tree parser.

(^ (* "b") #'(lambda (match) (apply #'strcat match)))

Matches ("b" "b" "b"), and returns "bbb".

Over the course of 50 years, why has regexp for sexp never
surfaced (or rather, caught on)? It's certainly easy to write
recursive parser for sexp  but it still takes work to define DSLs.
And the parser obsfucates the grammar enough, that a separate
description is necessary. There are list pattern matchers. But even
those with their limited powers are not used very often.

(defun parse-lambda-list (lst)
  (match-sexp
   ;; "^" does capturing.
   ;; :exp is the entrance grammar... like main()
   (:exp ((? &whole (^ :symbol))
          (^ (* :symbol))
          (? &optional (^ (* :binding)))
          (? &key (^ (* :binding)))
          (^ (? &allow-other-keys)))
    ;; "/" is for the alternate grammar
    :binding (/ :symbol (:symbol :symbol) (:symbol :symbol :symbol)))
   lst
   (let ((whole $1)
         (required $2)
         (optional $3)
         (key $4)
         (other-keys? $5))
     ...)))

I am modifying Siebel's META for this purpose. But I am not very good
at it... things like left factoring are still beyond me.

I've heard some legendary lisps of the bygone era had something
called... fsexp?? That can do context-sensitive grammar?? What's the
scoop?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.