Discuss Scratch

Magnie
Scratcher
100+ posts

M30W - Code Scratch with Scratchblocks!

blob8108 wrote:

Magnie wrote:

Maybe make it compatible with both syntax and no syntax?
What is “it” in this context? n's parser? Kurt? Forum scratchblocks?
scratchblocks + anything that parses scratchblocks.

▴ ▾ ▴ AMD A10-4600 2.3-3.2Ghz x4 6GB RAM, Ubuntu 14.04, Unity Desktop 1366x768, Firefox 31.0 ▴ ▾ ▴
~ Scratch Rush (Traffic Rush based clone) ~
There are 10 types of people in this world, those who understand binary, those who don't, and those who know ternary.
blob8108
Scratcher
1000+ posts

M30W - Code Scratch with Scratchblocks!

nXIII wrote:

I'd write a parser in Python on top of Kurt. It might not be a port, though….
Cool! Does that mean it would be better or worse than the one you've been describing?

It needs context though—like variable declarations and stuff. Is that OK?
Kurt certainly has the context, but it might not be available when the parser is invoked.

Currently you can write:
Block("say for secs", "hi", Block("*", 3, 2))
It'd be cool if you could also write:
Block("say 'hi' for 3 * 2 secs")
But a Block doesn't know about it's parent, so doesn't know about things like defined variables. I could always make the parse method a function of Sprite, though, and have sprites keep a reference to the Project (so you can get global variables as well).

Would it be possible to make the context optional? Or is that silly/unworkable?

Kurt already has information on all the blocks (straight from the 1.4/2.0 sources), so you're all sorted there. Have a look at the docs if you like.

tosh · tosh
blob8108
Scratcher
1000+ posts

M30W - Code Scratch with Scratchblocks!

Magnie wrote:

blob8108 wrote:

Magnie wrote:

Maybe make it compatible with both syntax and no syntax?
What is “it” in this context? n's parser? Kurt? Forum scratchblocks?
scratchblocks + anything that parses scratchblocks.
As nXIII says, we should probably leave the forum scratchblocks as they are. But I think other parsers should be compatible with both, absolutely.

tosh · tosh
nXIII
Scratcher
1000+ posts

M30W - Code Scratch with Scratchblocks!

blob8108 wrote:

nXIII wrote:

I'd write a parser in Python on top of Kurt. It might not be a port, though….
Cool! Does that mean it would be better or worse than the one you've been describing?
Better, probably.

It needs context though—like variable declarations and stuff. Is that OK?
Kurt certainly has the context, but it might not be available when the parser is invoked.

Currently you can write:
Block("say for secs", "hi", Block("*", 3, 2))
It'd be cool if you could also write:
Block("say 'hi' for 3 * 2 secs")
But a Block doesn't know about it's parent, so doesn't know about things like defined variables. I could always make the parse method a function of Sprite, though, and have sprites keep a reference to the Project (so you can get global variables as well).

Would it be possible to make the context optional? Or is that silly/unworkable?
It's pretty unworkable. The idea is that you shouldn't need to delimit anything, including string literals. When you write:
say hi for 10 seconds
I don't know if you mean
say [hi] for (10) seconds
or
say (hi) for (10) seconds
unless I know which variables you've declared.

Kurt already has information on all the blocks (straight from the 1.4/2.0 sources), so you're all sorted there. Have a look at the docs if you like.
OK, thanks.

nXIII · GitHub
blob8108
Scratcher
1000+ posts

M30W - Code Scratch with Scratchblocks!

nXIII wrote:

The idea is that you shouldn't need to delimit anything, including string literals.
Ah, okay, you've convinced me. (You hear that a lot, don't you?)

That is a shame, though — my plan was to have the repr for Blocks spit out the result of stringify():
Block("say 'hi' for 3 * 2 secs")
And then the block constructor would invoke the parser, so that eval(repr(block)) == block.

As it is, I'll keep the current syntax (command followed by args) and make parse a Scriptable method. I'll hook up a method stub for you…

How does your parser work with variable names or string literals or block names that clash with each other?

tosh · tosh
nXIII
Scratcher
1000+ posts

M30W - Code Scratch with Scratchblocks!

That is a shame, though — my plan was to have the repr for Blocks spit out the result of stringify():
Block("say 'hi' for 3 * 2 secs")
And then the block constructor would invoke the parser, so that eval(repr(block)) == block.

As it is, I'll keep the current syntax (command followed by args) and make parse a Scriptable method. I'll hook up a method stub for you…
Yeah, that sounds best. It's also fairly hard to generate code using the new syntax.

How does your parser work with variable names or string literals or block names that clash with each other?
The current one throws a syntax error if you define an already-existent block, so if I write:
-- Variables --
timer
-- Scripts --
say timer
It says:
SyntaxError: Duplicate block "timer".

nXIII · GitHub
blob8108
Scratcher
1000+ posts

M30W - Code Scratch with Scratchblocks!

nXIII wrote:

The current one throws a syntax error if you define an already-existent block
Sounds good.

I'll send you a github branch in a few days…

tosh · tosh
scimonster
Scratcher
1000+ posts

M30W - Code Scratch with Scratchblocks!

roijac wrote:

@sci, I uploaded a fixed version. Does it work now?
[sci@localhost ~]$ python-pip install M30W
Downloading/unpacking M30W
Running setup.py egg_info for package M30W

Downloading/unpacking kurt (from M30W)
Running setup.py egg_info for package kurt

Requirement already satisfied (use --upgrade to upgrade): PIL in /usr/lib64/python2.7/site-packages/PIL (from M30W)
Requirement already satisfied (use --upgrade to upgrade): wxpython in /usr/lib64/python2.7/site-packages/wx-2.8-gtk2-unicode (from M30W)
Downloading/unpacking construct<2.5 (from kurt->M30W)
Running setup.py egg_info for package construct

Downloading/unpacking PLY (from kurt->M30W)
Running setup.py egg_info for package PLY

Installing collected packages: M30W, kurt, construct, PLY
Running setup.py install for M30W
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help

error: option --single-version-externally-managed not recognized
Complete output from command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-sci/M30W/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gpFXjm-record/install-record.txt --single-version-externally-managed:
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]

or: -c --help [cmd1 cmd2 ...]

or: -c --help-commands

or: -c cmd --help



error: option --single-version-externally-managed not recognized

----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-sci/M30W/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gpFXjm-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build-sci/M30W
Storing complete log in /home/sci/.pip/pip.log
Content of ~/.pip/pip.log:
------------------------------------------------------------
/usr/bin/python-pip run on Thu Jun 13 17:09:53 2013
Downloading/unpacking M30W

Running setup.py egg_info for package M30W

running egg_info
writing requirements to pip-egg-info/M30W.egg-info/requires.txt
writing pip-egg-info/M30W.egg-info/PKG-INFO
writing top-level names to pip-egg-info/M30W.egg-info/top_level.txt
writing dependency_links to pip-egg-info/M30W.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found


reading manifest file 'pip-egg-info/M30W.egg-info/SOURCES.txt'
writing manifest file 'pip-egg-info/M30W.egg-info/SOURCES.txt'
Source in /tmp/pip-build-sci/M30W has version 0.2.0, which satisfies requirement M30W
Downloading/unpacking kurt (from M30W)

Running setup.py egg_info for package kurt

running egg_info
writing requirements to pip-egg-info/kurt.egg-info/requires.txt
writing pip-egg-info/kurt.egg-info/PKG-INFO
writing top-level names to pip-egg-info/kurt.egg-info/top_level.txt
writing dependency_links to pip-egg-info/kurt.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found


reading manifest file 'pip-egg-info/kurt.egg-info/SOURCES.txt'
writing manifest file 'pip-egg-info/kurt.egg-info/SOURCES.txt'
Source in /tmp/pip-build-sci/kurt has version 1.4.7, which satisfies requirement kurt (from M30W)
Requirement already satisfied (use --upgrade to upgrade): PIL in /usr/lib64/python2.7/site-packages/PIL (from M30W)

Requirement already satisfied (use --upgrade to upgrade): wxpython in /usr/lib64/python2.7/site-packages/wx-2.8-gtk2-unicode (from M30W)

Downloading/unpacking construct<2.5 (from kurt->M30W)

Running setup.py egg_info for package construct

running egg_info
writing pip-egg-info/construct.egg-info/PKG-INFO
writing top-level names to pip-egg-info/construct.egg-info/top_level.txt
writing dependency_links to pip-egg-info/construct.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found


reading manifest file 'pip-egg-info/construct.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pip-egg-info/construct.egg-info/SOURCES.txt'
Source in /tmp/pip-build-sci/construct has version 2.0.6, which satisfies requirement construct<2.5 (from kurt->M30W)
Downloading/unpacking PLY (from kurt->M30W)

Running setup.py egg_info for package PLY

running egg_info
writing pip-egg-info/ply.egg-info/PKG-INFO
writing top-level names to pip-egg-info/ply.egg-info/top_level.txt
writing dependency_links to pip-egg-info/ply.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found


reading manifest file 'pip-egg-info/ply.egg-info/SOURCES.txt'
writing manifest file 'pip-egg-info/ply.egg-info/SOURCES.txt'
Source in /tmp/pip-build-sci/PLY has version 3.4, which satisfies requirement PLY (from kurt->M30W)
Installing collected packages: M30W, kurt, construct, PLY

Running setup.py install for M30W

Running command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-sci/M30W/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gpFXjm-record/install-record.txt --single-version-externally-managed
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]

or: -c --help [cmd1 cmd2 ...]

or: -c --help-commands

or: -c cmd --help



error: option --single-version-externally-managed not recognized

Complete output from command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-sci/M30W/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gpFXjm-record/install-record.txt --single-version-externally-managed:

usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]

or: -c --help [cmd1 cmd2 ...]

or: -c --help-commands

or: -c cmd --help



error: option --single-version-externally-managed not recognized

----------------------------------------

Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-sci/M30W/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gpFXjm-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build-sci/M30W

Exception information:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 139, in main
status = self.run(options, args)
File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 271, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/usr/lib/python2.7/site-packages/pip/req.py", line 1185, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/pip/req.py", line 592, in install
cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
File "/usr/lib/python2.7/site-packages/pip/util.py", line 662, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-sci/M30W/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gpFXjm-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build-sci/M30W

Retired Community Moderator
BTW, i run Google Chrome 41.0.2272.101 on a Linux system - Ubuntu 14.04. NEW: iPad 4th gen. w/retina.

418 I'm a teapot (original - to be read by bored computer geeks)
THE GAME (you just lost)
; THE SEMICOLON LIVES ON IN OUR SIGS
Magnie
Scratcher
100+ posts

M30W - Code Scratch with Scratchblocks!

Maybe try sudo, sci?

▴ ▾ ▴ AMD A10-4600 2.3-3.2Ghz x4 6GB RAM, Ubuntu 14.04, Unity Desktop 1366x768, Firefox 31.0 ▴ ▾ ▴
~ Scratch Rush (Traffic Rush based clone) ~
There are 10 types of people in this world, those who understand binary, those who don't, and those who know ternary.
scimonster
Scratcher
1000+ posts

M30W - Code Scratch with Scratchblocks!

I did.

Retired Community Moderator
BTW, i run Google Chrome 41.0.2272.101 on a Linux system - Ubuntu 14.04. NEW: iPad 4th gen. w/retina.

418 I'm a teapot (original - to be read by bored computer geeks)
THE GAME (you just lost)
; THE SEMICOLON LIVES ON IN OUR SIGS
roijac
Scratcher
100+ posts

M30W - Code Scratch with Scratchblocks!

scimonster wrote:

I did.
Can you run rm -rf /tmp/pip/pip-build-sci/ and run again?
Anyway, could you tell after you run it what version the files inside had?
scimonster
Scratcher
1000+ posts

M30W - Code Scratch with Scratchblocks!

roijac wrote:

scimonster wrote:

I did.
Can you run rm -rf /tmp/pip/pip-build-sci/ and run again?
Anyway, could you tell after you run it what version the files inside had?
How do i find the version?

Retired Community Moderator
BTW, i run Google Chrome 41.0.2272.101 on a Linux system - Ubuntu 14.04. NEW: iPad 4th gen. w/retina.

418 I'm a teapot (original - to be read by bored computer geeks)
THE GAME (you just lost)
; THE SEMICOLON LIVES ON IN OUR SIGS
roijac
Scratcher
100+ posts

M30W - Code Scratch with Scratchblocks!

scimonster wrote:

roijac wrote:

scimonster wrote:

I did.
Can you run rm -rf /tmp/pip/pip-build-sci/ and run again?
Anyway, could you tell after you run it what version the files inside had?
How do i find the version?
there should be a compressed file, and inside it a setup.py file. open it and look at the bottom, there it should be
easymath123
Scratcher
100+ posts

M30W - Code Scratch with Scratchblocks!

I am confused.
How do i install M30W on linux?


Magnie
Scratcher
100+ posts

M30W - Code Scratch with Scratchblocks!

easymath123 wrote:

I am confused.
How do i install M30W on linux?
sudo pip install M30W
and if you want to upgrade:
sudo pip install M30W --upgrade

Btw, bug report:
Traceback (most recent call last):

File "/usr/local/lib/python2.7/dist-packages/M30W/GUI/menu.py", line 152, in OnStart
runtime.engine.start()

File "/usr/local/lib/python2.7/dist-packages/M30W/scripts.py", line 239, in start
next(script)

File "/usr/local/lib/python2.7/dist-packages/M30W/scripts.py", line 106, in next
self.current_block = self.script[self._counter]()

File "/usr/local/lib/python2.7/dist-packages/M30W/scripts.py", line 133, in __call__
value = getattr(self.sprite, self.command)(*self.arguments)

File "/usr/local/lib/python2.7/dist-packages/M30W/sprites/base.py", line 86, in __getattr__
(self.__class__.__name__, key))

AttributeError: 'Sprite' object has no attribute 'setVar:to:'

Last edited by Magnie (June 15, 2013 14:26:52)


▴ ▾ ▴ AMD A10-4600 2.3-3.2Ghz x4 6GB RAM, Ubuntu 14.04, Unity Desktop 1366x768, Firefox 31.0 ▴ ▾ ▴
~ Scratch Rush (Traffic Rush based clone) ~
There are 10 types of people in this world, those who understand binary, those who don't, and those who know ternary.
davidkt
Scratcher
1000+ posts

M30W - Code Scratch with Scratchblocks!

Did you recently make any changes?

Remember when I looked like this? I still do.


Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
roijac
Scratcher
100+ posts

M30W - Code Scratch with Scratchblocks!

Magnie wrote:

easymath123 wrote:

I am confused.
How do i install M30W on linux?
sudo pip install M30W
and if you want to upgrade:
sudo pip install M30W --upgrade

Btw, bug report:
Traceback (most recent call last):

File "/usr/local/lib/python2.7/dist-packages/M30W/GUI/menu.py", line 152, in OnStart
runtime.engine.start()

File "/usr/local/lib/python2.7/dist-packages/M30W/scripts.py", line 239, in start
next(script)

File "/usr/local/lib/python2.7/dist-packages/M30W/scripts.py", line 106, in next
self.current_block = self.script[self._counter]()

File "/usr/local/lib/python2.7/dist-packages/M30W/scripts.py", line 133, in __call__
value = getattr(self.sprite, self.command)(*self.arguments)

File "/usr/local/lib/python2.7/dist-packages/M30W/sprites/base.py", line 86, in __getattr__
(self.__class__.__name__, key))

AttributeError: 'Sprite' object has no attribute 'setVar:to:'
Maybe because the variables block aren't implemented yet?

@davidkt, the last change I made was r111, logic error in doIfElse. It was on Friday, does it count as recently?
davidkt
Scratcher
1000+ posts

M30W - Code Scratch with Scratchblocks!

roijac wrote:

Magnie wrote:

easymath123 wrote:

I am confused.
How do i install M30W on linux?
sudo pip install M30W
and if you want to upgrade:
sudo pip install M30W --upgrade

Btw, bug report:
Traceback (most recent call last):

File "/usr/local/lib/python2.7/dist-packages/M30W/GUI/menu.py", line 152, in OnStart
runtime.engine.start()

File "/usr/local/lib/python2.7/dist-packages/M30W/scripts.py", line 239, in start
next(script)

File "/usr/local/lib/python2.7/dist-packages/M30W/scripts.py", line 106, in next
self.current_block = self.script[self._counter]()

File "/usr/local/lib/python2.7/dist-packages/M30W/scripts.py", line 133, in __call__
value = getattr(self.sprite, self.command)(*self.arguments)

File "/usr/local/lib/python2.7/dist-packages/M30W/sprites/base.py", line 86, in __getattr__
(self.__class__.__name__, key))

AttributeError: 'Sprite' object has no attribute 'setVar:to:'
Maybe because the variables block aren't implemented yet?

@davidkt, the last change I made was r111, logic error in doIfElse. It was on Friday, does it count as recently?
I just was thinking it might have caused the problem. What code did you use?

Remember when I looked like this? I still do.


Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
roijac
Scratcher
100+ posts

M30W - Code Scratch with Scratchblocks!

davidkt wrote:

I just was thinking it might have caused the problem. What code did you use?
It didn't cause the problem, the problem is that i haven't done anything with variables yet
Though it may require a little bit more obvious error message.
davidkt
Scratcher
1000+ posts

M30W - Code Scratch with Scratchblocks!

Oh.

Remember when I looked like this? I still do.


Float, my Scratch 2.0 mod | My (somewhat under-construction) blog

Powered by DjangoBB

Standard | Mobile