PetitParser Help

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

PetitParser Help

Mohammad Al Houssami (Alumni)

Hello Everyone

 

I was going over PetitParser part on the pharo by example book. http://pharobooks.gforge.inria.fr/PharoByExampleTwo-Eng/latest/PetitParser.pdf

 

It was all going good until page 11.

Script 1.19is for creating the class so this was fine. You get an ExpressionGrammar class with all the needed variables, but what about script 1.20?

 

Where does this script go? I understand what the code does. It is describing a grammar for mathematical expressions by defining what everything is and the rules of the grammar. I am not sure where shall I put this script to run it. In earlier examples I was using the workspace.

 

Any help is much appreciated.

Mohammad

 

Reply | Threaded
Open this post in threaded view
|

Re: PetitParser Help

Benjamin Van Ryseghem (Pharo)
<base href="x-msg://97/">This code
ExpressionGrammar>>term
^ add / prod
ExpressionGrammar>>add
^ prod , $+ asParser trim , term
ExpressionGrammar>>prod
^ mul / prim
ExpressionGrammar>>mul
^ prim , $*
asParser trim , prod
ExpressionGrammar>>prim
^ parens / number
ExpressionGrammar>>parens
^ $( asParser trim , term , $) asParser trim

is not a code to evaluate in a workspace.
It the representation we use to express the implementation of a method
By example

ExpressionGrammar>>term
^ add / prod

means that on class ExpressionGrammar, you need to add a method named term with source code
^ add / prod


So, you can either use a method browser to do it, or programatically do it by doing:

ExpressionGrammar compile: 'term
^ add / prod'

But this method is a bit ad hoc.

:)
Hope it helps ;)

Ben

On Mar 13, 2013, at 8:56 PM, Mohammad Al Houssami (Alumni) <[hidden email]> wrote:

Hello Everyone
 
I was going over PetitParser part on the pharo by example book. http://pharobooks.gforge.inria.fr/PharoByExampleTwo-Eng/latest/PetitParser.pdf
 
It was all going good until page 11.
Script 1.19is for creating the class so this was fine. You get an ExpressionGrammar class with all the needed variables, but what about script 1.20?
 
Where does this script go? I understand what the code does. It is describing a grammar for mathematical expressions by defining what everything is and the rules of the grammar. I am not sure where shall I put this script to run it. In earlier examples I was using the workspace.
 
Any help is much appreciated.
Mohammad
 

Reply | Threaded
Open this post in threaded view
|

Re: PetitParser Help

Mohammad Al Houssami (Alumni)
<base href="x-msg://97/">

Thank You Benjamin,

There was no way I would figure that out on my own… its weird to represent it this way but its clear now.(Probably because im new to Smalltalk though)

Thanks again
J

Mohammad

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Benjamin
Sent: Wednesday, March 13, 2013 8:58 PM
To: A friendly place where any question about pharo is welcome
Subject: Re: [Pharo-users] PetitParser Help

 

This code

ExpressionGrammar>>term

^ add / prod

ExpressionGrammar>>add

^ prod , $+ asParser trim , term

ExpressionGrammar>>prod

^ mul / prim

ExpressionGrammar>>mul

^ prim , $*

asParser trim , prod

ExpressionGrammar>>prim

^ parens / number

ExpressionGrammar>>parens

^ $( asParser trim , term , $) asParser trim

 

is not a code to evaluate in a workspace.

It the representation we use to express the implementation of a method

By example

 

ExpressionGrammar>>term

^ add / prod

 

means that on class ExpressionGrammar, you need to add a method named term with source code

^ add / prod

 

 

So, you can either use a method browser to do it, or programatically do it by doing:

 

ExpressionGrammar compile: 'term

^ add / prod'

 

But this method is a bit ad hoc.

 

:)

Hope it helps ;)


Ben

 

On Mar 13, 2013, at 8:56 PM, Mohammad Al Houssami (Alumni) <[hidden email]> wrote:



Hello Everyone

 

I was going over PetitParser part on the pharo by example book. http://pharobooks.gforge.inria.fr/PharoByExampleTwo-Eng/latest/PetitParser.pdf

 

It was all going good until page 11.

Script 1.19is for creating the class so this was fine. You get an ExpressionGrammar class with all the needed variables, but what about script 1.20?

 

Where does this script go? I understand what the code does. It is describing a grammar for mathematical expressions by defining what everything is and the rules of the grammar. I am not sure where shall I put this script to run it. In earlier examples I was using the workspace.

 

Any help is much appreciated.

Mohammad

 

 


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.2904 / Virus Database: 2641/6169 - Release Date: 03/13/13

Reply | Threaded
Open this post in threaded view
|

Re: PetitParser Help

Alain Busser
Personnally, I found the browser very useful, so read on until you come to the marvels of

PPBrowser new

Your life will never be the same after that...

On Thu, Mar 14, 2013 at 3:20 AM, Mohammad Al Houssami (Alumni) <[hidden email]> wrote:

Thank You Benjamin,

There was no way I would figure that out on my own… its weird to represent it this way but its clear now.(Probably because im new to Smalltalk though)

Thanks again
J

Mohammad

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Benjamin
Sent: Wednesday, March 13, 2013 8:58 PM
To: A friendly place where any question about pharo is welcome
Subject: Re: [Pharo-users] PetitParser Help

 

This code

ExpressionGrammar>>term

^ add / prod

ExpressionGrammar>>add

^ prod , $+ asParser trim , term

ExpressionGrammar>>prod

^ mul / prim

ExpressionGrammar>>mul

^ prim , $*

asParser trim , prod

ExpressionGrammar>>prim

^ parens / number

ExpressionGrammar>>parens

^ $( asParser trim , term , $) asParser trim

 

is not a code to evaluate in a workspace.

It the representation we use to express the implementation of a method

By example

 

ExpressionGrammar>>term

^ add / prod

 

means that on class ExpressionGrammar, you need to add a method named term with source code

^ add / prod

 

 

So, you can either use a method browser to do it, or programatically do it by doing:

 

ExpressionGrammar compile: 'term

^ add / prod'

 

But this method is a bit ad hoc.

 

:)

Hope it helps ;)


Ben

 

On Mar 13, 2013, at 8:56 PM, Mohammad Al Houssami (Alumni) <[hidden email]> wrote:



Hello Everyone

 

I was going over PetitParser part on the pharo by example book. http://pharobooks.gforge.inria.fr/PharoByExampleTwo-Eng/latest/PetitParser.pdf

 

It was all going good until page 11.

Script 1.19is for creating the class so this was fine. You get an ExpressionGrammar class with all the needed variables, but what about script 1.20?

 

Where does this script go? I understand what the code does. It is describing a grammar for mathematical expressions by defining what everything is and the rules of the grammar. I am not sure where shall I put this script to run it. In earlier examples I was using the workspace.

 

Any help is much appreciated.

Mohammad

 

 


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.2904 / Virus Database: 2641/6169 - Release Date: 03/13/13


Reply | Threaded
Open this post in threaded view
|

Re: PetitParser Help

Mohammad Al Houssami (Alumni)

I am not sure what you mean Alain. Using the system browser to read what ?

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Alain Busser
Sent: Thursday, March 14, 2013 5:42 AM
To: A friendly place where any question about pharo is welcome
Subject: Re: [Pharo-users] PetitParser Help

 

Personnally, I found the browser very useful, so read on until you come to the marvels of

PPBrowser new

Your life will never be the same after that...

On Thu, Mar 14, 2013 at 3:20 AM, Mohammad Al Houssami (Alumni) <[hidden email]> wrote:

Thank You Benjamin,

There was no way I would figure that out on my own… its weird to represent it this way but its clear now.(Probably because im new to Smalltalk though)

Thanks again
J

Mohammad

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Benjamin
Sent: Wednesday, March 13, 2013 8:58 PM
To: A friendly place where any question about pharo is welcome
Subject: Re: [Pharo-users] PetitParser Help

 

This code

ExpressionGrammar>>term

^ add / prod

ExpressionGrammar>>add

^ prod , $+ asParser trim , term

ExpressionGrammar>>prod

^ mul / prim

ExpressionGrammar>>mul

^ prim , $*

asParser trim , prod

ExpressionGrammar>>prim

^ parens / number

ExpressionGrammar>>parens

^ $( asParser trim , term , $) asParser trim

 

is not a code to evaluate in a workspace.

It the representation we use to express the implementation of a method

By example

 

ExpressionGrammar>>term

^ add / prod

 

means that on class ExpressionGrammar, you need to add a method named term with source code

^ add / prod

 

 

So, you can either use a method browser to do it, or programatically do it by doing:

 

ExpressionGrammar compile: 'term

^ add / prod'

 

But this method is a bit ad hoc.

 

:)

Hope it helps ;)


Ben

 

On Mar 13, 2013, at 8:56 PM, Mohammad Al Houssami (Alumni) <[hidden email]> wrote:

 

Hello Everyone

 

I was going over PetitParser part on the pharo by example book. http://pharobooks.gforge.inria.fr/PharoByExampleTwo-Eng/latest/PetitParser.pdf

 

It was all going good until page 11.

Script 1.19is for creating the class so this was fine. You get an ExpressionGrammar class with all the needed variables, but what about script 1.20?

 

Where does this script go? I understand what the code does. It is describing a grammar for mathematical expressions by defining what everything is and the rules of the grammar. I am not sure where shall I put this script to run it. In earlier examples I was using the workspace.

 

Any help is much appreciated.

Mohammad

 

 


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.2904 / Virus Database: 2641/6169 - Release Date: 03/13/13

 


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.2904 / Virus Database: 2641/6172 - Release Date: 03/13/13

Reply | Threaded
Open this post in threaded view
|

Re: PetitParser Help

Alain Busser
No, not the *system* browser, PetitParser has its own browser:

In a workspace, just write

PPBrowser new

then "DoIt", and a PetitParser browser opens: It is a very beautiful tool, and powerful at that! Especially there is a graphical version which shows your grammar...

On Thu, Mar 14, 2013 at 5:53 PM, Mohammad Al Houssami (Alumni) <[hidden email]> wrote:

I am not sure what you mean Alain. Using the system browser to read what ?

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Alain Busser
Sent: Thursday, March 14, 2013 5:42 AM


To: A friendly place where any question about pharo is welcome
Subject: Re: [Pharo-users] PetitParser Help

 

Personnally, I found the browser very useful, so read on until you come to the marvels of

PPBrowser new

Your life will never be the same after that...

On Thu, Mar 14, 2013 at 3:20 AM, Mohammad Al Houssami (Alumni) <[hidden email]> wrote:

Thank You Benjamin,

There was no way I would figure that out on my own… its weird to represent it this way but its clear now.(Probably because im new to Smalltalk though)

Thanks again
J

Mohammad

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Benjamin
Sent: Wednesday, March 13, 2013 8:58 PM
To: A friendly place where any question about pharo is welcome
Subject: Re: [Pharo-users] PetitParser Help

 

This code

ExpressionGrammar>>term

^ add / prod

ExpressionGrammar>>add

^ prod , $+ asParser trim , term

ExpressionGrammar>>prod

^ mul / prim

ExpressionGrammar>>mul

^ prim , $*

asParser trim , prod

ExpressionGrammar>>prim

^ parens / number

ExpressionGrammar>>parens

^ $( asParser trim , term , $) asParser trim

 

is not a code to evaluate in a workspace.

It the representation we use to express the implementation of a method

By example

 

ExpressionGrammar>>term

^ add / prod

 

means that on class ExpressionGrammar, you need to add a method named term with source code

^ add / prod

 

 

So, you can either use a method browser to do it, or programatically do it by doing:

 

ExpressionGrammar compile: 'term

^ add / prod'

 

But this method is a bit ad hoc.

 

:)

Hope it helps ;)


Ben

 

On Mar 13, 2013, at 8:56 PM, Mohammad Al Houssami (Alumni) <[hidden email]> wrote:

 

Hello Everyone

 

I was going over PetitParser part on the pharo by example book. http://pharobooks.gforge.inria.fr/PharoByExampleTwo-Eng/latest/PetitParser.pdf

 

It was all going good until page 11.

Script 1.19is for creating the class so this was fine. You get an ExpressionGrammar class with all the needed variables, but what about script 1.20?

 

Where does this script go? I understand what the code does. It is describing a grammar for mathematical expressions by defining what everything is and the rules of the grammar. I am not sure where shall I put this script to run it. In earlier examples I was using the workspace.

 

Any help is much appreciated.

Mohammad

 

 


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.2904 / Virus Database: 2641/6169 - Release Date: 03/13/13

 


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.2904 / Virus Database: 2641/6172 - Release Date: 03/13/13


Reply | Threaded
Open this post in threaded view
|

Re: PetitParser Help

Mohammad Al Houssami (Alumni)

Oh okay I didn’t know that. Thanks for the information.

I tried that but nothing happened.

Any ideas why this might be the case?

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Alain Busser
Sent: Thursday, March 14, 2013 3:07 PM
To: A friendly place where any question about pharo is welcome
Subject: Re: [Pharo-users] PetitParser Help

 

No, not the *system* browser, PetitParser has its own browser:

In a workspace, just write

PPBrowser new

then "DoIt", and a PetitParser browser opens: It is a very beautiful tool, and powerful at that! Especially there is a graphical version which shows your grammar...

On Thu, Mar 14, 2013 at 5:53 PM, Mohammad Al Houssami (Alumni) <[hidden email]> wrote:

I am not sure what you mean Alain. Using the system browser to read what ?

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Alain Busser
Sent: Thursday, March 14, 2013 5:42 AM


To: A friendly place where any question about pharo is welcome
Subject: Re: [Pharo-users] PetitParser Help

 

Personnally, I found the browser very useful, so read on until you come to the marvels of

PPBrowser new

Your life will never be the same after that...

On Thu, Mar 14, 2013 at 3:20 AM, Mohammad Al Houssami (Alumni) <[hidden email]> wrote:

Thank You Benjamin,

There was no way I would figure that out on my own… its weird to represent it this way but its clear now.(Probably because im new to Smalltalk though)

Thanks again
J

Mohammad

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Benjamin
Sent: Wednesday, March 13, 2013 8:58 PM
To: A friendly place where any question about pharo is welcome
Subject: Re: [Pharo-users] PetitParser Help

 

This code

ExpressionGrammar>>term

^ add / prod

ExpressionGrammar>>add

^ prod , $+ asParser trim , term

ExpressionGrammar>>prod

^ mul / prim

ExpressionGrammar>>mul

^ prim , $*

asParser trim , prod

ExpressionGrammar>>prim

^ parens / number

ExpressionGrammar>>parens

^ $( asParser trim , term , $) asParser trim

 

is not a code to evaluate in a workspace.

It the representation we use to express the implementation of a method

By example

 

ExpressionGrammar>>term

^ add / prod

 

means that on class ExpressionGrammar, you need to add a method named term with source code

^ add / prod

 

 

So, you can either use a method browser to do it, or programatically do it by doing:

 

ExpressionGrammar compile: 'term

^ add / prod'

 

But this method is a bit ad hoc.

 

:)

Hope it helps ;)


Ben

 

On Mar 13, 2013, at 8:56 PM, Mohammad Al Houssami (Alumni) <[hidden email]> wrote:

 

Hello Everyone

 

I was going over PetitParser part on the pharo by example book. http://pharobooks.gforge.inria.fr/PharoByExampleTwo-Eng/latest/PetitParser.pdf

 

It was all going good until page 11.

Script 1.19is for creating the class so this was fine. You get an ExpressionGrammar class with all the needed variables, but what about script 1.20?

 

Where does this script go? I understand what the code does. It is describing a grammar for mathematical expressions by defining what everything is and the rules of the grammar. I am not sure where shall I put this script to run it. In earlier examples I was using the workspace.

 

Any help is much appreciated.

Mohammad

 

 


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.2904 / Virus Database: 2641/6169 - Release Date: 03/13/13

 


No virus found in this message.
Checked by AVG - www.avg.com

Version: 2013.0.2904 / Virus Database: 2641/6172 - Release Date: 03/13/13

 


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.2904 / Virus Database: 2641/6172 - Release Date: 03/13/13

Reply | Threaded
Open this post in threaded view
|

Re: PetitParser Help

Alain Busser


On Thu, Mar 14, 2013 at 7:24 PM, Mohammad Al Houssami (Alumni) <[hidden email]> wrote:

Oh okay I didn’t know that. Thanks for the information.

I tried that but nothing happened.

Any ideas why this might be the case?


Maybe your download is incomplete?

I did exactly what is in the PBE2 chapter, and it took a rather long time to complete the downloads...

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Alain Busser
Sent: Thursday, March 14, 2013 3:07 PM


To: A friendly place where any question about pharo is welcome
Subject: Re: [Pharo-users] PetitParser Help

 

No, not the *system* browser, PetitParser has its own browser:

In a workspace, just write

PPBrowser new

then "DoIt", and a PetitParser browser opens: It is a very beautiful tool, and powerful at that! Especially there is a graphical version which shows your grammar...

On Thu, Mar 14, 2013 at 5:53 PM, Mohammad Al Houssami (Alumni) <[hidden email]> wrote:

I am not sure what you mean Alain. Using the system browser to read what ?

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Alain Busser
Sent: Thursday, March 14, 2013 5:42 AM


To: A friendly place where any question about pharo is welcome
Subject: Re: [Pharo-users] PetitParser Help

 

Personnally, I found the browser very useful, so read on until you come to the marvels of

PPBrowser new

Your life will never be the same after that...

On Thu, Mar 14, 2013 at 3:20 AM, Mohammad Al Houssami (Alumni) <[hidden email]> wrote:

Thank You Benjamin,

There was no way I would figure that out on my own… its weird to represent it this way but its clear now.(Probably because im new to Smalltalk though)

Thanks again
J

Mohammad

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Benjamin
Sent: Wednesday, March 13, 2013 8:58 PM
To: A friendly place where any question about pharo is welcome
Subject: Re: [Pharo-users] PetitParser Help

 

This code

ExpressionGrammar>>term

^ add / prod

ExpressionGrammar>>add

^ prod , $+ asParser trim , term

ExpressionGrammar>>prod

^ mul / prim

ExpressionGrammar>>mul

^ prim , $*

asParser trim , prod

ExpressionGrammar>>prim

^ parens / number

ExpressionGrammar>>parens

^ $( asParser trim , term , $) asParser trim

 

is not a code to evaluate in a workspace.

It the representation we use to express the implementation of a method

By example

 

ExpressionGrammar>>term

^ add / prod

 

means that on class ExpressionGrammar, you need to add a method named term with source code

^ add / prod

 

 

So, you can either use a method browser to do it, or programatically do it by doing:

 

ExpressionGrammar compile: 'term

^ add / prod'

 

But this method is a bit ad hoc.

 

:)

Hope it helps ;)


Ben

 

On Mar 13, 2013, at 8:56 PM, Mohammad Al Houssami (Alumni) <[hidden email]> wrote:

 

Hello Everyone

 

I was going over PetitParser part on the pharo by example book. http://pharobooks.gforge.inria.fr/PharoByExampleTwo-Eng/latest/PetitParser.pdf

 

It was all going good until page 11.

Script 1.19is for creating the class so this was fine. You get an ExpressionGrammar class with all the needed variables, but what about script 1.20?

 

Where does this script go? I understand what the code does. It is describing a grammar for mathematical expressions by defining what everything is and the rules of the grammar. I am not sure where shall I put this script to run it. In earlier examples I was using the workspace.

 

Any help is much appreciated.

Mohammad

 

 


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.2904 / Virus Database: 2641/6169 - Release Date: 03/13/13

 


No virus found in this message.
Checked by AVG - www.avg.com

Version: 2013.0.2904 / Virus Database: 2641/6172 - Release Date: 03/13/13

 


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.2904 / Virus Database: 2641/6172 - Release Date: 03/13/13