LoginLogin

N# Compiler v1.8

Root / Submissions / [.]

computableeCreated:
Download:CKANY53Y
Version:Beta 1.7Size:
The N# Compiler is a compiler that reads N# code and outputs legal SmileBasic code. Its intention is to be an optional COMPLETE replacement for SmileBasic, as it contains the ability to do all that SB can do, plus more, easier. N# is a multi-paradigm (Object-Oriented, Functional) language with extra capabilities that SB does not have (such as classes, lazy evaluation, higher-order functions, etc.). The compiler eliminates need for variable and function suffixes (the compiler handles them automatically) and improves syntax of existing commands (for example, C-style "for," "while," "if," etc). N# is not an extension of SB, but rather a total replacement. It is not the same language by any means. All code must be in a function, and all functions should be in a class. If a function is not in a class, it will assume inheritance by the next occurring class. The compiler automatically runs "entry.main" at program start. Here's the official discussion/help thread: http://smilebasicsource.com/forum?fpid=5814

Instructions:

[N# manual has not been published] 1: Set PRG:N_SHARP as your SmileTool. 2: Write your N# program in slot 0 of the editor. 3: When you're ready to compile, press the Smile button. Your program will compile and will appear in slot 1 of the editor. This new PRG file is in pure SB, so it can be loaded, saved, and published independent of any N# tools. N# "Hello World" example:
use "Console"

static class entry
 def public void main()
  Console.Println "Hello World!"
 end
end static
As this is Beta, there are a few glitches I am aware of. However, almost all of these are crunched, and so the development should hopefully come out of beta soon. Update List: Beta v1.0: *Original publication Beta v1.1: *Private functions *Changed array declaration syntax *Fixed calculator example *Bug fixes Beta 1.2 *Revamped objects *Assigning objects class references *Bug fixes Beta 1.3 *Library importing *Completed object functionality *MML and Graphics classes *Class variables (private keyword doesn't work yet with these) *Passing an object's value as a parameter works now *Inline SB editor using [SB] tag in front of a line *Bug fixes Beta 1.4 * += and -= operators to work on objects * /=, %=, *=, <<=, and >>= operators added * % instead of MOD *Console and Hardware class *Class variables *Immutable value types *Foreach blocks *Basic array comprehension using [| and |] *Compile code to a standalone PRG! (No more mandatory runtime compilation) *Bug fixes Beta 1.5 *Changed syntax of switch blocks ("end" is no longer required after each case, only at the very end) *Changed compilation process of +=, -=, *=, /=, %=, <<=, and >>= (this does not affect the user) *Removed runtime compiler *Added progress bar to compilation *Removed support for labels *Partial sprite library *App library *Resource library *Bug fixes Beta 1.6 *By reference parameter passing *Brace syntax *Dictionary library *Wildcard variable (equal to anything) *Runs as SmileTool (much easier to use) *Ignore command *Lambdas and higher-order functions *Bug Fixes Beta 1.7 *Getter functions *Setter functions *Init functions *Modified Sprite and MML classes Beta 1.8 *Lazy evaluation *eval() function *BigInt library Expected Updates: Beta 1.9 *Completed Sprite Library *Function overloading *Bug Fixes

Notes:

Intended for use by experienced programmers.

Replying to:answer
When will N# be able to support DLC
[SB] tells the compiler to not parse ANYTHING on the line, including possible variables, function suffixes, etc. However, if a command is unknown to the compiler, it will pass it directly to the output. Often times, [SB] actually isn't needed at all where you might use it.

I feel like N# should still have keys with objects, and with each object(like in Java) should have set variables within it, I cannot add this myself as the code is too obfuscating; is there a less obfuscating source code you have lying around?



I'm sorry, but this is so outdated; do you think there will ever be a time where you will basically reset the project, this has a lot of potential, but I've discontinued to use this because it kind of needs an update and needs to be more similar to the syntax of C# if this is where you're trying to go. I'd really appreciate it if you continue this great language, but its flaws need work

Replying to:answer
I'm sorry, but this is so outdated; do you think there will ever be a time where you will basically reset the project, this has a lot of potential, but I've discontinued to use this because it kind of needs an update and needs to be more similar to the syntax of C# if this is where you're trying to go. I'd really appreciate it if you continue this great language, but its flaws need work
I probably won't redo it, but I can't say for certain I won't. If the demand gets high enough I might.

Replying to:answer
I'm sorry, but this is so outdated; do you think there will ever be a time where you will basically reset the project, this has a lot of potential, but I've discontinued to use this because it kind of needs an update and needs to be more similar to the syntax of C# if this is where you're trying to go. I'd really appreciate it if you continue this great language, but its flaws need work
Crowds gather in chat REDO N#! REDO N#! echos through the chatserver.

Replying to:answer
I'm sorry, but this is so outdated; do you think there will ever be a time where you will basically reset the project, this has a lot of potential, but I've discontinued to use this because it kind of needs an update and needs to be more similar to the syntax of C# if this is where you're trying to go. I'd really appreciate it if you continue this great language, but its flaws need work
N# 2 CONFIRMED!

Replying to:answer
I'm sorry, but this is so outdated; do you think there will ever be a time where you will basically reset the project, this has a lot of potential, but I've discontinued to use this because it kind of needs an update and needs to be more similar to the syntax of C# if this is where you're trying to go. I'd really appreciate it if you continue this great language, but its flaws need work
The only REAL problem is the way objects are designed, like, referencing the object within the class does not work. You should also be able to access object properties with keys as well rather than referencing the object's value
class MyClass
    int myInteger
    string myString
    def public void doSomething()
        print this.myString
    end
end

static class entry
    def public void main()
        object it <- MyClass
        it.myString = "Hello"
        it.doSomething()
    end
end
I'd love it if something like this would work

Replying to:answer
I'm sorry, but this is so outdated; do you think there will ever be a time where you will basically reset the project, this has a lot of potential, but I've discontinued to use this because it kind of needs an update and needs to be more similar to the syntax of C# if this is where you're trying to go. I'd really appreciate it if you continue this great language, but its flaws need work
Turns out the echos were just a bird slamming into the door

A little problem of the compiler is that if you do: static class meme public int me 'thats two spaces of indenting end Will parse incorrectly. alsp, lambds are awesome

how do you make a higher order function?

Replying to:hakke
A little problem of the compiler is that if you do: static class meme public int me 'thats two spaces of indenting end Will parse incorrectly. alsp, lambds are awesome
Well, think of it like Python, it kinds of depends on using exact spacing in between blocks Like for example, how blocks require 4 spaces on indentation, every block requires 1 space(only) of indentation. Python
class Hello:
    def World():
        print "Hello, World"
N#
class Hello
 def public void Main()
 end
end class

I feel as though you should really consider this when making the *I'll just just call them* quick array definitions using [||] I feel as though constants should only be optional in the matter and that you should be using something like str() to track the variable's values and the constant values
int[] myArr[0]
myArr = [| 23, someNumber, theClass.ThatHasAMember |]
It's a bit irritating that this won't work and will only work with constants because of the way you designed this ._.

Replying to:plinkopenguin
Sorry to bother again but I can't seem to figure out how to initialize sprites! I keep trying Sprite.Init(0) but I'm very clearly doing it wrong. I should probably wait for the manual but I thought I might ask anyways. Also C# would be the best reference for now right? Thanks for any info.
I know this is a bit late but you can do this:
use "Sprite"

static class entry
 def public void main()
   object mySprite <- Sprite = 0
   'Rest of your code
  end
end static

PFFFFFTTTT

@PhilFish I'm curious, what is SBexecutable? I'm trying to write a python interpreter which, hopefully with your help, will become an interpreter. I'm pretty much down with the graphics, console, and controls libraries. Most control flows are finished except classes :/

Replying to:SaladFingers
@PhilFish I'm curious, what is SBexecutable? I'm trying to write a python interpreter which, hopefully with your help, will become an interpreter. I'm pretty much down with the graphics, console, and controls libraries. Most control flows are finished except classes :/
If you would like to contact Phil directly, there's a message box built just for this purpose.

Replying to:SaladFingers
@PhilFish I'm curious, what is SBexecutable? I'm trying to write a python interpreter which, hopefully with your help, will become an interpreter. I'm pretty much down with the graphics, console, and controls libraries. Most control flows are finished except classes :/
SBExecutable is just SB code. That's all.

A cool thing would be to have an object have its own local arrays that work on an object's instance, not the object as a whole including all its instances (I hope that made sense)