Hello,
I want to use SmaccParser with my Expert System. I want to parse a String of the form : (A&B)->C and/or A->C and/or ((A&B)|C)->D I created a suclass of SmaccParser and SmaccScanner but I don't know to utilise SmaCC. If you could help me to understand and use theses classes. Thanks for your request. Sébastien Aubry. |
??
I do not understand. Did you try to open the SmaCC editor ? If no, try World menu/open. It also includes a tutorial. cheers, Alexandre Am May 18, 2006 um 3:18 PM schrieb Sebastien Aubry: > Hello, > > I want to use SmaccParser with my Expert System. I want to parse a > String of the form : (A&B)->C and/or A->C and/or ((A&B)|C)->D > > I created a suclass of SmaccParser and SmaccScanner but I don't > know to utilise SmaCC. If you could help me to understand and use > theses classes. > > Thanks for your request. > Sébastien Aubry. > -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.cs.tcd.ie/Alexandre.Bergel ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. |
In reply to this post by Sebastien Aubry-2
If you don't have any menu entry for "Smacc Parser Generator" in your
"World Menu", download "SmaccDev" (for Squeak 3.9>=) or "Smacc Development" (for Squeak <=3.8) from SqueakMap and use the generator to create your "scanner" and "parser" definitions - no need to create them by hand ;) - Smacc will create the scanner and parser classes for you. The generator-ui provides a simple help/tutorial on using Smacc ... and there are a several example-definitions available. Cheers Stef On 18.05.2006, at 16:18, Sebastien Aubry wrote: > Hello, > > I want to use SmaccParser with my Expert System. I want to parse a > String of the form : (A&B)->C and/or A->C and/or ((A&B)|C)->D > > I created a suclass of SmaccParser and SmaccScanner but I don't > know to utilise SmaCC. If you could help me to understand and use > theses classes. > > Thanks for your request. > Sébastien Aubry. > __________________________ http://www.reichhart.freezope.org |
In reply to this post by Sebastien Aubry-2
Let me try and re-ask this question. (Maybe this is Sebastien's
problem, maybe not). It's certainly mine ;-) I've downloaded SmaCC from Squeakmap. I've gone through the calculator tutorial (very nice) and generated a scanner and parser (two classes, CalculatorScanner and CalulatorParser). There are also nice examples StScanner and StParser. I can run them in the UI tool. So far, so good. I am completely at a loss to know how to use the Scanner and the Parser from other code. I remember having the same problem with TGen years ago, and eventually giving up. The generated code has no obvious entry point ... I tried STParser parseMethod: sourceString and got an immediate walkback. The answer is probably obvious when you know, but it is decidedly NON-obvious when you don't. Can someone help? Better still, can someone put this information in the documentation. Andrew On 18 May 2006, at 07:18, Sebastien Aubry wrote: > Hello, > > I want to use SmaccParser with my Expert System. I want to parse a > String of the form : (A&B)->C and/or A->C and/or ((A&B)|C)->D > > I created a suclass of SmaccParser and SmaccScanner but I don't > know to utilise SmaCC. If you could help me to understand and use > theses classes. > > Thanks for your request. > Sébastien Aubry. > |
On 26.05.2006, at 02:58, Andrew P. Black wrote: > Let me try and re-ask this question. (Maybe this is Sebastien's > problem, maybe not). It's certainly mine ;-) > > I've downloaded SmaCC from Squeakmap. I've gone through the > calculator tutorial (very nice) and generated a scanner and parser > (two classes, CalculatorScanner and CalulatorParser). There are > also nice examples StScanner and StParser. I can run them in the > UI tool. So far, so good. > > I am completely at a loss to know how to use the Scanner and the > Parser from other code. I remember having the same problem with > TGen years ago, and eventually giving up. The generated code has > no obvious entry point ... > > I tried STParser parseMethod: sourceString and got an immediate > walkback. The answer is probably obvious when you know, but it is > decidedly NON-obvious when you don't. Can someone help? Better > still, can someone put this information in the documentation. > the SmaCCParser superclass provides the method #parseStream:startingAt: First parameter is the stream to parse, second the starting state of the parser. SmaCC generates accessors for the possible starting states automatically (see method category 'generate starting states') For the SqueakParser (part of NewCompiler), this method was implemented to make it easy to use from other code: parseMethod: stringOrStream ^ (self parseStream: stringOrStream readStream startingAt: self startingStateForMethod) source: stringOrStream contents Thus, SqueakParser parseMethod: 'hello ^1' will give you an RB AST. For experiments, do not use the STParser. It's kind of broken *and* it just generates a parse tree, which is not what's needed in most cases. The SqueakParser (part of NewCompiler) can actually parse the whole image *and* it directly generates an RB AST. Marcus |
In reply to this post by Prof. Andrew P. Black
Hi,
> I am completely at a loss to know how to use the Scanner and the > Parser from other code. I remember having the same problem with TGen > years ago, and eventually giving up. The generated code has no > obvious entry point ... Take a look at Magma + Lava. Lava has a Smacc compiler for SQL. It uses the resulting parser in normal Smalltalk code. Brent |
In reply to this post by Marcus Denker
Marcus
is the parseMethod: or equivalent now in the Smacc package? Because it seems useful. Stef > the SmaCCParser superclass provides the method > #parseStream:startingAt: > > First parameter is the stream to parse, second the starting state > of the parser. SmaCC > generates accessors for the possible starting states automatically > (see method category > 'generate starting states') > > For the SqueakParser (part of NewCompiler), this method was > implemented to make it > easy to use from other code: > > parseMethod: stringOrStream > > ^ (self > parseStream: stringOrStream readStream > startingAt: self startingStateForMethod) > source: stringOrStream contents > > Thus, > > SqueakParser parseMethod: 'hello ^1' > > will give you an RB AST. > > For experiments, do not use the STParser. It's kind of broken *and* > it just > generates a parse tree, which is not what's needed in most cases. The > SqueakParser (part of NewCompiler) can actually parse the whole image > *and* it directly generates an RB AST. > > Marcus > > > |
On 26.05.2006, at 22:26, stéphane ducasse wrote: > Marcus > > is the parseMethod: or equivalent now in the Smacc package? > Because it seems useful. > I makes no sense to have that in the Smacc package, as it is specific to the Smalltalk grammar and even the parser (it calls a method on the resulting object). Marcus |
Ok I thought that it was an helper method of Smacc.
What I wanted to say is that how can we capitalize so that people get into Smacc in a easier way. >> Marcus >> >> is the parseMethod: or equivalent now in the Smacc package? >> Because it seems useful. >> > > > I makes no sense to have that in the Smacc package, as it is > specific to the Smalltalk grammar and even the parser > (it calls a method on the resulting object). > > Marcus > > |
Free forum by Nabble | Edit this page |