[Newbies] How to know where a BlockClosure finish

Mathieu mathk.sue at gmail.com
Mon Aug 28 11:33:50 UTC 2006


Marcus Denker a écrit :
>>
>> Yes you are right
>>
>> In the script I have 2 kind of things:
>> [
>> some Smalltalk
>> ]
>>
>> And:
>>
>> Class selector
>> [
>> some smalltalk
>> ]
>>
>> So my idea was to call Compiler>>#evaluate:in:to:notifying:ifFail:logged:
>> on the string inside the [] for the first things.
>>
> 
> Hi Mathieu,
> 
> I would go for a "complete" compiler for this... so let's explain a bit.
> (Hmm,
> Compilers, Parsers, Code Generation. Perfect Newby topics :-)
> 
> So: If we look at the new compiler in Squeak, it works on single
> methods. For
> each method, it does
>     - Scann / Parse to build up a Tree of objects that describe the code
>       The root of the tree is RBProgramNode. (other node are e.g.
> RBSendNode,
>       RBVariableNode... things like that).
>     - Analyze the names of variables. The AST only known that "a" is a
> name... but it
>       does not know what it means.. so is this a definition of a temp? Or
>       a use of an existing temp? Or an iVar?. This analysis is done in the
>       class ASTChecker
>     - Code Generation. The analyzed AST is visited by the ASTTranslator
>       to build a CompiledMethod obiect (using IRBuilder). This then is
> installed
>           in a class.
> 
> Ok. So for your Scripting system I would do the same:
> 
> 1) Scann/Parse the input, build up a Tree
> 2) Analyse the tree (name analysis)
> 3) generate all the needed elements (methods, classes)
> 4) run.
> 
> 1) Scann/Parse.
> 
> Just re-use the existing Parser, extend the grammar to not parse one
> method, but a whole Script. The root-node of the AST would then be
> some "SqueakScriptNode". This has nodes for all classes that the
> script defined, and nodes for all methods (these will be normal
> RBMethodNodes).
> Then it has the code of the script that starts the whole thing as a special
> method (named #run).
> 
> Keep in mind that this Tree-Representation of the Script has not yet added
> any methods or classes to the system.
> 
> 2) Analyse. The RBMethodNodes needs to have the ASTChecker run so
>      all variables are bound correctly.
>     This pass could do other analysis things, if needed (don't know any)
> 

In Parser2>>#parse:class:noPattern:notifying:ifFail: I saw:

[tree verifyIn: scope] on: SemanticWarning do: [:ex | ex correctIn: self]

When do SemanticWarning are throw?

In the script context do we need to call #correctIn:
Or what #correctIn: serve for?

Thanks
Math


More information about the Beginners mailing list