Michael Arndt | 5 May 15:18
Picon

Comment at end of input

Hi List!
I'm trying to parse Java input and it seems to work fine with the first 
few tests, but one thing doesn't work and I dont know how to fix it.
this is the input

class _{static long _
(long __,long ___) {
return __==0 ?___+ 1:
___==0?_(__-1,1):_(__
–1,_(__, ___-1)) ; }
static {int _=2 ,___
= 2;System.out.print(
"a("+_+','+___+ ")="+
_ (_, ___) ) ;System
.exit(1);}}//(C) Ulli

a rather bad-style java source. If I remove the Comment at the end 
parsing works, else it fails.
This is my skip-parser
space_p
| comment_p("/*", "*/") // rule for Block-comments
| comment_p("//") // rule for Line-comments

Comments which are not at the end also work fine, but i don't know how 
to handle this one.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
(Continue reading)

Michael Arndt | 5 May 15:32
Picon

Re: Comment at end of input

Thats typical, after trying around for two hours, giving up, sending the 
mail to the list, i suddently got it -.-
it's quite easy, just added a end_p to the start rule of my grammar.

So now my javaparser sould be done, except for ast generation... still 
fascinated by spirit ;D

Michael Arndt schrieb:
> Hi List!
> I'm trying to parse Java input and it seems to work fine with the first 
> few tests, but one thing doesn't work and I dont know how to fix it.
> this is the input
>
> class _{static long _
> (long __,long ___) {
> return __==0 ?___+ 1:
> ___==0?_(__-1,1):_(__
> –1,_(__, ___-1)) ; }
> static {int _=2 ,___
> = 2;System.out.print(
> "a("+_+','+___+ ")="+
> _ (_, ___) ) ;System
> .exit(1);}}//(C) Ulli
>
>
> a rather bad-style java source. If I remove the Comment at the end 
> parsing works, else it fails.
> This is my skip-parser
> space_p
> | comment_p("/*", "*/") // rule for Block-comments
(Continue reading)

Picon

[Phoenix] Prepackaged Phoenix 2 Implementation

Hi Guys,

Do you know where I can get a pre-packaged Phoenix 2 implementation?

--
Dean Michael Berris
Software Engineer, Friendster, Inc.
<dmberris <at> friendster.com>
+639287291459

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Joel de Guzman | 7 May 16:08
Picon
Favicon

Re: [Phoenix] Prepackaged Phoenix 2 Implementation

Dean Michael C. Berris wrote:
> Hi Guys,
> 
> Do you know where I can get a pre-packaged Phoenix 2 implementation?

Boost SVN trunk.

Cheers,
--

-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Alex Klizhentas | 7 May 17:04
Picon
Gravatar

Spirit Python bindings

Hi All,

Are there any python bindings for spirit?

Thanks,
Alex
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general
Esteve Fernandez | 7 May 17:32
Favicon

Re: Spirit Python bindings

El Miércoles 07 Mayo 2008 17:04:42 Alex Klizhentas escribió:
> Hi All,
>
> Are there any python bindings for spirit?

None, AFAIK. But you can use Boost.Python, it's fairly easy to use.

Cheers.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general
Hartmut Kaiser | 7 May 21:02
Picon
Gravatar

Re: [Phoenix] Prepackaged Phoenix 2 Implementation

Dean,

> Do you know where I can get a pre-packaged Phoenix 2 implementation?

The latest version of Phoenix2 is in Boost SVN (trunk, inside the Spirit
directory) and will be part of Boost V1.36 (although not as a separate Boost
library).

HTH
Regards Hartmut

> 
> --
> Dean Michael Berris
> Software Engineer, Friendster, Inc.
> <dmberris <at> friendster.com>
> +639287291459
> 
> -----------------------------------------------------------------------
> --
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/
> javaone
> _______________________________________________
> Spirit-general mailing list
> Spirit-general <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/spirit-general

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Nicola Musatti | 7 May 23:32
Picon

Re: Spirit Python bindings

Alex Klizhentas wrote:
> Hi All,
> 
> Are there any python bindings for spirit?

I love Spirit, but unless you need to parse huge files very frequently, 
PLY (http://www.dabeaz.com/ply/) is much more convenient.

Cheers,
Nicola
--

-- 
Nicola.Musatti <at> gmail <dot> com
Home: http://nicola.musatti.googlepages.com/home
Blog: http://wthwdik.wordpress.com/

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Alex Klizhentas | 7 May 23:41
Picon
Gravatar

Re: Spirit Python bindings

Hello Nicola,

Actually I'm trying to stick to Spirit here since I want to use AST trees that Spirit provides. I'm going to implement the grammar in Spirit and expose AST's to Python.

Alex



2008/5/8 Nicola Musatti <Nicola.Musatti <at> gmail.com>:
Alex Klizhentas wrote:
> Hi All,
>
> Are there any python bindings for spirit?

I love Spirit, but unless you need to parse huge files very frequently,
PLY (http://www.dabeaz.com/ply/) is much more convenient.

Cheers,
Nicola
--
Nicola.Musatti <at> gmail <dot> com
Home: http://nicola.musatti.googlepages.com/home
Blog: http://wthwdik.wordpress.com/


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general



--
Regards,
Alex
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general
Simone Pellegrini | 8 May 12:29
Picon
Picon
Favicon

(Probably) A bug in the Spirit's magic!

Hello everyone,
First of all I'd like to congratulate with the mind(s) behind the Spirit
project because it is simple awesome. 

However, I guess I have found a BUG. Probably the error is due to my
code, but after several hours of investigation, I am almost sure it is
not.

So, let's say tat I want to parse sequences of arguments (integer
numbers for simplicity) and store them inside a vector. These arguments
can be nested (max one level nesting) and in order to avoid the use of
the composite pattern I preferred to use a simple vector and keep the
position of each argument inside the argument list.

For example the following argument list:
"{10, {20, 30}, 50}"

should return the vector of elements:
[10 (pos:0), 20 (pos:1), 30 (pos:1), 50 (pos:2)]

ok? Simple, doesn't it? :)

So, I have defined the following struct in order to keep the parsed
values:

struct integer{
	int val_;
	int pos_;	

	integer(){}
	integer(int const& v, int const& pos): val_(v), pos_(pos){}
};

and I have defined the following grammar:

struct arg_grammar : public boost::spirit::grammar<arg_grammar>{
 template <typename ScannerT>
 struct definition{

  integer i;
  int pos;
        	
  definition(arg_grammar const& self)  {

    params = 
        ch_p('{') >> 
		( ( arg >> *(ch_p(',') >> arg) >> ch_p('}') )
	      |
		ch_p('}') ) >> end_p;

    arg = 
 	value_list[ increment_a(pos) ];
    	
    value_list = 
    	( ch_p('{') >> value >> *(',' >> value) >> ch_p('}') )
    	|
    	value;
    			
    value =
        int_p[ var(i) = construct_<integer>(arg1, pos) ]
        [ push_back_a(self.args, i) ];
   }
		
   rule<ScannerT> params, arg, value, value_list;
   rule<ScannerT> const& start() const { return params; }
 };

 arg_grammar(vector<integer>& args_): args(args_){ }
private:
    vector<integer>& args;
};

When I try to run the code (considering the previous argument list) I
received something like:
[10 (pos:0), 20 (pos:0), 30 (pos:0), 50 (pos:0)]

That is wrong as far as the position (pos) is not correct! :(

So, after several hours of investigation I can affirm that the problem
here is within the construct_ function. In fact, the pos value is
successfully incremented by the increment_at actor, and printing down
its value you can see that pos starts from 0 and reaches the value of
2. 
It seems that the problem happens when the integer object is created,
the pos argument is initialized always with the 0 value even if it has
got a different value (actually 0,1,2). How can be possible???

I have tried to solve the problem changing the grammar as follows:

   int_p[ var(i) = construct_<integer>(arg1, pos) ]
	[ my_assign(i.pos_, pos) ]
        [ push_back_a(self.args, i) ];

where, my_assign is defined as:

struct my_assign{

  void operator()(const int&) const{
    dest = source;
  }
  my_assign(int& dest_, int& source_): dest(dest_), source(source_){}

private:
  int& dest;
  int& source;
};

Using my custom actor everything works fine and the result is:
[10 (pos:0), 20 (pos:1), 30 (pos:1), 50 (pos:2)]

as expected.

Beside that solution, I have also tried to define the pos value as a
member value using closures, then outside the struct definition... as a
class member, but nothing worked.
So, what do you think guys? Where is the problem? Is it something
related to the definition of my grammar or is it a REAL bug?

greetings S. Pellegrini

P.S.: In attachment you can find the source code of the example. 

-- 
Simone Pellegrini
INFN (National Institute of Nuclear Physics)
Viale Berti Pichat 6/2 
40127 Bologna - Italy
email: simone.pellegrini <at> cnaf.infn.it
Attachment (arg_parser.cpp): text/x-c++src, 2036 bytes
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general

Gmane