Need help with writing a grammar

View: New views
4 Messages — Rating Filter:   Alert me  

Need help with writing a grammar

by Joe Solinsky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,
  It has been a while since I was on this list.  I've run into a problem that can only be solved with SableCC, sanely, which involves translating a 3D object from VRML 1.0 (WRL specification) to native C.  I attached the grammar I'm developing as the file wrl.grammar.

On line 68, I have the following production:
        point_elem        =     float float float point_elem_tail*;

when I process it, I get this message:

java.lang.RuntimeException: [68,23] Redefinition of APointElem.Float.

Would someone explain to me why this isn't a valid production?  Feel free to remind me something I may have forgotten in my language theory class.
  Thank you for your assistance on this.
--
-- Joe Solinsky
Plymouth, MN

_______________________________________________
SableCC-Discussion mailing list
SableCC-Discussion@...
http://lists.sablecc.org/listinfo/sablecc-discussion

wrl.grammar (2K) Download Attachment

RE: Need help with writing a grammar

by Christopher Van Kirk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Message
I belive that you need to give each of the float terms a separate name, like this:
 
point_elem = [float1]:float [float2]:float [float3]:float [tail]:point_elem_tail*;
 
-----Original Message-----
From: sablecc-discussion-bounces+chris.vankirk=fdcjapan.com@... [mailto:sablecc-discussion-bounces+chris.vankirk=fdcjapan.com@...] On Behalf Of Joe Solinsky
Sent: Friday, May 23, 2008 3:38 AM
To: sablecc-discussion@...
Subject: Need help with writing a grammar

Hello,
  It has been a while since I was on this list.  I've run into a problem that can only be solved with SableCC, sanely, which involves translating a 3D object from VRML 1.0 (WRL specification) to native C.  I attached the grammar I'm developing as the file wrl.grammar.

On line 68, I have the following production:
        point_elem        =     float float float point_elem_tail*;

when I process it, I get this message:

java.lang.RuntimeException: [68,23] Redefinition of APointElem.Float.

Would someone explain to me why this isn't a valid production?  Feel free to remind me something I may have forgotten in my language theory class.
  Thank you for your assistance on this.
--
-- Joe Solinsky
Plymouth, MN

_______________________________________________
SableCC-Discussion mailing list
SableCC-Discussion@...
http://lists.sablecc.org/listinfo/sablecc-discussion

Re: Need help with writing a grammar

by Taketoshi Nishimori :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Joe,

> java.lang.RuntimeException: [68,23] Redefinition of APointElem.Float.

If Sablecc could output CST from this rule, the node class APointElem corresponding
to point_elem would have three same name methods.

class APointElem {
   PFloat getFloat() { ..  } /* confrict! */
   PFloat getFloat() { ..  } /* confrict! */
   PFloat getFloat() { ..  } /* confrict! */
   LinkedList getPointElemTail() { .. }
}

So you should rewrite:

point_elem = [f1]:float [f2]:float [f3]:float point_elem_tail*;

The APointElem class will be:

class APointElem {
   PFloat getF1() { ..  }
   PFloat getF2() { ..  }
   PFloat getF3() { ..  }
   LinkedList getAPointElemTail() { .. }
}


regards

Taketoshi Nishimori

--
Taketoshi Nishimori
<nis@...>
<nistake@...>


_______________________________________________
SableCC-Discussion mailing list
SableCC-Discussion@...
http://lists.sablecc.org/listinfo/sablecc-discussion

Re: Need help with writing a grammar

by Joe Solinsky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you everyone.  I knew it was something I didn't understand!

On Fri, May 23, 2008 at 1:46 AM, Christopher Van Kirk <chris.vankirk@...> wrote:
I belive that you need to give each of the float terms a separate name, like this:
 
point_elem = [float1]:float [float2]:float [float3]:float [tail]:point_elem_tail*;
 
-----Original Message-----
From: sablecc-discussion-bounces+chris.vankirk=fdcjapan.com@lists.sablecc.org [mailto:...=fdcjapan.com@lists.sablecc.org] On Behalf Of Joe Solinsky
Sent: Friday, May 23, 2008 3:38 AM
To: sablecc-discussion@...
Subject: Need help with writing a grammar

Hello,
  It has been a while since I was on this list.  I've run into a problem that can only be solved with SableCC, sanely, which involves translating a 3D object from VRML 1.0 (WRL specification) to native C.  I attached the grammar I'm developing as the file wrl.grammar.

On line 68, I have the following production:
        point_elem        =     float float float point_elem_tail*;

when I process it, I get this message:

java.lang.RuntimeException: [68,23] Redefinition of APointElem.Float.

Would someone explain to me why this isn't a valid production?  Feel free to remind me something I may have forgotten in my language theory class.
  Thank you for your assistance on this.
--
-- Joe Solinsky
Plymouth, MN

_______________________________________________
SableCC-Discussion mailing list
SableCC-Discussion@...
http://lists.sablecc.org/listinfo/sablecc-discussion




--
-- Joe Solinsky
Plymouth, MN
_______________________________________________
SableCC-Discussion mailing list
SableCC-Discussion@...
http://lists.sablecc.org/listinfo/sablecc-discussion
LightInTheBox - Buy quality products at wholesale price!