About validating the result of RBParser >> parseMethod:

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

About validating the result of RBParser >> parseMethod:

Fernando olivero
I have a question about validating a methodNode, suppose we have the following:

parsedNode :=  RBParser parseMethod: 'test ^ self add: anUnbindedVariable'.

Is there a way of checking the health/validity of the parsedNode?

I couldn't find any behavior in RBMethodNode or related classes.

Lukas, do you have an idea is i could run any Lint rule?

My idea is to provide a method editor morph, that prevents from accepting invalid sources, and informs the user any problems detected with the edited code.

Thanks,
Fernando


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About validating the result of RBParser >> parseMethod:

Lukas Renggli
You can use #parseMethod:onError: to check for syntactical errors.

Semantical errors are harder to detect, some of them (e.g. undeclared
variables) you can find using AST-Semantics.

Lukas

On 23 July 2010 00:35, Fernando olivero <[hidden email]> wrote:

> I have a question about validating a methodNode, suppose we have the following:
>
> parsedNode :=  RBParser parseMethod: 'test ^ self add: anUnbindedVariable'.
>
> Is there a way of checking the health/validity of the parsedNode?
>
> I couldn't find any behavior in RBMethodNode or related classes.
>
> Lukas, do you have an idea is i could run any Lint rule?
>
> My idea is to provide a method editor morph, that prevents from accepting invalid sources, and informs the user any problems detected with the edited code.
>
> Thanks,
> Fernando
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Lukas Renggli
www.lukas-renggli.ch

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About validating the result of RBParser >> parseMethod:

Fernando olivero
Lukas, thanks for the answer. I will see if AST-Semantics solves my problem.

I also tried using the Compiler and the parser, and faking a notifier. But the Compiler>>interactive behavior is hard to override,
it always gives me visual feedback ( pop menus and related dialogs). Maybe the newCompiler is more customizable?

Fernando


On Jul 23, 2010, at 7:34 AM, Lukas Renggli wrote:

> You can use #parseMethod:onError: to check for syntactical errors.
>
> Semantical errors are harder to detect, some of them (e.g. undeclared
> variables) you can find using AST-Semantics.
>
> Lukas
>
> On 23 July 2010 00:35, Fernando olivero <[hidden email]> wrote:
>> I have a question about validating a methodNode, suppose we have the following:
>>
>> parsedNode :=  RBParser parseMethod: 'test ^ self add: anUnbindedVariable'.
>>
>> Is there a way of checking the health/validity of the parsedNode?
>>
>> I couldn't find any behavior in RBMethodNode or related classes.
>>
>> Lukas, do you have an idea is i could run any Lint rule?
>>
>> My idea is to provide a method editor morph, that prevents from accepting invalid sources, and informs the user any problems detected with the edited code.
>>
>> Thanks,
>> Fernando
>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>
>
>
> --
> Lukas Renggli
> www.lukas-renggli.ch
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About validating the result of RBParser >> parseMethod:

Fernando olivero
Thanks for the pointers Lukas,

Works now!

>>canSuccesfullyParse: aSource in: aClass
        [ parsedNode := RBParser parseMethod: aSource onError: [:descrip :position| evaluation := false. errorDescription := descrip. errorPosition := position ] ] on: Error do:[:err|  ].
        parsedNode annotateInClass: aClass.
        hasUndeclared := parsedNode allChildren select:[:each| each isVariable and:[ each variableBinding isUndeclaredBinding  ]] .
        hasUndeclared ifTrue:[ self .... ].


On Jul 23, 2010, at 11:46 AM, Fernando olivero wrote:

> Lukas, thanks for the answer. I will see if AST-Semantics solves my problem.
>
> I also tried using the Compiler and the parser, and faking a notifier. But the Compiler>>interactive behavior is hard to override,
> it always gives me visual feedback ( pop menus and related dialogs). Maybe the newCompiler is more customizable?
>
> Fernando
>
>
> On Jul 23, 2010, at 7:34 AM, Lukas Renggli wrote:
>
>> You can use #parseMethod:onError: to check for syntactical errors.
>>
>> Semantical errors are harder to detect, some of them (e.g. undeclared
>> variables) you can find using AST-Semantics.
>>
>> Lukas
>>
>> On 23 July 2010 00:35, Fernando olivero <[hidden email]> wrote:
>>> I have a question about validating a methodNode, suppose we have the following:
>>>
>>> parsedNode :=  RBParser parseMethod: 'test ^ self add: anUnbindedVariable'.
>>>
>>> Is there a way of checking the health/validity of the parsedNode?
>>>
>>> I couldn't find any behavior in RBMethodNode or related classes.
>>>
>>> Lukas, do you have an idea is i could run any Lint rule?
>>>
>>> My idea is to provide a method editor morph, that prevents from accepting invalid sources, and informs the user any problems detected with the edited code.
>>>
>>> Thanks,
>>> Fernando
>>>
>>>
>>> _______________________________________________
>>> Pharo-project mailing list
>>> [hidden email]
>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>>
>>
>>
>>
>> --
>> Lukas Renggli
>> www.lukas-renggli.ch
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About validating the result of RBParser >> parseMethod:

Lukas Renggli
In reply to this post by Fernando olivero
Unfortunately the NewCompiler doesn't work yet.

On 23 July 2010 11:46, Fernando olivero <[hidden email]> wrote:

> Lukas, thanks for the answer. I will see if AST-Semantics solves my problem.
>
> I also tried using the Compiler and the parser, and faking a notifier. But the Compiler>>interactive behavior is hard to override,
> it always gives me visual feedback ( pop menus and related dialogs). Maybe the newCompiler is more customizable?
>
> Fernando
>
>
> On Jul 23, 2010, at 7:34 AM, Lukas Renggli wrote:
>
>> You can use #parseMethod:onError: to check for syntactical errors.
>>
>> Semantical errors are harder to detect, some of them (e.g. undeclared
>> variables) you can find using AST-Semantics.
>>
>> Lukas
>>
>> On 23 July 2010 00:35, Fernando olivero <[hidden email]> wrote:
>>> I have a question about validating a methodNode, suppose we have the following:
>>>
>>> parsedNode :=  RBParser parseMethod: 'test ^ self add: anUnbindedVariable'.
>>>
>>> Is there a way of checking the health/validity of the parsedNode?
>>>
>>> I couldn't find any behavior in RBMethodNode or related classes.
>>>
>>> Lukas, do you have an idea is i could run any Lint rule?
>>>
>>> My idea is to provide a method editor morph, that prevents from accepting invalid sources, and informs the user any problems detected with the edited code.
>>>
>>> Thanks,
>>> Fernando
>>>
>>>
>>> _______________________________________________
>>> Pharo-project mailing list
>>> [hidden email]
>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>>
>>
>>
>>
>> --
>> Lukas Renggli
>> www.lukas-renggli.ch
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Lukas Renggli
www.lukas-renggli.ch

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About validating the result of RBParser >> parseMethod:

Lukas Renggli
In reply to this post by Fernando olivero
On 23 July 2010 11:58, Fernando olivero <[hidden email]> wrote:
> Thanks for the pointers Lukas,
>
> Works now!
>
>>>canSuccesfullyParse: aSource in: aClass
>        [ parsedNode := RBParser parseMethod: aSource onError: [:descrip :position| evaluation := false. errorDescription := descrip. errorPosition := position ] ] on: Error do:[:err|  ].
>        parsedNode annotateInClass: aClass.
>        hasUndeclared := parsedNode allChildren select:[:each| each isVariable and:[ each variableBinding isUndeclaredBinding  ]] .
>        hasUndeclared ifTrue:[ self .... ].

Yep, something like that. You shouldn't need the Error handler,
otherwise that would be a bug in the RBParser.

Also you might want to check for shadowed variables (#isShadowed),
because they cause the compiler to complain.

Lukas

--
Lukas Renggli
www.lukas-renggli.ch

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About validating the result of RBParser >> parseMethod:

Eliot Miranda-2
In reply to this post by Fernando olivero
Hi Fernando,

On Fri, Jul 23, 2010 at 2:46 AM, Fernando olivero <[hidden email]> wrote:
Lukas, thanks for the answer. I will see if AST-Semantics solves my problem.

I also tried using the Compiler and the parser, and faking a notifier. But the Compiler>>interactive behavior is hard to override,
it always gives me visual feedback ( pop menus and related dialogs).

Colin Putney has done good work replacing a number of interactive errors with exceptions whose defaultAction is to produce the notifier.  These are in Squeak 4.1.  Have you taken a look at the trunk 4.1 compiler?  Clearly the standard compiler should be able to do what you want.  We should fix it :)

best
Eliot
 
Maybe the newCompiler is more customizable?

Fernando


On Jul 23, 2010, at 7:34 AM, Lukas Renggli wrote:

> You can use #parseMethod:onError: to check for syntactical errors.
>
> Semantical errors are harder to detect, some of them (e.g. undeclared
> variables) you can find using AST-Semantics.
>
> Lukas
>
> On 23 July 2010 00:35, Fernando olivero <[hidden email]> wrote:
>> I have a question about validating a methodNode, suppose we have the following:
>>
>> parsedNode :=  RBParser parseMethod: 'test ^ self add: anUnbindedVariable'.
>>
>> Is there a way of checking the health/validity of the parsedNode?
>>
>> I couldn't find any behavior in RBMethodNode or related classes.
>>
>> Lukas, do you have an idea is i could run any Lint rule?
>>
>> My idea is to provide a method editor morph, that prevents from accepting invalid sources, and informs the user any problems detected with the edited code.
>>
>> Thanks,
>> Fernando
>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>
>
>
> --
> Lukas Renggli
> www.lukas-renggli.ch
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About validating the result of RBParser >> parseMethod:

Stéphane Ducasse
I thought I integrated those.
Fernando if you can check and let us know.

Stef

On Jul 23, 2010, at 6:48 PM, Eliot Miranda wrote:

> Hi Fernando,
>
> On Fri, Jul 23, 2010 at 2:46 AM, Fernando olivero <[hidden email]> wrote:
> Lukas, thanks for the answer. I will see if AST-Semantics solves my problem.
>
> I also tried using the Compiler and the parser, and faking a notifier. But the Compiler>>interactive behavior is hard to override,
> it always gives me visual feedback ( pop menus and related dialogs).
>
> Colin Putney has done good work replacing a number of interactive errors with exceptions whose defaultAction is to produce the notifier.  These are in Squeak 4.1.  Have you taken a look at the trunk 4.1 compiler?  Clearly the standard compiler should be able to do what you want.  We should fix it :)
>
> best
> Eliot
>  
> Maybe the newCompiler is more customizable?
>
> Fernando
>
>
> On Jul 23, 2010, at 7:34 AM, Lukas Renggli wrote:
>
> > You can use #parseMethod:onError: to check for syntactical errors.
> >
> > Semantical errors are harder to detect, some of them (e.g. undeclared
> > variables) you can find using AST-Semantics.
> >
> > Lukas
> >
> > On 23 July 2010 00:35, Fernando olivero <[hidden email]> wrote:
> >> I have a question about validating a methodNode, suppose we have the following:
> >>
> >> parsedNode :=  RBParser parseMethod: 'test ^ self add: anUnbindedVariable'.
> >>
> >> Is there a way of checking the health/validity of the parsedNode?
> >>
> >> I couldn't find any behavior in RBMethodNode or related classes.
> >>
> >> Lukas, do you have an idea is i could run any Lint rule?
> >>
> >> My idea is to provide a method editor morph, that prevents from accepting invalid sources, and informs the user any problems detected with the edited code.
> >>
> >> Thanks,
> >> Fernando
> >>
> >>
> >> _______________________________________________
> >> Pharo-project mailing list
> >> [hidden email]
> >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >>
> >
> >
> >
> > --
> > Lukas Renggli
> > www.lukas-renggli.ch
> >
> > _______________________________________________
> > Pharo-project mailing list
> > [hidden email]
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About validating the result of RBParser >> parseMethod:

Eliot Miranda-2
Hi Stéphane,

On Fri, Jul 23, 2010 at 10:12 AM, Stéphane Ducasse <[hidden email]> wrote:
I thought I integrated those.

My point was that while good work on non-interactive errors in the standard compiler has been done there's no guarantee its finished and we should check and make whatever modifications are required so that it all errors can be caught.

best
Eliot
 
Fernando if you can check and let us know.

Stef

On Jul 23, 2010, at 6:48 PM, Eliot Miranda wrote:

> Hi Fernando,
>
> On Fri, Jul 23, 2010 at 2:46 AM, Fernando olivero <[hidden email]> wrote:
> Lukas, thanks for the answer. I will see if AST-Semantics solves my problem.
>
> I also tried using the Compiler and the parser, and faking a notifier. But the Compiler>>interactive behavior is hard to override,
> it always gives me visual feedback ( pop menus and related dialogs).
>
> Colin Putney has done good work replacing a number of interactive errors with exceptions whose defaultAction is to produce the notifier.  These are in Squeak 4.1.  Have you taken a look at the trunk 4.1 compiler?  Clearly the standard compiler should be able to do what you want.  We should fix it :)
>
> best
> Eliot
>
> Maybe the newCompiler is more customizable?
>
> Fernando
>
>
> On Jul 23, 2010, at 7:34 AM, Lukas Renggli wrote:
>
> > You can use #parseMethod:onError: to check for syntactical errors.
> >
> > Semantical errors are harder to detect, some of them (e.g. undeclared
> > variables) you can find using AST-Semantics.
> >
> > Lukas
> >
> > On 23 July 2010 00:35, Fernando olivero <[hidden email]> wrote:
> >> I have a question about validating a methodNode, suppose we have the following:
> >>
> >> parsedNode :=  RBParser parseMethod: 'test ^ self add: anUnbindedVariable'.
> >>
> >> Is there a way of checking the health/validity of the parsedNode?
> >>
> >> I couldn't find any behavior in RBMethodNode or related classes.
> >>
> >> Lukas, do you have an idea is i could run any Lint rule?
> >>
> >> My idea is to provide a method editor morph, that prevents from accepting invalid sources, and informs the user any problems detected with the edited code.
> >>
> >> Thanks,
> >> Fernando
> >>
> >>
> >> _______________________________________________
> >> Pharo-project mailing list
> >> [hidden email]
> >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >>
> >
> >
> >
> > --
> > Lukas Renggli
> > www.lukas-renggli.ch
> >
> > _______________________________________________
> > Pharo-project mailing list
> > [hidden email]
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About validating the result of RBParser >> parseMethod:

Lukas Renggli
In reply to this post by Stéphane Ducasse
Yeah, these notifications are integrated in Pharo 1.0. OmniBrowser uses them.

Lukas

On 23 July 2010 19:12, Stéphane Ducasse <[hidden email]> wrote:

> I thought I integrated those.
> Fernando if you can check and let us know.
>
> Stef
>
> On Jul 23, 2010, at 6:48 PM, Eliot Miranda wrote:
>
>> Hi Fernando,
>>
>> On Fri, Jul 23, 2010 at 2:46 AM, Fernando olivero <[hidden email]> wrote:
>> Lukas, thanks for the answer. I will see if AST-Semantics solves my problem.
>>
>> I also tried using the Compiler and the parser, and faking a notifier. But the Compiler>>interactive behavior is hard to override,
>> it always gives me visual feedback ( pop menus and related dialogs).
>>
>> Colin Putney has done good work replacing a number of interactive errors with exceptions whose defaultAction is to produce the notifier.  These are in Squeak 4.1.  Have you taken a look at the trunk 4.1 compiler?  Clearly the standard compiler should be able to do what you want.  We should fix it :)
>>
>> best
>> Eliot
>>
>> Maybe the newCompiler is more customizable?
>>
>> Fernando
>>
>>
>> On Jul 23, 2010, at 7:34 AM, Lukas Renggli wrote:
>>
>> > You can use #parseMethod:onError: to check for syntactical errors.
>> >
>> > Semantical errors are harder to detect, some of them (e.g. undeclared
>> > variables) you can find using AST-Semantics.
>> >
>> > Lukas
>> >
>> > On 23 July 2010 00:35, Fernando olivero <[hidden email]> wrote:
>> >> I have a question about validating a methodNode, suppose we have the following:
>> >>
>> >> parsedNode :=  RBParser parseMethod: 'test ^ self add: anUnbindedVariable'.
>> >>
>> >> Is there a way of checking the health/validity of the parsedNode?
>> >>
>> >> I couldn't find any behavior in RBMethodNode or related classes.
>> >>
>> >> Lukas, do you have an idea is i could run any Lint rule?
>> >>
>> >> My idea is to provide a method editor morph, that prevents from accepting invalid sources, and informs the user any problems detected with the edited code.
>> >>
>> >> Thanks,
>> >> Fernando
>> >>
>> >>
>> >> _______________________________________________
>> >> Pharo-project mailing list
>> >> [hidden email]
>> >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>> >>
>> >
>> >
>> >
>> > --
>> > Lukas Renggli
>> > www.lukas-renggli.ch
>> >
>> > _______________________________________________
>> > Pharo-project mailing list
>> > [hidden email]
>> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Lukas Renggli
www.lukas-renggli.ch

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About validating the result of RBParser >> parseMethod:

Stéphane Ducasse
In reply to this post by Eliot Miranda-2
Ok ;)


> My point was that while good work on non-interactive errors in the standard compiler has been done there's no guarantee its finished and we should check and make whatever modifications are required so that it all errors can be caught.
>
> best
> Eliot
>  
> Fernando if you can check and let us know.


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project