Problem with amberc

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

Problem with amberc

Dave Mason-3
A few developers are working on the same code.  We're using mercurial as the VCS.  Currently we have the js directory in the repository, but merging js is painful and, frankly, stupid - it's like putting exe files in a repository!

It would be easy to put a hook in mercurial so that it would automatically run amberc on an update from the repository.  However, that doesn't work because amberc gives the following error:

Reading file st/Kit.st

/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:412
throw(error);
     ^
SyntaxError: Unexpected reserved word
    at smalltalk.addMethod.smalltalk.method.fn (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:18389:13)
    at withContextSend (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:426:18)
    at Smalltalk.st.send (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:403:11)
    at smalltalk.addMethod.smalltalk.method.fn (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:18426:21)
    at withContextSend (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:426:18)
    at Smalltalk.st.send (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:403:11)
    at smalltalk.addMethod.smalltalk.method.fn (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:6517:11)
    at withContextSend (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:426:18)
    at Smalltalk.st.send (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:403:11)
    at smalltalk.addMethod.smalltalk.method.fn (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:6556:18)
Failed compilation of Kit.js, exiting.

I presume this is my problem, not amber's, which is why I didn't file this as a bug.  I presume I have some reserved word, but am surprised that the browser-side compiler didn't see it (this st file has been developed from scratch on using amber)  I include Kit.st as an attachment.


../Dave

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Kit.st (39K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem with amberc

Nicolas Petton

Hi!

Which version of Amber are you using?

Nico

Dave Mason <[hidden email]> writes:

> A few developers are working on the same code.  We're using mercurial as
> the VCS.  Currently we have the js directory in the repository, but merging
> js is painful and, frankly, stupid - it's like putting exe files in a
> repository!
>
> It would be easy to put a hook in mercurial so that it would automatically
> run amberc on an update from the repository.  However, that doesn't work
> because amberc gives the following error:
>
> Reading file st/Kit.st
>
> /Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:412
> throw(error);
>       ^
> SyntaxError: Unexpected reserved word
>     at smalltalk.addMethod.smalltalk.method.fn
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:18389:13)
>     at withContextSend
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:426:18)
>     at Smalltalk.st.send
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:403:11)
>     at smalltalk.addMethod.smalltalk.method.fn
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:18426:21)
>     at withContextSend
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:426:18)
>     at Smalltalk.st.send
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:403:11)
>     at smalltalk.addMethod.smalltalk.method.fn
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:6517:11)
>     at withContextSend
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:426:18)
>     at Smalltalk.st.send
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:403:11)
>     at smalltalk.addMethod.smalltalk.method.fn
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:6556:18)
> Failed compilation of Kit.js, exiting.
>
> I presume this is my problem, not amber's, which is why I didn't file this
> as a bug.  I presume I have some reserved word, but am surprised that the
> browser-side compiler didn't see it (this st file has been developed from
> scratch on using amber)  I include Kit.st as an attachment.
>
>
> ../Dave
>
> --
> You received this message because you are subscribed to the Google Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
Nicolas Petton
http://nicolas-petton.fr

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: Problem with amberc

Dave Mason-3
The latest from git

../Dave


On Mon, Feb 4, 2013 at 7:35 AM, Nicolas Petton <[hidden email]> wrote:

Hi!

Which version of Amber are you using?

Nico

Dave Mason <[hidden email]> writes:

> A few developers are working on the same code.  We're using mercurial as
> the VCS.  Currently we have the js directory in the repository, but merging
> js is painful and, frankly, stupid - it's like putting exe files in a
> repository!
>
> It would be easy to put a hook in mercurial so that it would automatically
> run amberc on an update from the repository.  However, that doesn't work
> because amberc gives the following error:
>
> Reading file st/Kit.st
>
> /Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:412
> throw(error);
>       ^
> SyntaxError: Unexpected reserved word
>     at smalltalk.addMethod.smalltalk.method.fn
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:18389:13)
>     at withContextSend
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:426:18)
>     at Smalltalk.st.send
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:403:11)
>     at smalltalk.addMethod.smalltalk.method.fn
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:18426:21)
>     at withContextSend
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:426:18)
>     at Smalltalk.st.send
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:403:11)
>     at smalltalk.addMethod.smalltalk.method.fn
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:6517:11)
>     at withContextSend
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:426:18)
>     at Smalltalk.st.send
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:403:11)
>     at smalltalk.addMethod.smalltalk.method.fn
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:6556:18)
> Failed compilation of Kit.js, exiting.
>
> I presume this is my problem, not amber's, which is why I didn't file this
> as a bug.  I presume I have some reserved word, but am surprised that the
> browser-side compiler didn't see it (this st file has been developed from
> scratch on using amber)  I include Kit.st as an attachment.
>
>
> ../Dave
>
> --
> You received this message because you are subscribed to the Google Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
Nicolas Petton
http://nicolas-petton.fr

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.



--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Problem with amberc

Manfred Kröhnert
Hi Dave,

before being able to compile the Kit.st file you attached there were three errors which needed to be fixed:

* SinkBlock and MenuContainer are missing (inherited?) instvar named 'position'
* GraphBlock>>doIt is referencing a variable named 'input' which is not defined anywhere in the file

Afterwards I get a similar error output regarding 'unexpected reserved word'.

The problem was then in OperateBlock>>setup.
Everything compiles without errors if you change

self allSubclasses do: [: class |
    class setup
    ]

to

self allSubclasses do: [: aClass |
    aClass setup
    ]

So the problem probably is that 'class' is not escaped properly in this case.
Right now I don't have a solution, yet.
But maybe in the next few days.

Best,
Manfred


On Mon, Feb 4, 2013 at 10:37 PM, Dave Mason <[hidden email]> wrote:
The latest from git

../Dave


On Mon, Feb 4, 2013 at 7:35 AM, Nicolas Petton <[hidden email]> wrote:

Hi!

Which version of Amber are you using?

Nico

Dave Mason <[hidden email]> writes:

> A few developers are working on the same code.  We're using mercurial as
> the VCS.  Currently we have the js directory in the repository, but merging
> js is painful and, frankly, stupid - it's like putting exe files in a
> repository!
>
> It would be easy to put a hook in mercurial so that it would automatically
> run amberc on an update from the repository.  However, that doesn't work
> because amberc gives the following error:
>
> Reading file st/Kit.st
>
> /Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:412
> throw(error);
>       ^
> SyntaxError: Unexpected reserved word
>     at smalltalk.addMethod.smalltalk.method.fn
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:18389:13)
>     at withContextSend
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:426:18)
>     at Smalltalk.st.send
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:403:11)
>     at smalltalk.addMethod.smalltalk.method.fn
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:18426:21)
>     at withContextSend
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:426:18)
>     at Smalltalk.st.send
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:403:11)
>     at smalltalk.addMethod.smalltalk.method.fn
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:6517:11)
>     at withContextSend
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:426:18)
>     at Smalltalk.st.send
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:403:11)
>     at smalltalk.addMethod.smalltalk.method.fn
> (/Users/dmason/Ryerson/p4ru/kit/amberc.9XS5BF/compiler.js:6556:18)
> Failed compilation of Kit.js, exiting.
>
> I presume this is my problem, not amber's, which is why I didn't file this
> as a bug.  I presume I have some reserved word, but am surprised that the
> browser-side compiler didn't see it (this st file has been developed from
> scratch on using amber)  I include Kit.st as an attachment.
>
>
> ../Dave
>

--
Nicolas Petton
http://nicolas-petton.fr


--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Problem with amberc

Dave Mason-3
Great!  Thanks!

How did you figure this out?  I tried to track it down, but all I found was that it was trying to eval this giant string...

../Dave

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Problem with amberc

Manfred Kröhnert
Hi Dave,

well, from the error it was somehow clear to me that it was a JavaScript and not a Smalltalk error.
So a few weeks ago I was going through the compiler classes to see how they work together.
From there I knew that .st files get parsed and evaluated in chunks which are enclosed by exclamation marks.

Now, getting the compiler to emit the relevant information probably needs some deeper changes in the compiler classes.
Instead, I just added a logging statement in the Smalltalk>>basicParse: method to print the current chunk to parse.
When it stopped at this specific piece of code changing the name of the temporary variable did the trick.

What is left now is to actually investigate why the variable name wasn't escaped correctly in this situation.

Best,
Manfred


On Tue, Feb 5, 2013 at 3:52 AM, Dave Mason <[hidden email]> wrote:
Great!  Thanks!

How did you figure this out?  I tried to track it down, but all I found was that it was trying to eval this giant string...

../Dave

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Problem with amberc

Nicolas Petton

Manfred,

Could you report an issue about this one? The compiler *should always*
escape this variable names :)

Nico

Manfred Kröhnert <[hidden email]> writes:

> Hi Dave,
>
> well, from the error it was somehow clear to me that it was a JavaScript
> and not a Smalltalk error.
> So a few weeks ago I was going through the compiler classes to see how they
> work together.
> From there I knew that .st files get parsed and evaluated in chunks which
> are enclosed by exclamation marks.
>
> Now, getting the compiler to emit the relevant information probably needs
> some deeper changes in the compiler classes.
> Instead, I just added a logging statement in the Smalltalk>>basicParse:
> method to print the current chunk to parse.
> When it stopped at this specific piece of code changing the name of the
> temporary variable did the trick.
>
> What is left now is to actually investigate why the variable name wasn't
> escaped correctly in this situation.
>
> Best,
> Manfred
>
>
> On Tue, Feb 5, 2013 at 3:52 AM, Dave Mason <[hidden email]> wrote:
>
>> Great!  Thanks!
>>
>> How did you figure this out?  I tried to track it down, but all I found
>> was that it was trying to eval this giant string...
>>
>> ../Dave
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "amber-lang" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [hidden email].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
Nicolas Petton
http://nicolas-petton.fr

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: Problem with amberc

Manfred Kröhnert
I already planned to report an issue.
But before I wanted to create a minimal testcase to understand what is actually going on.

Manfred

On Wed, Feb 6, 2013 at 12:15 PM, Nicolas Petton <[hidden email]> wrote:

Manfred,

Could you report an issue about this one? The compiler *should always*
escape this variable names :)

Nico

Manfred Kröhnert <[hidden email]> writes:

> Hi Dave,
>
> well, from the error it was somehow clear to me that it was a JavaScript
> and not a Smalltalk error.
> So a few weeks ago I was going through the compiler classes to see how they
> work together.
> From there I knew that .st files get parsed and evaluated in chunks which
> are enclosed by exclamation marks.
>
> Now, getting the compiler to emit the relevant information probably needs
> some deeper changes in the compiler classes.
> Instead, I just added a logging statement in the Smalltalk>>basicParse:
> method to print the current chunk to parse.
> When it stopped at this specific piece of code changing the name of the
> temporary variable did the trick.
>
> What is left now is to actually investigate why the variable name wasn't
> escaped correctly in this situation.
>
> Best,
> Manfred
>
>
> On Tue, Feb 5, 2013 at 3:52 AM, Dave Mason <[hidden email]> wrote:
>
>> Great!  Thanks!
>>
>> How did you figure this out?  I tried to track it down, but all I found
>> was that it was trying to eval this giant string...
>>
>> ../Dave
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "amber-lang" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [hidden email].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
Nicolas Petton
http://nicolas-petton.fr

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Problem with amberc

Manfred Kröhnert
It seems like this problem has been already fixed in current Amber master.

However, I noticed that there are sometimes ^M characters in the generated JavaScript code but right now I am not sure where they come from.
The following example function:

setup
    self allSubclasses do: [:class | class setup]

gets compiled into:

fn: function (){
var self=this;
return smalltalk.withContext(function($ctx1) { ^M_st(_st(self)._allSubclasses())._do_((function(class_){
return smalltalk.withContext(function($ctx2) {^Mreturn _st(class_)._setup();
}, function($ctx2) {$ctx2.fillBlock({class_:class_},$ctx1)})}));
return self}, function($ctx1) {$ctx1.fill(self,"setup",{}, smalltalk.Test)})},

Notice the ^M at the beginning of the first two function() calls which are not present in the following two.

Best,
Manfred

On Wed, Feb 6, 2013 at 12:44 PM, Manfred Kröhnert <[hidden email]> wrote:
I already planned to report an issue.
But before I wanted to create a minimal testcase to understand what is actually going on.

Manfred


On Wed, Feb 6, 2013 at 12:15 PM, Nicolas Petton <[hidden email]> wrote:

Manfred,

Could you report an issue about this one? The compiler *should always*
escape this variable names :)

Nico

Manfred Kröhnert <[hidden email]> writes:

> Hi Dave,
>
> well, from the error it was somehow clear to me that it was a JavaScript
> and not a Smalltalk error.
> So a few weeks ago I was going through the compiler classes to see how they
> work together.
> From there I knew that .st files get parsed and evaluated in chunks which
> are enclosed by exclamation marks.
>
> Now, getting the compiler to emit the relevant information probably needs
> some deeper changes in the compiler classes.
> Instead, I just added a logging statement in the Smalltalk>>basicParse:
> method to print the current chunk to parse.
> When it stopped at this specific piece of code changing the name of the
> temporary variable did the trick.
>
> What is left now is to actually investigate why the variable name wasn't
> escaped correctly in this situation.
>
> Best,
> Manfred
>
>
> On Tue, Feb 5, 2013 at 3:52 AM, Dave Mason <[hidden email]> wrote:
>
>> Great!  Thanks!
>>
>> How did you figure this out?  I tried to track it down, but all I found
>> was that it was trying to eval this giant string...
>>
>> ../Dave
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "amber-lang" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [hidden email].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
Nicolas Petton
http://nicolas-petton.fr


--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Problem with amberc

Herby Vojčík


Manfred Kröhnert wrote:
> It seems like this problem has been already fixed in current Amber master.
>
> However, I noticed that there are sometimes ^M characters in the
> generated JavaScript code but right now I am not sure where they come from.

^M is \x0d, so it cr from cr/lf when read on unix.
cr should be removed in String >> asJavascript, I think.

Herby

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.