Re: [sqlite] Questions regarding Lemon

2010-02-22 Thread Wilson, Ronald
> > %type course_plot { std::vector* }
> >
> > course_plot(V) ::= COURSE_PLOT_BEG course_plot_sector(A) .
> > {
> >
> The issue is more what V is when the vector isn't created.
> 
> 
>  Igmar

lemon is not going to initialize anything for you.  You need to design
your parser such that you can control the creation and deletion of your
own objects.

*** untested pseudo-c code ***

%type assigments { struct llist *}
main ::= zero_or_more_statments.
zero_or_more_statements ::= .
zero_or_more_statements ::= zero_or_more_statements one_statement.
one_statement ::= assignments(L). { dostuff(*L); free(L); }
assignments(A) ::= ASSIGNMENT_BEGIN assignment(B). { A = malloc(...);
A->add(B); }
assignments(A) ::= assignments(L) assignment(B). { A = L; A->add(B); }

RW

Ron Wilson, Engineering Project Lead
(o) 434.455.6453, (m) 434.851.1612, www.harris.com

HARRIS CORPORATION   |   RF Communications Division
assuredcommunications(tm)
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Questions regarding Lemon

2010-02-22 Thread Igmar Palsenberg

> %type course_plot { std::vector* }
>
> course_plot(V) ::= COURSE_PLOT_BEG course_plot_sector(A) .
>   {
>
The issue is more what V is when the vector isn't created.


 Igmar
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Questions regarding Lemon

2010-02-22 Thread Wilson, Ronald
You have to initialize the variable yourself, e.g.

%type course_plot { std::vector* } 

course_plot(V) ::= COURSE_PLOT_BEG course_plot_sector(A) .
{
V = new std::vector;
V->push_back(A);
}
course_plot(V) ::= course_plot(L) COURSE_PLOT_GT course_plot_sector(A) .
{
V = L;
V->push_back(A);
}

And yes, I parse TradeWars 2002 with lemon.  /bow

Ron Wilson, Engineering Project Lead
(o) 434.455.6453, (m) 434.851.1612, www.harris.com

HARRIS CORPORATION   |   RF Communications Division 
assuredcommunications(tm)


> -Original Message-
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
> boun...@sqlite.org] On Behalf Of Igmar Palsenberg
> Sent: Monday, February 22, 2010 7:39 AM
> To: sqlite-users@sqlite.org
> Subject: [sqlite] Questions regarding Lemon
> 
> 
> Hi,
> 
> After a decode or so I've begun to program in C again. I've writing a
> parser, and Lemon seems like the right tool for the job. SQLite itself
> is an excellent read when starting with lemon.
> However, a few questions remain unanswered :
> 
> - How do variables get initialized ? For example :
> 
> %type assigments { struct llist *}
> 
> assignments(A) ::= assignments assignment(B). { /* . */ }
> assignments(A) ::= assignment(B). {/*  */ }
> 
> Can I assume that A, when the rule is executed the first time, is NULL ?
> 
> - What is the meaning of @ in an assignment ? From the sqlite parse.y
> source :
> 
> transtype(A) ::= DEFERRED(X).  {A = @X;}
> 
> Thanx in advance for all the hints :)
> 
> 
> Regards,
> 
> 
>  Igmar
> 
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Questions regarding Lemon

2010-02-22 Thread Igmar Palsenberg
Hi,

After a decode or so I've begun to program in C again. I've writing a 
parser, and Lemon seems like the right tool for the job. SQLite itself 
is an excellent read when starting with lemon.
However, a few questions remain unanswered :

- How do variables get initialized ? For example :

%type assigments { struct llist *}

assignments(A) ::= assignments assignment(B). { /* . */ }
assignments(A) ::= assignment(B). {/*  */ }

Can I assume that A, when the rule is executed the first time, is NULL ?

- What is the meaning of @ in an assignment ? From the sqlite parse.y 
source :

transtype(A) ::= DEFERRED(X).  {A = @X;}

Thanx in advance for all the hints :)


Regards,


 Igmar

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users