Usenet.com

www.Usenet.com

Group Index

Comp Thread Archive from Usenet.com

<-- __Chronological__ --> <-- __Thread__ -->

Re: Newbie question...



Amund Trovåg wrote:


Yes, thank you so much for that! This works, and I understand why it should be like this. :)
The last problem I have now is the part of the expression that is "relationName". In the language, the relationNames/relation expressions, are always enclosed in parentheses like you show above. The parentheses however, are not part of the actual string of the token, they are rather there to show that it is a relation, and not attribute e.g.


This problem seems similar to the one you just solved, but it doesn't seem to be(at least not in my newb experience) :).
I have defined the tokens
| <LEFTPAR: "(">
| <RIGHTPAR: ")">
and <RELATION> is the same as the token <ID>, only a different tokenname.


So I have:
void project() #PROJECT:
{Token t = new Token();}
{// project + attribute name commalist(zero or more(*)) end with //(relationname) and EOF=;
(t=<PROJECT>) [attributeList()] Relation() {jjtThis.setToken(t.kind, t.image);}
}
and the relation production:
void Relation() #RELATION:
{Token t = new Token();}
{
t=<RELATION>{jjtThis.setToken(t.kind, t.image);}
}
In Relation() I want to do something like this:
<LEFTPAR>t=<RELATION>{jjtThis.setToken(t.kind, t.image);}<RIGHTPAR>
but this doesn't seem to work.


When I write in the parser: project ssn, name(relationName); The parser returns, "expecting <RELATION>". I get it to work if I define the <RELATION> token to be enclosed by <LEFTPAR> and <RIGHTPAR>. Still, this is not what I want. This token too, should have the string as the relationName in itself, _without_ the parentheses.

This may seem easy for some of you, but I would be happy if you could point me in the right direction for this as well so I can get on with my program.

Thanks in advance,

regards,
Amund


After parsing name it then tries to match Relation(), the first token of Relation is <RELATION> while the next token of the input is "(".

The answer is similar to the previous one. You need to change Relation()
to look for "(" <RELATION> ")".

--
Mike Atkinson
(to reply remove NO SPAM from the address).



<-- __Chronological__ --> <-- __Thread__ -->


Usenet.com



Please check out one of the premium Usenet Newsgroup Service Providers below for access to Usenet.