Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Need more eyes on two small Qi-YACC parsers
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
  9 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
 
Daniel Jomphe  
View profile   Translate to Translated (View Original)
 More options 8 Sep, 20:16
From: Daniel Jomphe <danieljom...@gmail.com>
Date: Tue, 8 Sep 2009 12:16:49 -0700 (PDT)
Local: Tues 8 Sep 2009 20:16
Subject: Need more eyes on two small Qi-YACC parsers
=== 1 ===
What's wrong with my parser?

  (defcc <rule>
        <sn> <sym>;)

  (defcc <sym>
        symbol;)

  (defcc <sn>
        -*- := (if (number? -*-)
                   [-*-]
                   (error "~A is not a number" -*-)))

  (compile <rule> [[1] symbol])
  error: [1] is not a number

Isn't -*- supposed to be the head of [1], thus 1? And, consequently:

  (compile <rule> [1 symbol])
  [1 symbol]

Why does the head of 1 = 1? I would have expected to have an error
message telling me 1 is not a list.

In other words, what I really want is this to parse as valid:

    (compile <rule> [[1] symbol])

=== 2 ===
I want something like this to be parsed:

  (defcc <foo>
        ::=;)
  (compile <foo> [::=])
  fail!

I think this clashes with Qi-YACC's semantic action's reserved symbol
( := ). Therefore, I've tried different strategies but haven't been
successful in accepting ::= as valid syntax. For example, I can accept
the following as valid if I rework a bit my parser:

 (defcc <foo>
        #\: #\: #\=;)
  (compile <foo> [#\: #\: #\=])
  [#\: #\: #\=]

but I can't use this parser to parse what I really want:

  (compile <foo> [::=])
  fail!

And I can't define my parser as follows:

 (defcc <foo>
        #\:#\:#\=;)
  READ from #<INPUT STRING-INPUT-STREAM>: there is no character with
name ":#"

In languages with which I'm more familiar, it's possible to read
character literals without any whitespace between each one; but not in
Qi, AFAIK.

Otherwise, there's this strategy:

  (defcc <foo>
      -*- := (if (= ::= -*-) -*- (error "error")))
  (compile <foo> [::=])
  :=

...which doesn't work completely like I'd want.

 What should I do?


    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 9 Sep, 13:42
From: Mark Tarver <dr.mtar...@ukonline.co.uk>
Date: Wed, 9 Sep 2009 05:42:07 -0700 (PDT)
Local: Wed 9 Sep 2009 13:42
Subject: Re: Need more eyes on two small Qi-YACC parsers
OK, Dan, while I'm waiting for my buddy to turn up.

> Isn't -*- supposed to be the head of [1], thus 1? And, consequently:

Well, in your example; the input is

[[1] symbol]

and the head is [1] and not 1.  So Qi-Yacc is doing right.

> In other words, what I really want is this to parse as valid:

>     (compile <rule> [[1] symbol])

OK; try changing your program to:

(defcc <rule>
   [<sn>] <sym>;)

(defcc <sym>
  symbol;)

(defcc <sn>
   -*- := (if (number? -*-)
              -*-
              (error "~A is not a number" -*-)))

I'm guessing at what you want to parse the input into.

Mark

On 8 Sep, 20:16, Daniel Jomphe <danieljom...@gmail.com> 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.
Daniel Jomphe  
View profile   Translate to Translated (View Original)
 More options 9 Sep, 15:53
From: Daniel Jomphe <danieljom...@gmail.com>
Date: Wed, 9 Sep 2009 07:53:22 -0700 (PDT)
Local: Wed 9 Sep 2009 15:53
Subject: Re: Need more eyes on two small Qi-YACC parsers
Thanks for the answer to my question 1. Have you seen my question 2?

=== 1 ===

So you're telling me that <rule> doesn't send the head of the stuff to
be parsed to <sn>, and the rest of it to <sym>?

  (defcc <rule>
        <sn> <sym>;)

I thought that the space between <sn> and <sym> in <rule> told the
compiler to try to parse the first element using <sn>, and the rest of
the elements using <sym>. But maybe I assumed too much in thinking the
compiler knows how to take the head of something this way.

So if I understand well now, it's not the head that's sent to <sn> but
the whole, because <rule> doesn't know what <sn> really wants. And
once <sn> has done taking out whatever it wanted, <rule> will send the
rest to <sym>. Is that a proper way to think about it?

I think I'll reread chapter 8 (metaprograms); I might have read it too
fast last week.

On Sep 9, 8:42 am, 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 9 Sep, 17:59
From: Mark Tarver <dr.mtar...@ukonline.co.uk>
Date: Wed, 9 Sep 2009 09:59:24 -0700 (PDT)
Local: Wed 9 Sep 2009 17:59
Subject: Re: Need more eyes on two small Qi-YACC parsers

> So if I understand well now, it's not the head that's sent to <sn> but
> the whole, because <rule> doesn't know what <sn> really wants. And
> once <sn> has done taking out whatever it wanted, <rule> will send the
> rest to <sym>. Is that a proper way to think about it?

That's about right.

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.
Daniel Jomphe  
View profile   Translate to Translated (View Original)
 More options 9 Sep, 19:08
From: Daniel Jomphe <danieljom...@gmail.com>
Date: Wed, 9 Sep 2009 11:08:10 -0700 (PDT)
Local: Wed 9 Sep 2009 19:08
Subject: Re: Need more eyes on two small Qi-YACC parsers
Thanks. Second, I want something like this to be recognised:

  (defcc <foo>
        ::=;)
  (compile <foo> [::=])
  fail!

I think this clashes with Qi-YACC's semantic action's reserved symbol
":=".

I've tried different strategies but haven't been successful in
accepting ::= as valid (see the start of this thread for my trials).

What should I do?

On Sep 9, 12:59 pm, 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 9 Sep, 22:21
From: Mark Tarver <dr.mtar...@ukonline.co.uk>
Date: Wed, 9 Sep 2009 14:21:38 -0700 (PDT)
Local: Wed 9 Sep 2009 22:21
Subject: Re: Need more eyes on two small Qi-YACC parsers
Since := is part of Qi-yacc syntax; push it into the semantics.

(defcc <foo>
  -*- := (if (= -*- ::=) -*- #\Escape);)

Mark

On 9 Sep, 19:08, Daniel Jomphe <danieljom...@gmail.com> 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 10 Sep, 00:16
From: Mark Tarver <dr.mtar...@ukonline.co.uk>
Date: Wed, 9 Sep 2009 16:16:15 -0700 (PDT)
Local: Thurs 10 Sep 2009 00:16
Subject: Re: Need more eyes on two small Qi-YACC parsers
Type ::= to top level and reflect.

On 9 Sep, 22:21, 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.
Daniel Jomphe  
View profile   Translate to Translated (View Original)
 More options 10 Sep, 01:39
From: Daniel Jomphe <danieljom...@gmail.com>
Date: Wed, 9 Sep 2009 17:39:55 -0700 (PDT)
Local: Thurs 10 Sep 2009 01:39
Subject: Re: Need more eyes on two small Qi-YACC parsers
Thinking of it, I don't even need ::= to be parsed as ::=. My real
intention is to translate stuff. But I'm still confounded by this side-
effect of something I'm not aware of.

From this below, I see that a colon (:) seems to somehow quote what
follows. But I'm really not sure about this. I suppose I'll have to
hope to find my answer in the reader's source code?

That said, I'd like to know the difference between:
- :...  <--
- |...| <--
- #\... <-- character
- Qi::Bar (or approximately)

(8-) :=
:=

(9-) ::=
:=

(10-) :::=
READ from #<INPUT STRING-INPUT-STREAM>: too many colons in token
":::="

(10-) :1
:|1|

(11-) ::1
:|1|

(12-) :::1
READ from #<INPUT STRING-INPUT-STREAM>: too many colons in token ":::
1"

(12-) :a
:a

(13-) ::a
:a

(14-) :::a
READ from #<INPUT STRING-INPUT-STREAM>: too many colons in token
":::a"

(16-) (= := =)
false

(17-) (= := ::=)
true

On Sep 9, 7:16 pm, 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.
snorgers  
View profile   Translate to Translated (View Original)
 More options 10 Sep, 19:53
From: snorgers <stefan.ta...@spray.se>
Date: Thu, 10 Sep 2009 11:53:16 -0700 (PDT)
Local: Thurs 10 Sep 2009 19:53
Subject: Re: Need more eyes on two small Qi-YACC parsers
You should now that the symbols in qi follows the rules of comon-lisp
:alpha    represents a key symbol
::alpha   is the same
:::alpha  The underlying CL engine cannot interpret this, the reson is
that
:: is a namespace operator e.g. qi::ebr  calls the ebr function in the
qi package.

You need to work at the character stream level and or work with
strings

/Stefan

On 10 Sep, 02:39, Daniel Jomphe <danieljom...@gmail.com> 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.
End of messages
« Back to Discussions « Newer topic     Older topic »

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