[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Treetop Parser whitespace

Young tae Kim

3/9/2009 6:48:00 PM

I can't understand why the following test fails.
Could you tell me why? Thanks, in advance.


# in arithmetic.treetop

grammar Arithmetic
rule white_space
[ \t\n\r]+ {
def value
text_value
end
}
end
end





# in test_parser.rb
require "rubygems"
require "treetop"
require "arithmetic"

parser = ArithmeticParser.new

p parser.parse(" \n\t\r")




# the execution result
$ ruby test_parser.rb
nil
--
Posted via http://www.ruby-....

15 Answers

Clifford Heath

3/9/2009 9:39:00 PM

0

Young tae Kim wrote:
> I can't understand why the following test fails.
> Could you tell me why? Thanks, in advance.

It works for me. What version of Treetop and Polyglot
are you using. Can you please tell us what is printed
by "puts parser.failure_reason"?

Clifford Heath.

Young tae Kim

3/9/2009 11:21:00 PM

0

Clifford Heath wrote:
> Young tae Kim wrote:
>> I can't understand why the following test fails.
>> Could you tell me why? Thanks, in advance.
>
> It works for me. What version of Treetop and Polyglot
> are you using. Can you please tell us what is printed
> by "puts parser.failure_reason"?
>
> Clifford Heath.

First of all, many thanks for your reply!

The version of the operating system is Ubuntu 8.10

the ruby version is ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux]

The following is the result of gem list --local

$ gem list --local

*** LOCAL GEMS ***

actionmailer (2.2.2)
actionpack (2.2.2)
activerecord (2.2.2)
activeresource (2.2.2)
activesupport (2.2.2)
cgi_multipart_eof_fix (2.5.0)
daemons (1.0.10)
fastthread (1.0.1)
gem_plugin (0.2.3)
hoe (1.9.0)
mongrel (1.1.5)
polyglot (0.2.5) <----
rails (2.2.2)
rake (0.8.3)
rubyforge (1.0.3)
sqlite3-ruby (1.2.4)
treetop (1.2.4) <----

What's printed by "puts parser.failure_reason" is just "nil".


--
Posted via http://www.ruby-....

Young tae Kim

3/9/2009 11:37:00 PM

0

Clifford Heath wrote:
> Young tae Kim wrote:
>> I can't understand why the following test fails.
>> Could you tell me why? Thanks, in advance.
>
> It works for me. What version of Treetop and Polyglot
> are you using. Can you please tell us what is printed
> by "puts parser.failure_reason"?
>
> Clifford Heath.

I revised my example like this but it doesn't work as well.

# in arithmetic.treetop

grammar Arithmetic
rule num
[1-9] [0-9]* {
def value
text_value
end
}
end

rule space
[ \t\n\r]+ {
def value
text_value
end
}
end
end



# in test_parser.rb

require "rubygems"
require "treetop"
require "arithmetic"

parser = ArithmeticParser.new

p parser.parse("123")
p parser.parse(" \n\t\r")
puts parser.failure_reason



# the execution result

$ ruby test_parser.rb
SyntaxNode+Num1+Num0 offset=0, "123" (value):
SyntaxNode offset=0, "1"
SyntaxNode offset=1, "23":
SyntaxNode offset=1, "2"
SyntaxNode offset=2, "3"
nil
nil

--
Posted via http://www.ruby-....

Clifford Heath

3/10/2009 12:47:00 AM

0

Young Tae Kim wrote:
> What's printed by "puts parser.failure_reason" is just "nil".

I think that's a bug. I don't have time to investigate it right now.
BTW, if you run the command "tt arithmetic.tt", you'll get the
generated "arithmetic.rb" code that you can explore.

Clifford Heath

Young tae Kim

3/10/2009 1:50:00 AM

0

I got an answer. If you face the same problem, please refer to the
following site.

http://groups.google.com/group/treetop-dev/browse_thread/thread/417aaf...

--
Posted via http://www.ruby-....

Obveeus

7/24/2014 12:04:00 AM

0



On 7/23/2014 7:18 PM, Rhino wrote:
> On 2014-07-23 3:38 PM, David wrote:
>> http://tvbythenumbers.zap2it.com/2014/07/23/the-cw-pulls-seed-backpackers-from-its-schedule-after-two-episod...
>>
>>
>> The CW Pulls 'Seed' & 'Backpackers' From Its Schedule After Two Episodes

> I never saw Backpackers but I'm genuinely disappointed that the American
> audience didn't give Seed a chance.
>
> Was it just not marketed well? Or did people try it and just not find it
> their cup of tea?

It was aired on the 5th place broadcast network, which few people watch.

Ian J. Ball

7/24/2014 5:54:00 AM

0

In article <lqpih0$fo7$1@dont-email.me>, Obveeus <Obveeus@aol.com>
wrote:

> On 7/23/2014 7:18 PM, Rhino wrote:
> > On 2014-07-23 3:38 PM, David wrote:
> >>
> >> http://tvbythenumbers.zap2it.com/2014/07/23/th...
> >> -seed-backpackers-from-its-schedule-after-two-episodes/285693/
> >>
> >> The CW Pulls 'Seed' & 'Backpackers' From Its Schedule After Two Episodes
> >
> > I never saw Backpackers but I'm genuinely disappointed that the American
> > audience didn't give Seed a chance.
> >
> > Was it just not marketed well? Or did people try it and just not find it
> > their cup of tea?
>
> It was aired on the 5th place broadcast network, which few people watch.

And it was a sitcom on a network that basically doesn't air sitcoms, and
never has.

And it was a *Canadian* sitcom airing on a (minor) American broadcast
network.

During summer.
When said network runs basically *no* real original programming.

Yeah, there was never anything wrong with this idea!... [roll]

--
"Wait! - You can set your GPS to "tacos"?!" - Shawn, to Gus, in
"The Break-Up", the series finale to "Psych" (03-26-14)

Obveeus

7/24/2014 12:03:00 PM

0



On 7/24/2014 1:53 AM, Ian J. Ball wrote:
> In article <lqpih0$fo7$1@dont-email.me>, Obveeus <Obveeus@aol.com>
> wrote:
>
>> On 7/23/2014 7:18 PM, Rhino wrote:
>>> On 2014-07-23 3:38 PM, David wrote:
>>>>
>>>> http://tvbythenumbers.zap2it.com/2014/07/23/th...
>>>> -seed-backpackers-from-its-schedule-after-two-episodes/285693/
>>>>
>>>> The CW Pulls 'Seed' & 'Backpackers' From Its Schedule After Two Episodes
>>>
>>> I never saw Backpackers but I'm genuinely disappointed that the American
>>> audience didn't give Seed a chance.
>>>
>>> Was it just not marketed well? Or did people try it and just not find it
>>> their cup of tea?
>>
>> It was aired on the 5th place broadcast network, which few people watch.
>
> And it was a sitcom on a network that basically doesn't air sitcoms, and
> never has.

CW aired sitcoms at the start. One of those sitcoms is still on the
air, in fact, just on a different network.

> And it was a *Canadian* sitcom airing on a (minor) American broadcast
> network.
>
> During summer.
> When said network runs basically *no* real original programming.
>
> Yeah, there was never anything wrong with this idea!... [roll]

Since almost no one is watching the network this summer anyway, I don't
know why they didn't keep these on the air just to get a real sense for
what sort of sitcom audience they can establish...maybe even pick up a
few more foreign sitcoms for the regular season so they aren't having to
run any shows twice in the same week just to fill out the schedule.

Ian J. Ball

7/24/2014 3:19:00 PM

0

In article <lqqslk$rjn$1@dont-email.me>, Obveeus <Obveeus@aol.com>
wrote:

> On 7/24/2014 1:53 AM, Ian J. Ball wrote:
> > In article <lqpih0$fo7$1@dont-email.me>, Obveeus <Obveeus@aol.com>
> > wrote:
> >> On 7/23/2014 7:18 PM, Rhino wrote:
> >>> On 2014-07-23 3:38 PM, David wrote:
> >>>>
> >>>> http://tvbythenumbers.zap2it.com/2014/07/23/th...
> >>>> -seed-backpackers-from-its-schedule-after-two-episodes/285693/
> >>>>
> >>>> The CW Pulls 'Seed' & 'Backpackers' From Its Schedule After Two Episodes
> >>>
> >>> I never saw Backpackers but I'm genuinely disappointed that the American
> >>> audience didn't give Seed a chance.
> >>>
> >>> Was it just not marketed well? Or did people try it and just not find it
> >>> their cup of tea?
> >>
> >> It was aired on the 5th place broadcast network, which few people watch.
> >
> > And it was a sitcom on a network that basically doesn't air sitcoms, and
> > never has.
>
> CW aired sitcoms at the start. One of those sitcoms is still on the
> air, in fact, just on a different network.

The C-Wub did? Or The WB/UPN did?

'Cos I honestly don't remember any sitcoms originating on The C-Wub, at
least none that weren't summer burnoff...

--
"Wait! - You can set your GPS to "tacos"?!" - Shawn, to Gus, in
"The Break-Up", the series finale to "Psych" (03-26-14)

Anim8rFSK

7/24/2014 3:42:00 PM

0

In article
<ijball-NO_SPAM-6F6B4C.08183724072014@news.eternal-september.org>,
"Ian J. Ball" <ijball-NO_SPAM@mac.invalid> wrote:

> In article <lqqslk$rjn$1@dont-email.me>, Obveeus <Obveeus@aol.com>
> wrote:
>
> > On 7/24/2014 1:53 AM, Ian J. Ball wrote:
> > > In article <lqpih0$fo7$1@dont-email.me>, Obveeus <Obveeus@aol.com>
> > > wrote:
> > >> On 7/23/2014 7:18 PM, Rhino wrote:
> > >>> On 2014-07-23 3:38 PM, David wrote:
> > >>>>
> > >>>> http://tvbythenumbers.zap2it.com/2014/07/23/th...
> > >>>> -seed-backpackers-from-its-schedule-after-two-episodes/285693/
> > >>>>
> > >>>> The CW Pulls 'Seed' & 'Backpackers' From Its Schedule After Two
> > >>>> Episodes
> > >>>
> > >>> I never saw Backpackers but I'm genuinely disappointed that the
> > >>> American
> > >>> audience didn't give Seed a chance.
> > >>>
> > >>> Was it just not marketed well? Or did people try it and just not find
> > >>> it
> > >>> their cup of tea?
> > >>
> > >> It was aired on the 5th place broadcast network, which few people watch.
> > >
> > > And it was a sitcom on a network that basically doesn't air sitcoms, and
> > > never has.
> >
> > CW aired sitcoms at the start. One of those sitcoms is still on the
> > air, in fact, just on a different network.
>
> The C-Wub did? Or The WB/UPN did?
>
> 'Cos I honestly don't remember any sitcoms originating on The C-Wub, at
> least none that weren't summer burnoff...

http://en.wikipedia.org/wiki/List_of_programs_broadcast_by_The_...

Sitcoms[edit]
? Girlfriends (2006?2008) (UPN, 2000?2006)
? Reba (2006?2007) (The WB, 2001?2006)
? All of Us (2006?2007) (UPN, 2003?2006)
? Everybody Hates Chris (2006?2009) (UPN, 2005?2006)
? The Game (2006?2009; 2011?present on BET)
? Aliens in America (2007?2008)
? 18 to Life (2010)
? Backpackers (2014)
? Seed (2014)

--
Wait - are you saying that ClodReamer was wrong, or lying?