Discuss Scratch

MegaApuTurkUltra
Scratcher
1000+ posts

ApuC - A C-based language that compiles to Scratch JSON

ApuC

I've always wanted to make my own language. I also have gotten quite tired of dragging stuff around in Scratch. So, I made ApuC. It's a C-based language that compiles to Scratch JSON.
It's really limited right now because it's not in the Scratch editor - I might make a mod for it later if people find it useful. Right now you just type code, run my compiler on it, and it generates a “.sprite2” file or replaces scripts in an existing one. Also, it can't do global variables yet, and it isn't object oriented.

Running ApuC
You can check out the source on my repo: https://github.com/MegaApuTurkUltra/Scratch-ApuC
Link to advanced doc here.

I have no idea how to use GitHub so I had my friend help me, but some stuff may still be wrong. Let me know if you have problems.

Building it is kind of difficult (I could have made an ant script or something) very easy. Just run the ant script “build.xml”
If you import it into Eclipse you'll need to change the library build path item "swt-[….].jar" to the swt version for your OS and Java bit version (32 or 64 bit). Then, run apu.scratch.converter.IdeMain
Otherwise just run the ant script and run the jars it makes in dist/

If you don't want the source, download my small hacked-together now slightly complex and large IDE or just the command line compiler. I assure you that there are no viruses or anything (read the source code if you're unsure).

Note: if you're not going to read any of this post and are on Mac OSX, use apuc-noswt.jar because there's a 99% chance ApuC.jar won't work

IDE: https://github.com/MegaApuTurkUltra/Scratch-ApuC/releases/download/1.3.5/ApuC.jar
Just double click. It's pretty self explanatory. It will automatically highlight errors in your code, hover over red line numbers to see what's wrong.
IDE without SWT new: https://github.com/MegaApuTurkUltra/Scratch-ApuC/releases/download/1.3.5/ApuC-noswt.jar
Like the normal IDE, but this gets rid of the preview (which relies on SWT) and removes the LAF in case the IDE is crashing on your system. Basically, if the IDE doesn't work, try this. (Mostly a problem on Mac. I got an OSX VM on VMware completely 100% legal copy of OSX so I probably should be able to test stuff now).
Just compiler: https://github.com/MegaApuTurkUltra/Scratch-ApuC/releases/download/1.3.5/apuc-compile.jar
This is a command line tool to compile ApuC files without the IDE

Note: if you get a 404, it means I'm uploading the files atm! Just wait a few minutes and they will be up.


To run the command line compiler use the command
java -jar apuc-compile.jar source_code.apuc destination.sprite2
Replace source_code.apuc and destination.sprite2 with your source file name and the name of the sprite file you want.

Once you create a sprite file either by using the IDE export button or compiling on the command line, import it into Scratch by using the upload sprite button at the top of the sprites list in the Scratch editor.

———————–

I also realized that this may be a good intro to real programming from Scratch since ApuC looks a lot like C (and the entire C family), Java, JavaScript, etc. So, I'll give a full explanation of the syntax:

If you already know a C-like language, you may need the advanced doc instead of this newbie guide. There's more info and downloads at the bottom of this post.

First, in case you didn't know:
A compiler turns written code into code a computer understands. Even though code may seem complicated to you, it's much much more complicated to a computer. Compilers usually turn text into bytes that a computer can run. My compiler turns your ApuC code into code Scratch understands.

Newbie syntax guide

All ApuC programs consist of lines and blocks. I don't mean the Scratch kind of blocks; these blocks just group lines, kind of like c-blocks in Scratch.

All lines contain one statement and then end with a semicolon.
this is my line;
It is not necessary for lines to be on different lines in your text editor, just that they all end with a semicolon, so the compiler can tell which line is which.

All blocks begin with a curly brace, contain some number of lines, and then end with a curly brace.
{
line 1;
line 2;
etc;
}
Blocks may also have a line at the top before the opening brace to define them. For example, “if” blocks look like this:
if(condition){
line 1;
etc;
}
I'll get into this later.
Remember that blocks in ApuC are not Scratch blocks. Lines are a better analogy for Scratch blocks.

Apart from lines and blocks, you can also put comments in code. These are ignored by the compiler.
// this is a single line comment. The compiler ignores this
this is treated as a line and is turned into Scratch code;
/*
this is a multi line
comment
this is also ignored by the compiler
*/
Also, spaces, tabs, and newlines are ignored. You can put as many of those as you want anywhere you want. They are only for making your code look nice.

Variables

Setting and getting variables is easy in ApuC. Just remember that all variable names may only contain letters, numbers and underscores (_), and must not start with a number.
my_var = 5; // this sets my_var to 5
5derp = 6; // not a valid variable name! It starts with a number
asdf = my_var; // this sets asdf to the same thing as my_var.
derp2 = 8; // this is valid. It doesn't start with a number, but it does have a number after the first letter, which is allowed.
_derp = 9; // this is also valid.
derp = 10 // the variable set is valid, but do you know what this line is missing? Scroll back up if you forgot.
You can also use math in setting variables. It will be evaluated in order-of-operations order. For example
d = 5+6+7;
will become
set [d v] to (((5)+(6))+(7))
// note how ApuC is more concise than scratchblocks code. Instead of
// set [d v] to (((5)+(6))+(7)) (omg so many parens)
// it's just
d = 5 + 6 + 7;
// easy
// here are some more examples
a = 5 + 6 * 7; // will evaluate in PEMDAS order: 5 + (6*7)
b = 3 % 2; // this is the modulo operator. It works like the scratch ( ) mod ( ) block
c = (5 + 6) * 7; // use parens to change the evaluation order
d = d + 4; // obvious
d += 4; // same as the line above. Just more concise.
e = e + 1; // obvious
e++; // same as the line above. Only works for + 1. Otherwise use +=

Type
In ApuC, unlike regular C, variables can be whatever type you want: text or number.
You can even change a variable from text to number or vice versa.
derp = "sup this is text"; // oh yeah I forgot to mention how to make text
// use double quotes like above
// in programming text is called a "string"
derp = 5; // valid in ApuC - because it's valid in Scratch too

Context and scope
An important feature of all C-like languages is scope. This means that some variables are only accessible within certain areas of your code. This is really useful for complex programs where you may want to name variables the same way in different areas of your code, but you don't want them all to be the same variable. For example:
{
// remember that this is a comment, which means it's ignored
// now we are inside a block
asdf = 5; // yay, we used our epic skills to set a variable to 5
}
// now we are outside the block
asdf = 6; // This is a DIFFERENT asdf. This is the asdf outside the "scope" of the block above.
// my compiler handles scope by putting unique context IDs on the names of all variables.
Scopes inside other scopes can access the “parent” scope's variables
asdf = 5;
{
// inside a block
asdf = 6; // this is the SAME asdf. It was declared first outside of this block's scope, so this block now
// "inherits" it into its own scope
}
// here asdf will now be 6

Note that Scratch maintains variables between runs, so in ApuC, it is required to define a variable by setting it before you can use it.
//// BAD example
yo_sup = derp; // WRONG. derp isn't defined yet! It could be anything!

//// GOOD example
derp = 5;
yo_sup = derp; // now we know for sure that derp is not some random thing left over from last run
This also means that cloud variables are not supported (yet). I will add functionality for persistent variables and cloud variables if anyone needs it.

Control flow
This is a fancy word that means “controlling which lines of a program are run”. Basically, it's all the control stuff in Scratch like if/else, etc.
ApuC has if/else blocks (no else-if yet though).
derp = 0;
// do some operation here that will set derp to some random number
if(derp == 5){
// do stuff for derp = 5
// don't be fooled by the if! This is still a block!
// all block stuff apply here like scope
} else {
// do stuff for derp does not = 5
// another block
}

if(b > 6){
// an if by itself is ok too
}
Whoa. That was complicated. What is “==” anyway?
Well, what goes into the parens after an if block is called a condition
Conditions can test for things being “true” or “false”
For example,
5 > 6
is “false” because 5 is not greater than 6!
 derp < 5 
will be “true” if derp is less than 5, or “false” if it's not.
Here are all the conditional “operators”
derp < 5 // will be true if the left side is less than the right side
derp > 5 // same thing as above, just greater than
derp <= 5 // will be true if the left side is less than OR equal to the right side
derp >= 5 // same thing, just greater than
derp == 5 // will be true if the left side equals the right side
// it's "==" instead of "=" so the compiler isn't fooled into thinking derp needs to be SET to 5!
// my compiler doesn't allow "=" in if statements yet, though
derp != 5 // this will be true if the left side DOES NOT equal the right side
derp = 5 // Wrong! Use ==
You can also use boolean operators, which are true if their conditions are related.
// && is the AND operator. You can put two conditions on either side of it and it will be true if BOTH conditions are true
// example:
derp < 5 && derp2 < 5 // will be true ONLY if both sides are true
// || is the OR operator. It will be true if either sides are true.
// example
derp < 5 || derp2 < 5 // will be true if derp is less than 5 OR if derp2 is less than 5

// ! is the NOT operator. It will turn all trues to falses and all falses to trues
!(derp < 5) // will be true if derp is NOT less than 5. In this case, this is equivalent to
derp >= 5

// you can also use parens to group (and right now, ApuC doesn't support multiple operators without parens
(derp > 5 && derp2 < 6) || derp4 == 7 // valid
derp > 5 && derp2 < 6 || derp4 == 7 // should be valid, but isn't yet. Use parens like above
Remember, if blocks will only run if the condition in them is “true”. Otherwise, if it is “false”, the else block will be run, if it exists.
More examples:

The next type of control flow statement is the while loop. This is simple
while(derp < 5){
// repeats until derp is not less than 5
}
The while loop also accepts a condition like the if statement. It will keep running the code over and over until the condition is “false.” If the condition is already “false,” it won't run at all.
A special case of the while loop (at least in my language) is
while(true){
// runs forever
}
This will loop indefinitely. It never stops unless you use a “stop all scripts.” This is also the only place in ApuC where “true” is allowed. I will update ApuC if anyone needs more features (I'm sure they will if they actually want to use ApuC).

Now, the most complicated type of loop. The for loop
for(x = 5;x < 10; x++){
// runs from x = 5 to x = 9
}
Whoa. Aren't you supposed to use “==” instead of “=”? No! That's because in the for loop, it actually sets a variable.
Let's break it down;
for(<set variable here>;<condition here>;<set variable here>) { }
First, it sets a variable to its initial value. Then, it runs the condition. If the condition is “true” then it loops over and over until the condition is “false.” Kind of like the while loop. However, at the end of each loop, it also runs the second variable set. For loops are useful for things like running through list items.
for(i = 0;i<length of list;i++){ // remember what i++ does?
// usually we programmers start with 'i' as the loop variable, and then continue to 'j', 'k', 'l', etc if we have more for loops inside for loops
}
for(i = 0;i<length of list 2;i++){
// remember what scope is? If not, scroll back up!
// this i is different from the other i!
}

One last loop I added, which isn't part of C at all
repeat @singleframe (5){ // note only numbers allowed here
// do stuff 5 times
// this will actually expand out to 5 different operations all in a row
derp++;
}
In this case this will become
set [derp v] to ((derp)+(1))
set [derp v] to ((derp)+(1))
set [derp v] to ((derp)+(1))
set [derp v] to ((derp)+(1))
set [derp v] to ((derp)+(1))
This is useful to avoid loop delay.
If you don't understand, don't worry. Single frame is only useful to advanced Scratchers.

Ok enough control flow stuff. What about lists?

Arrays
Arrays are a fancy programming term for what Scratch calls lists.
The syntax for creating one is a bit different from C.
derp = array[5]; // derp[] is just like a variable derp, but it's an array
// array[5] means "create a new array with a length of 5"
// now access items like
derp[0] = "sup"; // sets the first item (called "index 0") to "sup"
derp[1] = 5; // sets the second item (index 1) to 5
// etc etc
// notice the 0! In ApuC (and most languages) 0 is the starting index of an array.
// to find the length of a list, use the built in function "length"
// more on functions later
length(derp); // 5 in this case
Remember: in Scratch list indices start with 1. In ApuC, they start with 0 because that's what it's like in most languages. My compiler automatically corrects array indices by adding 1.
// You can use array items just like any other variable
a = 1;
derp[] = array[10];
str[] = array[10];
if(derp[6] < 5 || str[a+4] == "derp"){
// do stuff
var = 6;
}
// remember scope?
var = 7; // different var here!

You can also create arrays with
derp[] = @singleframe array[5];
Which will replace the inner loop that ApuC compiles this to with single frame operations. If you don't understand, don't worry. Single frame is only useful to advanced Scratchers.

Phew. That was a lot of typing. On to the last section:

Methods/functions/subroutines/whatever you want to call them

These are like custom blocks. In fact, the compile to custom blocks. If you have a lot of stuff you want to do repeatedly somehow, and loops aren't fit for the task, or if you want to organize your code, use these.
def sup_function(){ // this defines a function
say("Hi"); // more on this later
}

// do stuff
sup_function(); // this calls the function
// more stuff
sup_function(); // this calls it again
The “def” keyword is kind of unlike C syntax. Since ApuC has no variable types, “def” is used instead of “void” or a variable type in C.
Then, there are two parentheses. These indicate that it is a function, and not just some old variable. They also hold parameters if necessary. More on params later.
To call a function (which means to run it), just put the name of the function and two parentheses in your line.

You can define functions anywhere and call them anywhere in your code. Unlike C, ApuC allows method definitions and calls anywhere. Just don't call a method that isn't defined! That's an error.

Parameters

You can also put variables into a function call.
defsay_thingy(thingy){
say(thingy); // more on "say" and other built in functions later
derp = 5;
}
// do stuff
say("Hi"); // passes "Hi" as the parameter "thingy"
derp = "Derp"; // functions have scope too! derp is not the same derp as in say_thingy!
say(derp); // passes the value of derp as the parameter.
// you can call functions with variables, strings, numbers, math operations, etc.
say(5+5); // valid!
I've already typed a lot so if parameters don't make sense to you please go look up the Scratch Wiki article on custom blocks. I'm too lazy to explain more.

Return statements

Added in 1.1: Methods can have return statements. This means that they can output a value, just like some built in Scratch reporter blocks.
Here's an example:
def sign(number){
if(number == 0){
return 0;
} else {
if(number>0){
return 1;
} else {
return -1;
}
}
}
say(join("The sign of 8 is: ", sign(8)));
Each return statement expands out to:
set [return_method_id v] to [whatever the return statement has]
stop [this script v]
You can even just use return by itself to immediately exit a function.
When you call a function and use its return value somewhere, ApuC automatically assigns an ID to your function call, calls the function before using the return value, sets the unique function call variable, and then uses it in the place of your function call. So:
say(my_func());
will look like:
my_func::custom
set [function_call_id v] to (return_method_id)
say (return_method_id)
Note that function_call_id and return_method_id are actually variables with unique IDs.
The function call ID enables you to call a function multiple times in a line
def increment(i){
return i+1;
}
say(increment(5)+increment(6));
This will become
define increment (i)
set [return_method_id v] to ((i)+(1))
stop [this script v] // useless here, but my compiler doesn't know where you will put returns, so this is necessary

when gf clicked
increment (5)
set [function_call_id_1 v] to (method_call_id)
increment (6)
set [function_call_id_2 v] to (method_call_id)
say((function_call_id_1)+(function_call_id_2))

Just be careful! If you use a return value from a function that doesn't return anything, results are undefined!

Recursion

Functions in ApuC can also be recursive. This means they can call themselves. ApuC creates a call stack (basically it's a list with all the current methods' return values) for each “when” block in your script, and then passes the call stack's name to each function called in the “when” block with that stack. When a function is called, it only updates return values in it's “when” block caller's stack (with the power of ApuC hacks - variables in list blocks).
Please note that while ApuC has made a small step toward “safe” recursive functions, they still aren't completely “safe”. I mean that if you call a recursive function from two different “when” blocks at the same time, it will glitch out (unless it doesn't define any variables). So, please make sure you aren't doing that!

Run without screen refresh

To make a function become a “Run without screen refresh” define block in Scratch, use the @atomic tag.
def @atomic derp_function(){
// do stuff without screen refresh here
}

When blocks

Your program by default gets hooked under a “When green flag” block (except for functions) but if you want to add more “When” hats, then use the @when keyword followed by a block
For example:
@when greenFlag { /* extra green flag script */ }
@when received "derp_broadcast" { /* when received script */ }
@when keyPressed "space" { }
@when keyPressed "a" { /* any key can go in the quotes */ }
@when cloned { /* when I start as clone */ }
@when clicked { /* this sprite clicked */ }
@when sensorGreaterThan "loudness" 10 { /* when loudness > 10 */ }

Built in functions

And math operations in
[ v] of ()::operators 
are built in functions with their names the same as what they do, except for “e ^” and “
”10 ^"
abs(-10); // same as [abs v] of (-10)
asin(0); // same as [asin v] of (0)
powe(0); // function for [e ^ v] of (0)
pow10(0); // function for [10 ^ v] of (0)

All Scratch functions are supported.
For a full list of built in functions see https://github.com/MegaApuTurkUltra/Scratch-ApuC/blob/master/src/builtin.csv
For example:
other_var = username(); // the username block. No need to be defined yourself. It's built in
joined_var = join("Sup, ", other_var); // the join block
if(username() == "MegaApuTurkUltra"){ // yes you can use built in functions in conditions
enableEpicAdminCheats(); // jk lol
}
// you can use built in reporter functions wherever you can use a variable!
// Note that they are ALL functions. Even stuff like username()

// while fooling with my language I discovered a Scratch hack
// hack as in really cool use of code that you can't make in the normal editor
variable_name = "derp";
setVariable(variable_name, 5); // will set the variable derp to 5!!!
// currently no use for this especially since all variables have random context ids
// maybe you can use this to hack in global variables or cloud variables to ApuC
// use readVariable("var_name") to get a variable value

Post if you see more hacks or cool things you can do with ApuC!

This concludes the syntax tutorial. If I missed anything, let me know.

———————————-

I hope someone other than me finds this useful. In any case, it was a fun project for me to finally make my own language

Changelog
  • 1.3.5 Fixed bug in contexts and variables; fixed bug in compiler
  • 1.3.4 UI updates; removed LAF in non-swt version (use -uselaf to get it back)
  • 1.3.2 Fixed bug that made 1.3.1 unlaunchable
  • 1.3.1 Fixed bug in negative numbers, added hex color support, added “Export all” to IDE to export to a project file
  • 1.2.1 Fixed tons of bugs, added tabs to the editor, added buttons to preview.
  • 1.2.0: Added built in math operations; added call stacks for recursion; added advanced doc; fixed bug in length(); removed hideAll; fixed some things in the IDE
  • 1.1.2: Might have fixed IllegalArgumentException on unix-like systems
  • 1.1: Added return statement, change “void” to “def”

Last edited by MegaApuTurkUltra (Oct. 17, 2015 23:25:19)


$(".box-head")[0].textContent = "committing AT crimes since $whenever"
Thepuzzlegame
Scratcher
1000+ posts

ApuC - A C-based language that compiles to Scratch JSON

This is really cool, I'm looking forward to future development!

hi!
ArloarLoLs
Scratcher
1 post

ApuC - A C-based language that compiles to Scratch JSON

Amazing stuff. Just what I've been waiting for.
bobbybee
Scratcher
1000+ posts

ApuC - A C-based language that compiles to Scratch JSON

Nice! I can't test right now, because of Ludum Dare (and addiction to IRC), but I will definitely look into this soon!

Request: since you are doing a compiler, you could probably make return values for functions… (easiest way is a Scratch list representing the stack, and to return, you push, and the callee pops the value into a temp var)

“Ooo, can I call you Señorita Bee?” ~Chibi-Matoran
Harakou
Scratcher
1000+ posts

ApuC - A C-based language that compiles to Scratch JSON

Looks cool; I'll have to try it out!
Mrcomputer1
Scratcher
500+ posts

ApuC - A C-based language that compiles to Scratch JSON

Harakou wrote:

Looks cool; I'll have to try it out!
^^^ Same as what you said ^^^

My Profile / My User Page / My Talk Page
——————–
Progress bar to 1000+ Posts - Image might not be up to date

——————–
My browser / operating system: Windows NT 10.0 (Windows 11 - 22H2), Firefox 122.0b4
——————–
My ScratchX Extensions——–If you like this post, give me an internet!——–Sharp Scratch Mod
PullJosh
Scratcher
1000+ posts

ApuC - A C-based language that compiles to Scratch JSON

MegaApuTurkUltra
Scratcher
1000+ posts

ApuC - A C-based language that compiles to Scratch JSON

PullJosh wrote:

Cool! This must have taken a lot of work!
Yeah it took about 4 days. Completely worth it though. Now I can say I have made my own language

Harakou wrote:

Looks cool; I'll have to try it out!
Whoa. ST posting on my topic. Thanks!

bobbybee wrote:

Nice! I can't test right now, because of Ludum Dare (and addiction to IRC), but I will definitely look into this soon!

Request: since you are doing a compiler, you could probably make return values for functions… (easiest way is a Scratch list representing the stack, and to return, you push, and the callee pops the value into a temp var)
Yeah I could do that. First I have to figure out how to use apache ant though otherwise I'm going to waste too much time manually building stuff.

$(".box-head")[0].textContent = "committing AT crimes since $whenever"
MegaApuTurkUltra
Scratcher
1000+ posts

ApuC - A C-based language that compiles to Scratch JSON

bobbybee wrote:

Nice! I can't test right now, because of Ludum Dare (and addiction to IRC), but I will definitely look into this soon!

Request: since you are doing a compiler, you could probably make return values for functions… (easiest way is a Scratch list representing the stack, and to return, you push, and the callee pops the value into a temp var)
I added return statements. It uses variables for each return statement and each function call.
See my updated syntax guide (first post)

If you have more syntax suggestions let me know!

$(".box-head")[0].textContent = "committing AT crimes since $whenever"
djdolphin
Scratcher
1000+ posts

ApuC - A C-based language that compiles to Scratch JSON

Awesome! I'm going to try making my secret project CQ: WoG with this.

I think
Math.ceiling(1.5)
would be nicer than
mathOperationOf("ceiling", 1.5)
though.

And I see this includes the hideAll function. The block's code was commented out of Scratch a while ago.

Last edited by djdolphin (Aug. 26, 2014 18:28:41)


!
djdolphin
Scratcher
1000+ posts

ApuC - A C-based language that compiles to Scratch JSON

I get this whenever I try to compile something:
name:test name$ java -jar apuc-compile.jar test.apuc test.sprite2
Done
java.lang.IllegalArgumentException: URI has an authority component
at sun.nio.fs.UnixUriUtils.fromUri(UnixUriUtils.java:53)
at sun.nio.fs.UnixFileSystemProvider.getPath(UnixFileSystemProvider.java:98)
at java.nio.file.Paths.get(Paths.java:138)
at com.sun.nio.zipfs.ZipFileSystemProvider.uriToPath(ZipFileSystemProvider.java:85)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:107)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:322)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:272)
at apu.scratch.converter.ScratchConverter.writeToZip(Unknown Source)
at apu.scratch.converter.ScratchConverter.main(Unknown Source)

Unable to write to destination file. Make sure you have the correct permissions.
Usage:
java -jar apuc-compile.jar <source> <destination>
Compiles ApuC code
source: The text file containing your source code
destination: A sprite2 or zip file to put the code in

java -jar apuc-compile.jar -help
Prints this section.

!
DigiTechs
Scratcher
500+ posts

ApuC - A C-based language that compiles to Scratch JSON

djdolphin wrote:

I get this whenever I try to compile something:
name:test name$ java -jar apuc-compile.jar test.apuc test.sprite2
Done
java.lang.IllegalArgumentException: URI has an authority component
at sun.nio.fs.UnixUriUtils.fromUri(UnixUriUtils.java:53)
at sun.nio.fs.UnixFileSystemProvider.getPath(UnixFileSystemProvider.java:98)
at java.nio.file.Paths.get(Paths.java:138)
at com.sun.nio.zipfs.ZipFileSystemProvider.uriToPath(ZipFileSystemProvider.java:85)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:107)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:322)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:272)
at apu.scratch.converter.ScratchConverter.writeToZip(Unknown Source)
at apu.scratch.converter.ScratchConverter.main(Unknown Source)

Unable to write to destination file. Make sure you have the correct permissions.
Usage:
java -jar apuc-compile.jar <source> <destination>
Compiles ApuC code
source: The text file containing your source code
destination: A sprite2 or zip file to put the code in

java -jar apuc-compile.jar -help
Prints this section.

Try running it with ‘sudo’ permission. That looks like the problem, although that is pretty odd.

I do, in fact, have my own site; it's here.
I'm also working on a thing called Fetch. Look at it here!
@thisandagain pls explain. @thisandagain pls explain. @thisandagain pls explain. @thisandagain pls explain. @thisandagain pls explain.
djdolphin
Scratcher
1000+ posts

ApuC - A C-based language that compiles to Scratch JSON

DigiTechs wrote:

djdolphin wrote:

I get this whenever I try to compile something:
name:test name$ java -jar apuc-compile.jar test.apuc test.sprite2
Done
java.lang.IllegalArgumentException: URI has an authority component
at sun.nio.fs.UnixUriUtils.fromUri(UnixUriUtils.java:53)
at sun.nio.fs.UnixFileSystemProvider.getPath(UnixFileSystemProvider.java:98)
at java.nio.file.Paths.get(Paths.java:138)
at com.sun.nio.zipfs.ZipFileSystemProvider.uriToPath(ZipFileSystemProvider.java:85)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:107)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:322)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:272)
at apu.scratch.converter.ScratchConverter.writeToZip(Unknown Source)
at apu.scratch.converter.ScratchConverter.main(Unknown Source)

Unable to write to destination file. Make sure you have the correct permissions.
Usage:
java -jar apuc-compile.jar <source> <destination>
Compiles ApuC code
source: The text file containing your source code
destination: A sprite2 or zip file to put the code in

java -jar apuc-compile.jar -help
Prints this section.

Try running it with ‘sudo’ permission. That looks like the problem, although that is pretty odd.
Nope. That didn't help.

!
DigiTechs
Scratcher
500+ posts

ApuC - A C-based language that compiles to Scratch JSON

djdolphin wrote:

DigiTechs wrote:

djdolphin wrote:

I get this whenever I try to compile something:
name:test name$ java -jar apuc-compile.jar test.apuc test.sprite2
Done
java.lang.IllegalArgumentException: URI has an authority component
at sun.nio.fs.UnixUriUtils.fromUri(UnixUriUtils.java:53)
at sun.nio.fs.UnixFileSystemProvider.getPath(UnixFileSystemProvider.java:98)
at java.nio.file.Paths.get(Paths.java:138)
at com.sun.nio.zipfs.ZipFileSystemProvider.uriToPath(ZipFileSystemProvider.java:85)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:107)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:322)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:272)
at apu.scratch.converter.ScratchConverter.writeToZip(Unknown Source)
at apu.scratch.converter.ScratchConverter.main(Unknown Source)

Unable to write to destination file. Make sure you have the correct permissions.
Usage:
java -jar apuc-compile.jar <source> <destination>
Compiles ApuC code
source: The text file containing your source code
destination: A sprite2 or zip file to put the code in

java -jar apuc-compile.jar -help
Prints this section.

Try running it with ‘sudo’ permission. That looks like the problem, although that is pretty odd.
Nope. That didn't help.

Okay, that's odd. I don't know then.

I do, in fact, have my own site; it's here.
I'm also working on a thing called Fetch. Look at it here!
@thisandagain pls explain. @thisandagain pls explain. @thisandagain pls explain. @thisandagain pls explain. @thisandagain pls explain.
MegaApuTurkUltra
Scratcher
1000+ posts

ApuC - A C-based language that compiles to Scratch JSON

djdolphin wrote:

I get this whenever I try to compile something:
name:test name$ java -jar apuc-compile.jar test.apuc test.sprite2
Done
java.lang.IllegalArgumentException: URI has an authority component
at sun.nio.fs.UnixUriUtils.fromUri(UnixUriUtils.java:53)
at sun.nio.fs.UnixFileSystemProvider.getPath(UnixFileSystemProvider.java:98)
at java.nio.file.Paths.get(Paths.java:138)
at com.sun.nio.zipfs.ZipFileSystemProvider.uriToPath(ZipFileSystemProvider.java:85)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:107)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:322)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:272)
at apu.scratch.converter.ScratchConverter.writeToZip(Unknown Source)
at apu.scratch.converter.ScratchConverter.main(Unknown Source)

Unable to write to destination file. Make sure you have the correct permissions.
Usage:
java -jar apuc-compile.jar <source> <destination>
Compiles ApuC code
source: The text file containing your source code
destination: A sprite2 or zip file to put the code in

java -jar apuc-compile.jar -help
Prints this section.
Hmm I've only tested on Windows so thanks for discovering this! I'll get on it.

I found this stackoverflow Q on the topic. Are you using a UNC path? Since I'm on Windows, I replaced all backslashes with forward slashes in URIs but that may be a problem…

$(".box-head")[0].textContent = "committing AT crimes since $whenever"
djdolphin
Scratcher
1000+ posts

ApuC - A C-based language that compiles to Scratch JSON

MegaApuTurkUltra wrote:

djdolphin wrote:

I get this whenever I try to compile something:
name:test name$ java -jar apuc-compile.jar test.apuc test.sprite2
Done
java.lang.IllegalArgumentException: URI has an authority component
at sun.nio.fs.UnixUriUtils.fromUri(UnixUriUtils.java:53)
at sun.nio.fs.UnixFileSystemProvider.getPath(UnixFileSystemProvider.java:98)
at java.nio.file.Paths.get(Paths.java:138)
at com.sun.nio.zipfs.ZipFileSystemProvider.uriToPath(ZipFileSystemProvider.java:85)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:107)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:322)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:272)
at apu.scratch.converter.ScratchConverter.writeToZip(Unknown Source)
at apu.scratch.converter.ScratchConverter.main(Unknown Source)

Unable to write to destination file. Make sure you have the correct permissions.
Usage:
java -jar apuc-compile.jar <source> <destination>
Compiles ApuC code
source: The text file containing your source code
destination: A sprite2 or zip file to put the code in

java -jar apuc-compile.jar -help
Prints this section.
Hmm I've only tested on Windows so thanks for discovering this! I'll get on it.

I found this stackoverflow Q on the topic. Are you using a UNC path? Since I'm on Windows, I replaced all backslashes with forward slashes in URIs but that may be a problem…
I'm using a Mac. The directory name separator thingy is ‘/’. I don't know if that's what UNC is.

Last edited by djdolphin (Aug. 26, 2014 19:47:37)


!
MegaApuTurkUltra
Scratcher
1000+ posts

ApuC - A C-based language that compiles to Scratch JSON

djdolphin wrote:

MegaApuTurkUltra wrote:

djdolphin wrote:

I get this whenever I try to compile something:
name:test name$ java -jar apuc-compile.jar test.apuc test.sprite2
Done
java.lang.IllegalArgumentException: URI has an authority component
at sun.nio.fs.UnixUriUtils.fromUri(UnixUriUtils.java:53)
at sun.nio.fs.UnixFileSystemProvider.getPath(UnixFileSystemProvider.java:98)
at java.nio.file.Paths.get(Paths.java:138)
at com.sun.nio.zipfs.ZipFileSystemProvider.uriToPath(ZipFileSystemProvider.java:85)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:107)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:322)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:272)
at apu.scratch.converter.ScratchConverter.writeToZip(Unknown Source)
at apu.scratch.converter.ScratchConverter.main(Unknown Source)

Unable to write to destination file. Make sure you have the correct permissions.
Usage:
java -jar apuc-compile.jar <source> <destination>
Compiles ApuC code
source: The text file containing your source code
destination: A sprite2 or zip file to put the code in

java -jar apuc-compile.jar -help
Prints this section.
Hmm I've only tested on Windows so thanks for discovering this! I'll get on it.

I found this stackoverflow Q on the topic. Are you using a UNC path? Since I'm on Windows, I replaced all backslashes with forward slashes in URIs but that may be a problem…
I'm using a Mac. The directory name separator thingy is ‘/’. I don't know if that's what UNC is.
I don't exactly know what it is either… I'm assuming it's something to do with backslashes somewhere where regular slashes don't belong.

Anyway I changed some code and it might fix the problem. Download the latest version from the top post.

$(".box-head")[0].textContent = "committing AT crimes since $whenever"
djdolphin
Scratcher
1000+ posts

ApuC - A C-based language that compiles to Scratch JSON

MegaApuTurkUltra wrote:

djdolphin wrote:

MegaApuTurkUltra wrote:

djdolphin wrote:

I get this whenever I try to compile something:
name:test name$ java -jar apuc-compile.jar test.apuc test.sprite2
Done
java.lang.IllegalArgumentException: URI has an authority component
at sun.nio.fs.UnixUriUtils.fromUri(UnixUriUtils.java:53)
at sun.nio.fs.UnixFileSystemProvider.getPath(UnixFileSystemProvider.java:98)
at java.nio.file.Paths.get(Paths.java:138)
at com.sun.nio.zipfs.ZipFileSystemProvider.uriToPath(ZipFileSystemProvider.java:85)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:107)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:322)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:272)
at apu.scratch.converter.ScratchConverter.writeToZip(Unknown Source)
at apu.scratch.converter.ScratchConverter.main(Unknown Source)

Unable to write to destination file. Make sure you have the correct permissions.
Usage:
java -jar apuc-compile.jar <source> <destination>
Compiles ApuC code
source: The text file containing your source code
destination: A sprite2 or zip file to put the code in

java -jar apuc-compile.jar -help
Prints this section.
Hmm I've only tested on Windows so thanks for discovering this! I'll get on it.

I found this stackoverflow Q on the topic. Are you using a UNC path? Since I'm on Windows, I replaced all backslashes with forward slashes in URIs but that may be a problem…
I'm using a Mac. The directory name separator thingy is ‘/’. I don't know if that's what UNC is.
I don't exactly know what it is either… I'm assuming it's something to do with backslashes somewhere where regular slashes don't belong.

Anyway I changed some code and it might fix the problem. Download the latest version from the top post.
It works now. Yay! Did you see my suggestions up there?

!
davidkt
Scratcher
1000+ posts

ApuC - A C-based language that compiles to Scratch JSON

You should make a doc for experienced programmers. I'm getting tired of scrolling through all this beginnerish stuff.

Remember when I looked like this? I still do.


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

ApuC - A C-based language that compiles to Scratch JSON

More suggestions:
  • Let users specify a template sprite instead of the one included in the .jar.
  • Compile whole projects if you specify a folder full of template .sprite2 files and .apuc files with the same names. If there's a file named Stage.sprite2, that will be used as the Stage's template.

!

Powered by DjangoBB