Left values and assignments

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

Left values and assignments

by Henrique Rocha :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm having trouble with SableCC's CST->AST transformations.
I'm trying to write productions for assignments and left values
because I have C-like structs in my language.

Here is what I have:

simple_statement {-> statement} =
      {assign} lvalue assign exp semi {-> New statement.assign(lvalue,exp) }

basic_exp {-> exp} =
(...)
    | {lvalue} lvalue {-> New exp.lvalue(lvalue) }

How should I define lvalue to be able to parse this?

x.number = 10;
print(x.number);

Thanks.
--
Henrique Rocha
www.hmrocha.com
ExpertRating Certified Windows XP Professional
ExpertRating Certified Unix Shell Script Professional
ExpertRating Certified Unix Professional
ExpertRating Certified Object-Oriented Concepts Professional
ExpertRating Certified Professional Computer Technician Skills
ExpertRating Certified HTML 4 Professional

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

Parent Message unknown Re: Left values and assignments

by Christopher Van Kirk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Have a look at the pascal sample on the SableCC website. That should give you a clue how to handle expressions.

--- On Sun, 4/19/09, Henrique Rocha <hmrocha@...> wrote:

> From: Henrique Rocha <hmrocha@...>
> Subject: Left values and assignments
> To: "Discussion mailing list for the SableCC project" <sablecc-discussion@...>
> Date: Sunday, April 19, 2009, 2:48 AM
> Hi,
>
> I'm having trouble with SableCC's CST->AST
> transformations.
> I'm trying to write productions for assignments and left
> values
> because I have C-like structs in my language.
>
> Here is what I have:
>
> simple_statement {-> statement} =
>       {assign} lvalue assign exp semi {->
> New statement.assign(lvalue,exp) }
>
> basic_exp {-> exp} =
> (...)
>     | {lvalue} lvalue {-> New
> exp.lvalue(lvalue) }
>
> How should I define lvalue to be able to parse this?
>
> x.number = 10;
> print(x.number);
>
> Thanks.
> --
> Henrique Rocha
> www.hmrocha.com
> ExpertRating Certified Windows XP Professional
> ExpertRating Certified Unix Shell Script Professional
> ExpertRating Certified Unix Professional
> ExpertRating Certified Object-Oriented Concepts
> Professional
> ExpertRating Certified Professional Computer Technician
> Skills
> ExpertRating Certified HTML 4 Professional
>
> _______________________________________________
> SableCC-Discussion mailing list
> SableCC-Discussion@...
> http://lists.sablecc.org/listinfo/sablecc-discussion
>

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