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.

This looks really neat. Are there more code examples?

Plinko, the .LIB files are all coded in N#, so feel free to browse those.

Oh I see. Thanks!

Facinating! Another coding language interpreter on SmileBasic

Replying to:16bitcoder
Facinating! Another coding language interpreter on SmileBasic
It's a compiler, not an interpreter :) It's actually kind of a big difference I think

Replying to:16bitcoder
Facinating! Another coding language interpreter on SmileBasic
I mistyped? Sorry for my mistype.

Replying to:16bitcoder
Facinating! Another coding language interpreter on SmileBasic
Ok. Sorry to bug you then ;)

Replying to:16bitcoder
Facinating! Another coding language interpreter on SmileBasic
Don't worry Minxrod, it is quite all right.

@16bitcoder An interpreter is an engine that reads a line of code, executes it, and then continues to read the next line, the one after that, etc. A compiler reads all of the lines of code at once, parses them, and outputs a format that can be read by the computer. The reason N# is a compiler is that it compiles (or converts) N# into SB, which is then converted into SBExecutable. Because it converts into pure SB, it runs faster and does not require the compiler to run. This also means code does not have to be open-source.

Replying to:computablee
@16bitcoder An interpreter is an engine that reads a line of code, executes it, and then continues to read the next line, the one after that, etc. A compiler reads all of the lines of code at once, parses them, and outputs a format that can be read by the computer. The reason N# is a compiler is that it compiles (or converts) N# into SB, which is then converted into SBExecutable. Because it converts into pure SB, it runs faster and does not require the compiler to run. This also means code does not have to be open-source.
I'm sorry, I mistyped... :(

Thanks for the insperation for the title of basiccode2 (#AC) which is an interpreter so that is why I mistyped! My codinng is based off of BasicTron and Python!

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.

To initialize sprites (untested code, may need tweaking)
use "Sprite"
static class entry
  def public void main()
    object mysprite <- Sprite
    mysprite = Sprite.Init(0)
    'Now "mysprite" represents the sprite that appears on screen. You can do stuff like mtsprite.Move to move it.
    delete mysprite 'memory handling
  end
end static
EDIT: In the new version Beta 1.7, initializing sprites has been changed.
use "Sprite"
static class entry
  def public void main()
    object mysprite <- Sprite = 0
    'Now "mysprite" represents the strawberry on the screen.
    'You can change the number to change the sprite, but once created, it cannot be changed
    mysprite = [| 100, 100 |]
    'Assigning coordinates via array notation will automatically change the location of the sprite, so now "mysprite" appears at location 100,100
    mysprite.Clear
    delete mysprite
  end
end static

Thanks for the info again!

May I ask the origins of the name "N#" I'm a little curious

Replying to:NateDogg1232
May I ask the origins of the name "N#" I'm a little curious
The original name of the compiler was Nossrec (which was something I thought of: Persson backwards, but instead of starting with P, starting with C, because this was based off of C# and other similar languages), so that's where the N comes from. The # comes from C#, since this is sort of like C# in quite a few ways.

Replying to:NateDogg1232
May I ask the origins of the name "N#" I'm a little curious
Cool.

When will N# be able to support DLC

Replying to:answer
When will N# be able to support DLC
Just type the DLC commands directly into N# and use them as you would SB. They should work.

Replying to:answer
When will N# be able to support DLC
I believe you still need to use the [SB] notation. Just a heads up