? N# Compiler v1.8 ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password
Another contest? You asked for it!

N# Compiler v1.8

Submitted
Updated
Author
phil_
Public Key
CKANY53Y
Min. Compat.
All
Version
Beta 1.7
Rating
24 votes
Description 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.
Categories
Keywords
62 Comment(s) NateDogg1232 NateDogg1232 Night Person I like the quiet night and sleep late. Express Yourself Avatar Taboo I didn't change my avatar for 180 days Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength 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) banana banana RNG Hidden Easter Eggs Disguised Hidden Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength You're talking about non-static members? NateDogg1232 NateDogg1232 Night Person I like the quiet night and sleep late. Express Yourself Avatar Taboo I didn't change my avatar for 180 days Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Yes, I'm talking about non-static arrays. Sorry, the term was blanking my mind. SaladFingers SaladFingers Avatar Embargo I didn't change my avatar for 90 days Website @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 :/ Chemicalex Chemicalex Drawing I like to draw! Hobbies RNG Hidden Easter Eggs Video Games I like to play video games! Hobbies If you would like to contact Phil directly, there's a message box built just for this purpose. NateDogg1232 NateDogg1232 Night Person I like the quiet night and sleep late. Express Yourself Avatar Taboo I didn't change my avatar for 180 days Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength SBExecutable is just SB code. That's all. AnswerXOX AnswerXOX First Year My account is over 1 year old Website Great Page Hidden Achievements Touhou Project Is Awesome! I love Touhou Project! Express Yourself PFFFFFTTTT AnswerXOX AnswerXOX First Year My account is over 1 year old Website Great Page Hidden Achievements Touhou Project Is Awesome! I love Touhou Project! Express Yourself 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 ._. banana banana RNG Hidden Easter Eggs Disguised Hidden Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength how do you make a higher order function? banana banana RNG Hidden Easter Eggs Disguised Hidden Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength 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 AnswerXOX AnswerXOX First Year My account is over 1 year old Website Great Page Hidden Achievements Touhou Project Is Awesome! I love Touhou Project! Express Yourself 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 AnswerXOX AnswerXOX First Year My account is over 1 year old Website Great Page Hidden Achievements Touhou Project Is Awesome! I love Touhou Project! Express Yourself 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 phil_ phil_ Scholar Received for knowing a great deal about programming topics Achievements osu! Is Awesome! I love osu! Express Yourself First Day Joined on the very first day of SmileBASIC Source Website I probably won't redo it, but I can't say for certain I won't. If the demand gets high enough I might. MasterR3C0RD MasterR3C0RD Helper Received for being very helpful around SmileBASIC Source Achievements Second Year My account is over 2 years old Website osu! Is Awesome! I love osu! Express Yourself Crowds gather in chat REDO N#! REDO N#! echos through the chatserver. MYCRAFTisbest MYCRAFTisbest Good Page Hidden Achievements Video Games I like to play video games! Hobbies Avatar Taboo I didn't change my avatar for 180 days Website N# 2 CONFIRMED! AnswerXOX AnswerXOX First Year My account is over 1 year old Website Great Page Hidden Achievements Touhou Project Is Awesome! I love Touhou Project! Express Yourself 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 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Turns out the echos were just a bird slamming into the door AnswerXOX AnswerXOX First Year My account is over 1 year old Website Great Page Hidden Achievements Touhou Project Is Awesome! I love Touhou Project! Express Yourself I'm working on a guide: https://docs.google.com/document/d/1tzDcRIDJpDpERJ5E5xgZH0jOxGylnzawUsPOtcwhZfk/edit?usp=sharing AnswerXOX AnswerXOX First Year My account is over 1 year old Website Great Page Hidden Achievements Touhou Project Is Awesome! I love Touhou Project! Express Yourself Comments are enabled btw AnswerXOX AnswerXOX First Year My account is over 1 year old Website Great Page Hidden Achievements Touhou Project Is Awesome! I love Touhou Project! Express Yourself 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? AnswerXOX AnswerXOX First Year My account is over 1 year old Website Great Page Hidden Achievements Touhou Project Is Awesome! I love Touhou Project! Express Yourself When will N# be able to support DLC phil_ phil_ Scholar Received for knowing a great deal about programming topics Achievements osu! Is Awesome! I love osu! Express Yourself First Day Joined on the very first day of SmileBASIC Source Website Just type the DLC commands directly into N# and use them as you would SB. They should work. NateDogg1232 NateDogg1232 Night Person I like the quiet night and sleep late. Express Yourself Avatar Taboo I didn't change my avatar for 180 days Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength I believe you still need to use the [SB] notation. Just a heads up phil_ phil_ Scholar Received for knowing a great deal about programming topics Achievements osu! Is Awesome! I love osu! Express Yourself First Day Joined on the very first day of SmileBASIC Source Website [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. NateDogg1232 NateDogg1232 Night Person I like the quiet night and sleep late. Express Yourself Avatar Taboo I didn't change my avatar for 180 days Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength May I ask the origins of the name "N#" I'm a little curious MasterR3C0RD MasterR3C0RD Helper Received for being very helpful around SmileBASIC Source Achievements Second Year My account is over 2 years old Website osu! Is Awesome! I love osu! Express Yourself 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. Guzzler Guzzler First Week Joined in the very first week of SmileBASIC Source Website Drawing I like to draw! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Cool. plinkopenguin plinkopenguin Thanks for the info again! phil_ phil_ Scholar Received for knowing a great deal about programming topics Achievements osu! Is Awesome! I love osu! Express Yourself First Day Joined on the very first day of SmileBASIC Source Website 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 plinkopenguin 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. NateDogg1232 NateDogg1232 Night Person I like the quiet night and sleep late. Express Yourself Avatar Taboo I didn't change my avatar for 180 days Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength 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 16bitcoder 16bitcoder 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! phil_ phil_ Scholar Received for knowing a great deal about programming topics Achievements osu! Is Awesome! I love osu! Express Yourself First Day Joined on the very first day of SmileBASIC Source Website @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. 16bitcoder 16bitcoder I'm sorry, I mistyped... :( 16bitcoder 16bitcoder Facinating! Another coding language interpreter on SmileBasic Minxrod Minxrod Summer 2016 Contest Participant I participated in the SmileBASIC Source Summer 2016 Contest! Programming Contest Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Pokemon Is Awesome! I love Pokemon! Express Yourself It's a compiler, not an interpreter :) It's actually kind of a big difference I think 16bitcoder 16bitcoder I mistyped? Sorry for my mistype. Minxrod Minxrod Summer 2016 Contest Participant I participated in the SmileBASIC Source Summer 2016 Contest! Programming Contest Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Pokemon Is Awesome! I love Pokemon! Express Yourself Ok. Sorry to bug you then ;) 16bitcoder 16bitcoder Don't worry Minxrod, it is quite all right. plinkopenguin plinkopenguin Oh I see. Thanks! phil_ phil_ Scholar Received for knowing a great deal about programming topics Achievements osu! Is Awesome! I love osu! Express Yourself First Day Joined on the very first day of SmileBASIC Source Website Plinko, the .LIB files are all coded in N#, so feel free to browse those. plinkopenguin plinkopenguin This looks really neat. Are there more code examples? 1 2