Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
segment matching variables in Qi-YACC (for Snorgers ;))
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
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 will appear after it is approved by moderators
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up 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 that you hear
 
Mark Tarver  
View profile   Translate to Translated (View Original)
 More options 26 June, 10:37
From: Mark Tarver <dr.mtar...@ukonline.co.uk>
Date: Fri, 26 Jun 2009 02:37:13 -0700 (PDT)
Local: Fri 26 June 2009 10:37
Subject: segment matching variables in Qi-YACC (for Snorgers ;))
Here is a sugaring on top of Qi that enables you to have segment
matching variables in Qi-YACC.  <<...>> is a stuff matcher.

(defcc <grab-numbers>
       <<X>> <numbers> <<Y>> := <numbers>;)

(defcc <numbers>
       <number> <numbers>;
       <number>;)

(defcc <number>
        -*- := (if (number? -*-) [-*-] #\Escape);)

(defcc <grab-my-name>
   <<X>> :name <<Y>> := <<Y>>;)

Examples:

(compile <grab-my-name> [ghhghg 7 8 :name Mark Tarver])
[Mark Tarver]

(compile <grab-numbers> [just some numbers 1 2 3/4 tum te tum])
[1 2 3/4]

The code is 85 lines.

Mark


    Reply to author    Forward  
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.
snorgers  
View profile   Translate to Translated (View Original)
 More options 26 June, 20:42
From: snorgers <stefan.ta...@spray.se>
Date: Fri, 26 Jun 2009 12:42:49 -0700 (PDT)
Local: Fri 26 June 2009 20:42
Subject: Re: segment matching variables in Qi-YACC (for Snorgers ;))
Hi Mark,

Cool this looks like a natural building block, but what do you think
about patterns like

(defcc <f>
 <<L>> <numbers> <<L>> := ...)

They is nice to have for situations like
<string-prefix> <<boundary>> <endl> <<String>> <<boundary>> := (COERCE
<<String>> STRING);

/Stefan

On 26 June, 11:37, Mark Tarver <dr.mtar...@ukonline.co.uk> wrote:


    Reply to author    Forward  
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.
Mark Tarver  
View profile   Translate to Translated (View Original)
 More options 26 June, 20:46
From: "Mark Tarver" <dr.mtar...@ukonline.co.uk>
Date: Fri, 26 Jun 2009 20:46:10 +0100
Local: Fri 26 June 2009 20:46
Subject: Re: segment matching variables in Qi-YACC (for Snorgers ;))
As of now, the second <<L>> would bind over the first.  No identity would be
created.  you would have to have

(defcc <f>
 <<L1>> <numbers> <<L2>> := (if (= <<L1>> <<L2>>) ..... #\Escape);)


    Reply to author    Forward  
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.
Mark Tarver  
View profile   Translate to Translated (View Original)
 More options 26 June, 20:52
From: Mark Tarver <dr.mtar...@ukonline.co.uk>
Date: Fri, 26 Jun 2009 12:52:29 -0700 (PDT)
Local: Fri 26 June 2009 20:52
Subject: Re: segment matching variables in Qi-YACC (for Snorgers ;))
Its very compact; I'll say that - here is a text extractor for an HTML
file which

1. Scrapes out the text from an HTML file.
2. Grabs an HTML template and sticks it into the template in a spot
called Text! and
3. Creates a new resulting HTML file .

(define text
  File -> (let Chars (read-file-as-charlist File)
                    Text (FORMAT NIL "~{~C~}" (compile <scrape>
Chars))
                    Template (read-file-as-charlist "template.htm")
                    Html (compile <insert> [Text | Template])
                    (write-to-file "out. Html)))

(defcc <scrape>
    #\< <<X>> #\> <scrape> := <scrape>;
   -*- <scrape>;
   <e> := [];)

(defcc <insert>
  -*- <<X>> #\T #\e #\x #\t #\! <<Y>>
      := (FORMAT NIL "~{~C~} ~A ~{~C~}" <<X>> -*- <<Y>>);)


    Reply to author    Forward  
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.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google