Lemon grammar question

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Lemon grammar question

Ludvig Strigeus-2
With Bison, you can do something like this (not quite bison syntax):

myrule: TYPE IDENT {DoSomethingRightAfterIdent($1,$2); } LP more_rules
RP; {DoSomethingAfterEverything($1,$2,$5); }

I.e. you have a chunk of C code that's called in the middle of the
processing of the production. (In the above case right after TYPE
IDENT)

Can you do this with lemon?

I know you can do something like this for other cases,

myrule ::= TYPE(T) IDENT(I) temp LP more_rules(R) RP. {
DoSomethingAfterEverything(T,I,R); }
temp ::= DoSomethingRightAfterIdent(...how would I access TYPE/INDENT
from here..);

but it doesn't quite work for this case...

Any ideas?
/Ludvig
Reply | Threaded
Open this post in threaded view
|

Re: Lemon grammar question

Ulrik Sandborg-Petersen
Ludvig Strigeus wrote:

>With Bison, you can do something like this (not quite bison syntax):
>
>myrule: TYPE IDENT {DoSomethingRightAfterIdent($1,$2); } LP more_rules
>RP; {DoSomethingAfterEverything($1,$2,$5); }
>
>I.e. you have a chunk of C code that's called in the middle of the
>processing of the production. (In the above case right after TYPE
>IDENT)
>
>Can you do this with lemon?
>  
>

I don't know if you can do it bison-style, but you can do this:

1) have a struct that wraps a TYPE(T) and IDENT(I).

2) myrule : prefix(P) LP more_rules(R) RP . { /* process rule */ }

3) prefix(P) : TYPE(T) IDENT(I) . { /* process ident; wrap T and I in
the struct from (1); */ }

4) remember to set the default destructor of the prefix rule to destroy
the struct from (1).

>I know you can do something like this for other cases,
>
>myrule ::= TYPE(T) IDENT(I) temp LP more_rules(R) RP. {
>DoSomethingAfterEverything(T,I,R); }
>temp ::= DoSomethingRightAfterIdent(...how would I access TYPE/INDENT
>from here..);
>
>but it doesn't quite work for this case...
>
>Any ideas?
>/Ludvig
>  
>
HTH

Ulrik Petersen

--
Ulrik Petersen, PhD student, MA, B.Sc.
Aalborg University, Denmark


Reply | Threaded
Open this post in threaded view
|

Authorization API

Marco Bambini
I am implementing the authorization API for sqlite 3.
I want to map high level permissions to low level Sqlite permissions.

This is my current map:
SQL_CREATE:
     SQLITE_CREATE_INDEX
     SQLITE_CREATE_TABLE
     SQLITE_CREATE_TEMP_INDEX
     SQLITE_CREATE_TEMP_TABLE
     SQLITE_CREATE_TEMP_TRIGGER
     SQLITE_CREATE_TEMP_VIEW
     SQLITE_CREATE_TRIGGER
     SQLITE_CREATE_VIEW
     SQLITE_ALTER_TABLE
     SQLITE_REINDEX

SQL_DELETE:
     SQLITE_DELETE

SQL_DROP:
     SQLITE_DROP_INDEX
     SQLITE_DROP_TABLE
     SQLITE_DROP_TEMP_INDEX
     SQLITE_DROP_TEMP_TABLE
     SQLITE_DROP_TEMP_TRIGGER
     SQLITE_DROP_TEMP_VIEW
     SQLITE_DROP_TRIGGER
     SQLITE_DROP_VIEW

SQL_INSERT:
     SQLITE_INSERT
     SQLITE_UPDATE
     SQLITE_TRANSACTION

SQL_PRAGMA:
     SQLITE_PRAGMA

SQL_SELECT:
     SQLITE_SELECT
     SQLITE_READ

I am not sure about SQLITE_READ, have I to give this permission also  
to SQL_INSERT?
Anyone can confirm that SQLITE_COPY privilege has been removed in  
sqlite 3?
This page http://www.sqlite.org/lang_copy.html confirms me, but  
SQLITE_COPY is in sqlite3.h so I am sure about this...

Thanks a lot for your help.
Regards,
Marco Bambini
SQLabs.net