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) <mh...@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 >