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: pharo-users-bounces@lists.gforge.inria.fr [mailto:pharo-users-bounces@lists.gforge.inria.fr] 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) <mha53@mail.aub.edu> 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