[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

TreeTop: dealing with Grammars in multiple files?

rubyfan

2/7/2008 1:42:00 AM

I know that you can include one grammar into another like so:

grammar foo
include Bar_grammar
end

But what if Bar_grammar is defined in a different file? I tried:

load_grammar "Bar_grammar"
grammar Foo
include Bar_grammar
end

but that doesnt' work.

5 Answers

Clifford Heath

2/7/2008 2:02:00 AM

0

Phil Tomson wrote:
> I know that you can include one grammar into another like so:
>
> grammar foo
> include Bar_grammar
> end
>
> But what if Bar_grammar is defined in a different file? I tried:
>
> load_grammar "Bar_grammar"
> grammar Foo
> include Bar_grammar
> end
>
> but that doesnt' work.

I haven't done this, but I think I might have said this was the
way to compose grammars. I suspect I was wrong, and that what you
need to do is to require both grammars, then re-open one of the
generated parser classes (which includes the module for that
grammar), and simply include the other grammar.

BTW, load_grammar is deprecated - in fact I thought it had been
removed. Are you using an old gem? The current incantation is
to call Treetop.load, or just to simply require the .treetop
file (which gets Polyglot to load it for you).

The file to be required may be called with either a .tt or .treetop
extension.

Clifford Heath.

rubyfan

2/29/2008 3:51:00 AM

0

On 2/6/08, Clifford Heath <no@spam.please.net> wrote:
> Phil Tomson wrote:
> > I know that you can include one grammar into another like so:
> >
> > grammar foo
> > include Bar_grammar
> > end
> >
> > But what if Bar_grammar is defined in a different file? I tried:
> >
> > load_grammar "Bar_grammar"
> > grammar Foo
> > include Bar_grammar
> > end
> >
> > but that doesnt' work.
>
>
> I haven't done this, but I think I might have said this was the
> way to compose grammars. I suspect I was wrong, and that what you
> need to do is to require both grammars, then re-open one of the
> generated parser classes (which includes the module for that
> grammar), and simply include the other grammar.
>
> BTW, load_grammar is deprecated - in fact I thought it had been
> removed. Are you using an old gem? The current incantation is
> to call Treetop.load, or just to simply require the .treetop
> file (which gets Polyglot to load it for you).
>
> The file to be required may be called with either a .tt or .treetop
> extension.


sorry for the long delay... just got back to this problem.

So you're saying that I could have two files each which defines a grammar:
#keywords.treetop
grammar Keywords
...
end

#Foo.treetop
grammar Foo
...
end

OK, so now I've got keywords.treetop and Foo.treetop, so are you
saying that I would then do something like:

#main.rb
require "keywords"
require "Foo"

And then open the Foo module like so:

module Foo
include Keywords
end

... or something like that??

Phil

Clifford Heath

2/29/2008 4:26:00 AM

0

Phil Tomson wrote:
> And then open the Foo module like so:
>
> module Foo
> include Keywords
> end
>
> .. or something like that??

Exactly that. Each rule becomes a method, so including one
module in the other makes all rules available to that parser.

Let us know how it goes, but in principle it should work fine.

Clifford Heath.

Eddie Haskell

4/6/2012 2:34:00 PM

0


".MattB." <trdell1234@Nomorespamgmail.com> wrote in message
news:qugsn7hag5dcarsa370m7r3pncs8d267c5@4ax.com...
> On Fri, 6 Apr 2012 01:14:17 +0000 (UTC), 2938 Dead <dead@gone.com>
> wrote:
>
>>On Thu, 05 Apr 2012 15:14:57 -0700, .MattB. wrote:
>>
>>> On Thu, 5 Apr 2012 17:00:31 -0500, "Eddie Haskell" <hfhfhfhf@ssassw.com>
>>> wrote:
>>>
>>>
>>>>".MattB." <trdell1234@Nomorespamgmail.com> wrote in message
>>>>news:fp4sn7tehjr1c0lhgo0s50etvddn7578f3@4ax.com...
>>>>> On Thu, 5 Apr 2012 16:46:32 -0500, "Eddie Haskell"
>>>>> <hfhfhfhf@ssassw.com> wrote:
>>>>>
>>>>>
>>>>>>".MattB." <trdell1234@Nomorespamgmail.com> wrote in message
>>>>>>news:vd4sn790abao0vhba6b67soca0h284qhb3@4ax.com...
>>>>>>> On Thu, 5 Apr 2012 16:28:02 -0500, "Eddie Haskell"
>>>>>>> <hfhfhfhf@ssassw.com> wrote:
>>>>>>>
>>>>>>>
>>>>>>>>".MattB." <trdell1234@Nomorespamgmail.com> wrote in message
>>>>>>>>news:223sn7h8cufarf25lg5vdlrl6usanhhnp2@4ax.com...
>>>>>>>>> The Supreme Court's Contempt for Congress
>>>>>>>>>
>>>>>>>>> It's well known by now that Donald Verrilli, Jr., the Solicitor
>>>>>>>>> General, had an off day at the Supreme Court last Tuesday, when he
>>>>>>>>> was called on to defend the constitutionality of the individual
>>>>>>>>> mandate, the part of the Affordable Care Act which requires people
>>>>>>>>> to buy health insurance. Still, it's worth noting the magnitude of
>>>>>>>>> the challenge that he was facing. The key issue in the case is
>>>>>>>>> whether Congress, in passing the law, exceeded its powers under
>>>>>>>>> the Commerce Clause of the Constitution, which allows the
>>>>>>>>> government to regulate interstate commerce. Consider, then, this
>>>>>>>>> question, posed to Verrilli by Justice Anthony M. Kennedy: "Assume
>>>>>>>>> for the moment that this"-the mandate-"is unprecedented, this is a
>>>>>>>>> step beyond what our cases have allowed, the affirmative duty to
>>>>>>>>> act to go into commerce. If that is so, do you not have a heavy
>>>>>>>>> burden of justification?" Every premise of that question was a
>>>>>>>>> misperception. The involvement of the federal government in the
>>>>>>>>> health-care market is not unprecedented; it dates back nearly
>>>>>>>>> fifty years, to the passage of Medicare and Medicaid. The forty
>>>>>>>>> million uninsured Americans whose chances for coverage are riding
>>>>>>>>> on the outcome of the case are already entered "into commerce,"
>>>>>>>>> because others are likely to pay their health-care costs
>>>>>>>>>
>>>>>>>>> ..........
>>>>>>>>>
>>>>>>>>> No one expects the Justices to be making health-care policy any
>>>>>>>>> more than we expect them to be picking Presidents, which, it may
>>>>>>>>> be remembered, is not exactly their strength, either. ?
>>>>>>>>
>>>>>>>>Except that it never happened, moron.
>>>>>>>
>>>>>>> Well maybe you had better write the write of the article.
>>>>>>
>>>>>>So you're now you're posting shit that you don't even believe, moron?
>>>>>
>>>>> Maybe I'm posting it to see what other people think. Well in this
>>>>> case.
>>>>>
>>>>> So you opinion noted.
>>>>>
>>>>> My opinion Bush and Obama tied as worse Presidents in the history of
>>>>> the USA.
>>>>
>>>>That's because you are a DNC / MSM cabal brainwashed moron.
>>>>
>>>>May as well tell me that Zimmerman said, "This guy looks like he's up to
>>>>no good. He looks black."
>>>
>>> Which of the DNC / MSM cabal said that about Obama again?
>>
>>Still trying to pretend you aren't a racist piece of shit there, bubbles?
>
> What has anything here have to do with race?

When dealing with a self-loathing racist Sambo fuck like "2938 Dead"
EVERYTHING has to do with race. Astronomy has to do with race. Mathematics
has to do with race. The automotive industry has to do race. Just pick up a
copy of Louis Farrakhan's "Final Call" aka "Why it's Whitey's Fault and
you'll understand Kunta Kinte's mentality completely.

-Eddie Haskell


Eddie Haskell

4/6/2012 2:40:00 PM

0


".MattB." <trdell1234@Nomorespamgmail.com> wrote in message
news:o1psn7pbe0mvs9sfb8qps9abhnarhghlta@4ax.com...
> On Fri, 6 Apr 2012 03:30:52 +0000 (UTC), 2938 Dead <dead@gone.com>
> wrote:
>
>>On Thu, 05 Apr 2012 18:17:58 -0700, .MattB. wrote:
>>
>>> On Fri, 6 Apr 2012 01:14:17 +0000 (UTC), 2938 Dead <dead@gone.com>
>>> wrote:
>>>
>>>>On Thu, 05 Apr 2012 15:14:57 -0700, .MattB. wrote:
>>>>
>>>>> On Thu, 5 Apr 2012 17:00:31 -0500, "Eddie Haskell"
>>>>> <hfhfhfhf@ssassw.com> wrote:
>>>>>
>>>>>
>>>>>>".MattB." <trdell1234@Nomorespamgmail.com> wrote in message
>>>>>>news:fp4sn7tehjr1c0lhgo0s50etvddn7578f3@4ax.com...
>>>>>>> On Thu, 5 Apr 2012 16:46:32 -0500, "Eddie Haskell"
>>>>>>> <hfhfhfhf@ssassw.com> wrote:
>>>>>>>
>>>>>>>
>>>>>>>>".MattB." <trdell1234@Nomorespamgmail.com> wrote in message
>>>>>>>>news:vd4sn790abao0vhba6b67soca0h284qhb3@4ax.com...
>>>>>>>>> On Thu, 5 Apr 2012 16:28:02 -0500, "Eddie Haskell"
>>>>>>>>> <hfhfhfhf@ssassw.com> wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>".MattB." <trdell1234@Nomorespamgmail.com> wrote in message
>>>>>>>>>>news:223sn7h8cufarf25lg5vdlrl6usanhhnp2@4ax.com...
>>>>>>>>>>> The Supreme Court's Contempt for Congress
>>>>>>>>>>>
>>>>>>>>>>> It's well known by now that Donald Verrilli, Jr., the Solicitor
>>>>>>>>>>> General, had an off day at the Supreme Court last Tuesday, when
>>>>>>>>>>> he was called on to defend the constitutionality of the
>>>>>>>>>>> individual mandate, the part of the Affordable Care Act which
>>>>>>>>>>> requires people to buy health insurance. Still, it's worth
>>>>>>>>>>> noting the magnitude of the challenge that he was facing. The
>>>>>>>>>>> key issue in the case is whether Congress, in passing the law,
>>>>>>>>>>> exceeded its powers under the Commerce Clause of the
>>>>>>>>>>> Constitution, which allows the government to regulate interstate
>>>>>>>>>>> commerce. Consider, then, this question, posed to Verrilli by
>>>>>>>>>>> Justice Anthony M. Kennedy: "Assume for the moment that
>>>>>>>>>>> this"-the mandate-"is unprecedented, this is a step beyond what
>>>>>>>>>>> our cases have allowed, the affirmative duty to act to go into
>>>>>>>>>>> commerce. If that is so, do you not have a heavy burden of
>>>>>>>>>>> justification?" Every premise of that question was a
>>>>>>>>>>> misperception. The involvement of the federal government in the
>>>>>>>>>>> health-care market is not unprecedented; it dates back nearly
>>>>>>>>>>> fifty years, to the passage of Medicare and Medicaid. The forty
>>>>>>>>>>> million uninsured Americans whose chances for coverage are
>>>>>>>>>>> riding on the outcome of the case are already entered "into
>>>>>>>>>>> commerce," because others are likely to pay their health-care
>>>>>>>>>>> costs
>>>>>>>>>>>
>>>>>>>>>>> ..........
>>>>>>>>>>>
>>>>>>>>>>> No one expects the Justices to be making health-care policy any
>>>>>>>>>>> more than we expect them to be picking Presidents, which, it may
>>>>>>>>>>> be remembered, is not exactly their strength, either. ?
>>>>>>>>>>
>>>>>>>>>>Except that it never happened, moron.
>>>>>>>>>
>>>>>>>>> Well maybe you had better write the write of the article.
>>>>>>>>
>>>>>>>>So you're now you're posting shit that you don't even believe,
>>>>>>>>moron?
>>>>>>>
>>>>>>> Maybe I'm posting it to see what other people think. Well in this
>>>>>>> case.
>>>>>>>
>>>>>>> So you opinion noted.
>>>>>>>
>>>>>>> My opinion Bush and Obama tied as worse Presidents in the history
>>>>>>> of
>>>>>>> the USA.
>>>>>>
>>>>>>That's because you are a DNC / MSM cabal brainwashed moron.
>>>>>>
>>>>>>May as well tell me that Zimmerman said, "This guy looks like he's up
>>>>>>to no good. He looks black."
>>>>>
>>>>> Which of the DNC / MSM cabal said that about Obama again?
>>>>
>>>>Still trying to pretend you aren't a racist piece of shit there,
>>>>bubbles?
>>>
>>> What has anything here have to do with race?
>>>
>>> The quote from the 911 call is edited and out of context. FACT.
>>
>>And there the little bigot goes, trying to be disingenuous and dance away
>>from his seething hatred of black people.
>
> I don't hate even you. Pity feel sorry for yes.
>>
>>You're a disgraceful piece of shit.
>
> Now go back to your little racist friends and tell them a white
> man dared to disagree with you. Forgot 3/4 white.

I wondered what was wrong with you.

-Eddie Haskell