Discuss Scratch
- -EmeraldThunder-
-
1000+ posts
Ember

Ember is a programming langauge that I am currently working on that will allow users to compile their programs directly to .sb3. This means that they may have an easier time moving from the visual environment of scratch to more advanced text based languages.
The first releases will be released sometime form late December to mid January although you are always welcome to clone the files from the GitHub repo and test some of your code on it.
Currenly I've finsihed building up a lexer and am starting on the main compiler. I've got a few ideas for syntax although I would like feedback on what to change.
Stage {
@green_flag{
var count = 0;
forever {
count++;
wait(0.5);
}
}
}
Sprite Cat {
@key('right_arrow') {
if x < 230 {
x += 10;
}
}
@key('left_arrow') {
if x > -230 {
x -= 10;
}
}
}
Please don't upload projects created with Ember to the website as it currenty violates the TOS.
What I'm currently working on:
I now need to compy out the opcodes of all blocks into a dictionary and implement global variables.
Last edited by -EmeraldThunder- (Jan. 1, 2022 07:00:19)
- NFlex23
-
1000+ posts
Ember
This looks amazing! I'm a huge fan of creating programming languages, so seeing this really excites me!
Edit: I believe using regular expressions in the `lexer.py` file would make it much simpler and more readable– of course that's just a personal opinion though; I love regexes.
Edit: I believe using regular expressions in the `lexer.py` file would make it much simpler and more readable– of course that's just a personal opinion though; I love regexes.

Last edited by NFlex23 (Nov. 23, 2021 19:46:20)
- MagicCrayon9342
-
1000+ posts
Ember
very nice, I remember asking for this kind of thing a few weeks back! Good luck with the project
Ember is a programming langauge that I am currently working on that will allow users to compile their programs directly to .sb3. This means that they may have an easier time moving from the visual environment of scratch to more advanced text based languages.
The first releases will be released sometime form late December to mid January although you are always welcome to clone the files from the GitHub repo and test some of your code on it.
Currenly I've finsihed building up a lexer and am starting on the main compiler. I've got a few ideas for syntax although I would like feedback on what to change.Stage {
@green_flag{
var count = 0;
forever {
count++;
wait(0.5);
}
}
}
Sprite Cat {
@key('right_arrow') {
if x < 230 {
x += 10;
}
}
@key('left_arrow') {
if x > -230 {
x -= 10;
}
}
}
Please don't upload projects created with Ember to the website as it currenty violates the TOS.
What I'm currently working on:I'm trying to implement variables and blocks. Some variables will be built into the sprite such as the position as shown above.
what coding language is this coding language written in?
Last edited by MagicCrayon9342 (Nov. 24, 2021 04:07:34)
- god286
-
1000+ posts
Ember
I think it's Python. There is a GitHub repository in the first post. what coding language is this coding language written in?
also isn't there yet another javascript framework called ember?
Last edited by god286 (Nov. 24, 2021 04:10:34)
- -EmeraldThunder-
-
1000+ posts
Ember
also isn't there yet another javascript framework called ember?Yes that's why the official name is -ET-Ember
- god286
-
1000+ posts
Ember
I've changed quite a bit of the source code for it to run on my computer. Does the version in the repository work for you? Which file do I run?
I got this as a result after doing my changes:
I got this as a result after doing my changes:
[KEYWORD : stage, SCOPE_OPEN : {, EVENT_REGISTER : @, KEYWORD : green_flag, SCOPE_OPEN : {, KEYWORD : var, KEYWORD : count, ASSIGNMENT_OPERATOR : =, NUMBER : 0, LINE_TERMINATOR : ;, KEYWORD : forever, SCOPE_OPEN : {, KEYWORD : count, PLUS_OPERATOR : +, PLUS_OPERATOR : +, LINE_TERMINATOR : ;, KEYWORD : wait, LBRACKET : ( , NUMBER : 0.5, RBRACKET : ), LINE_TERMINATOR : ;, SCOPE_CLOSE : }, SCOPE_CLOSE : }, SCOPE_CLOSE : }, KEYWORD : sprite, KEYWORD : cat, SCOPE_OPEN : {, EVENT_REGISTER : @, KEYWORD : key, LBRACKET : ( , STRING : right_arrow, RBRACKET : ), SCOPE_OPEN : {, KEYWORD : if, KEYWORD : x, LANGLE_BR : {, NUMBER : 230, SCOPE_OPEN : {, KEYWORD : x, PLUS_OPERATOR : +, ASSIGNMENT_OPERATOR : =, NUMBER : 10, LINE_TERMINATOR : ;, SCOPE_CLOSE : }, SCOPE_CLOSE : }, EVENT_REGISTER : @, KEYWORD : key, LBRACKET : ( , STRING : left_arrow, RBRACKET : ), SCOPE_OPEN : {, KEYWORD : if, KEYWORD : x, RANGLE_BR : >, MINUS_OPERATOR : -, NUMBER : 230, SCOPE_OPEN : {, KEYWORD : x, MINUS_OPERATOR : -, ASSIGNMENT_OPERATOR : =, NUMBER : 10, LINE_TERMINATOR : ;, SCOPE_CLOSE : }, SCOPE_CLOSE : }, SCOPE_CLOSE : }]
Last edited by god286 (Nov. 24, 2021 06:57:58)
- -EmeraldThunder-
-
1000+ posts
Ember
What did you have to change and what OS are you using, I get that when I run lexer.py. I've changed quite a bit of the source code for it to run on my computer. Does the version in the repository work for you? Which file do I run?
I got this as a result after doing my changes:[KEYWORD : stage, SCOPE_OPEN : {, EVENT_REGISTER : @, KEYWORD : green_flag, SCOPE_OPEN : {, KEYWORD : var, KEYWORD : count, ASSIGNMENT_OPERATOR : =, NUMBER : 0, LINE_TERMINATOR : ;, KEYWORD : forever, SCOPE_OPEN : {, KEYWORD : count, PLUS_OPERATOR : +, PLUS_OPERATOR : +, LINE_TERMINATOR : ;, KEYWORD : wait, LBRACKET : ( , NUMBER : 0.5, RBRACKET : ), LINE_TERMINATOR : ;, SCOPE_CLOSE : }, SCOPE_CLOSE : }, SCOPE_CLOSE : }, KEYWORD : sprite, KEYWORD : cat, SCOPE_OPEN : {, EVENT_REGISTER : @, KEYWORD : key, LBRACKET : ( , STRING : right_arrow, RBRACKET : ), SCOPE_OPEN : {, KEYWORD : if, KEYWORD : x, LANGLE_BR : {, NUMBER : 230, SCOPE_OPEN : {, KEYWORD : x, PLUS_OPERATOR : +, ASSIGNMENT_OPERATOR : =, NUMBER : 10, LINE_TERMINATOR : ;, SCOPE_CLOSE : }, SCOPE_CLOSE : }, EVENT_REGISTER : @, KEYWORD : key, LBRACKET : ( , STRING : left_arrow, RBRACKET : ), SCOPE_OPEN : {, KEYWORD : if, KEYWORD : x, RANGLE_BR : >, MINUS_OPERATOR : -, NUMBER : 230, SCOPE_OPEN : {, KEYWORD : x, MINUS_OPERATOR : -, ASSIGNMENT_OPERATOR : =, NUMBER : 10, LINE_TERMINATOR : ;, SCOPE_CLOSE : }, SCOPE_CLOSE : }, SCOPE_CLOSE : }]
Edit: It turns out there is a slight mistake on one line of the Lexer where I forgot to create an instance of Token.
Last edited by -EmeraldThunder- (Nov. 24, 2021 07:09:03)
- god286
-
1000+ posts
Ember
Your code works now!
Last edited by god286 (Nov. 24, 2021 07:17:18)
- -EmeraldThunder-
-
1000+ posts
Ember
Does anyone think constants are worth implementing? It would just raise an error at compile if you try to change the value, not in mainstream scratch but may be found useful by someone.
- MagicCrayon9342
-
1000+ posts
Ember
YES!! Does anyone think constants are worth implementing? It would just raise an error at compile if you try to change the value, not in mainstream scratch but may be found useful by someone.https://en.wikipedia.org/wiki/Constant_(computer_programming)
very important feature
- ScolderCreations
-
1000+ posts
Ember
I mean, if you use try/except, you can handle errors in a way that won't stop the entire program. Does anyone think constants are worth implementing? It would just raise an error at compile if you try to change the value, not in mainstream scratch but may be found useful by someone.
- -EmeraldThunder-
-
1000+ posts
Ember
-Deleted-
Last edited by -EmeraldThunder- (Nov. 24, 2021 20:15:11)
- god286
-
1000+ posts
Ember
Oh I got that before! I got this error when trying to push. What can I do?To https://github.com/EmeraldThunder1/Ember.git
! [rejected] main -> main (non-fast-forward)
error: failed to push some refs to 'https://github.com/EmeraldThunder1/Ember.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Just run git pull and then push your changes
- Scratch137
-
1000+ posts
Ember
This looks really cool! It'll be interesting to see where this goes.
- -EmeraldThunder-
-
1000+ posts
Ember
Would people prefer if each sprite plus the stage needed its own file or is everybody happy with the concept in the description?
- NFlex23
-
1000+ posts
Ember
I like it the way it is: all the sprites in one file. Would people prefer if each sprite plus the stage needed its own file or is everybody happy with the concept in the description?

- Scratch137
-
1000+ posts
Ember
I second this; it's more accurate to the way that vanilla Scratch organizes the project.json file. It'd also help to fill the gap between it and a language like Python, where everything can more or less be handled by a single script.I like it the way it is: all the sprites in one file. Would people prefer if each sprite plus the stage needed its own file or is everybody happy with the concept in the description?
- god286
-
1000+ posts
Ember
In my opinion it's best to put different parts of your code in different files. I think it's more organised and also allows you to reuse the code.I second this; it's more accurate to the way that vanilla Scratch organizes the project.json file. It'd also help to fill the gap between it and a language like Python, where everything can more or less be handled by a single script.I like it the way it is: all the sprites in one file. Would people prefer if each sprite plus the stage needed its own file or is everybody happy with the concept in the description?
- ninjaMAR
-
1000+ posts
Ember
i made a pr which added a gitignore and turned ember into a module. see the git repo for the pr