Share your repls and programming experiences

← Back to all posts
Custom Language Compiler
Geocube101 (591)

This program (which took around 4 or 5 months) compiles a custom language into python for execution. It's not the most efficient language but it was just an idea.

There is now a basic tutorial in the tutorials folder. You can look over each file to see how to use this language

The custom language code will be (by default) compiled from the "program.ccl" file though this can be changed

Supported Functions

  • Variable creation: create <type> : <value> >> <name>
  • Variable modification: set <type> : <value> >> <name>
  • Variable calling: get [new] <type> : <value> >> <target>
  • Variable destruction: destroy <type> [: <name>]
  • Module Importing: import <type> : <path>
  • If statement: if (<condition>) {<code>}
  • Else if statement: else if (<condition>) {<code>}
  • Else statement: else {<code>}
  • While loop: while (<condition>) {<code>}
  • Unless loop: unless (<condition>) {<code>}
  • Once statement: once (<condition>)
  • Support for curly brace formatting
  • Support for functions: create function : <name>[args] >> {<code>}
  • Support for Error throwing: get [new] Error : <value/var_name> >> tracer
  • Support for classes: create class : <name> >> {<code>}
  • Init function: initialize<args> >> {<code>}
  • Support for "entry" hashes and arrays: create entry : <value> : <variable> <key/index/relative_operator>
  • Support "eval(string)" command
  • Support for single line comments: //
  • Support for multi-line comments: /* ... */
  • Support for "for" loop array iteration: for (<type> <name> : <iterable>) {<code>}
  • Support for empty block statements
  • Support for "for" loop range iteration: for (<type> <name> << <initial> : <name> <operator> <max> : <iter_count>)
  • Support for "try/handle" statements: try {<code>} handle(<error_variable>) {<code>}
  • Fixed tracer showing incorrect line numbers

Things WIP

  • Some built-in modules (Mainly the builtin "Thread" module)

Things Planned

  • Optional function parameters

Warnings

  • Still some issues with the for loop range iteration (especially with negatives)
  • Using try/handle will not exempt you from compilation errors (some compilation errors will be nullified when using this)

Please let me know about any bugs and also leave any features you would like to see added (I might add it in)
Note: This program is still being developed but the major things are done, so it may not always work

Commentshotnewtop
Geocube101 (591)

@ChezCoder @EddieHozan @NikoBrooks @Kai_Justice @billehb @MatthewDoan @rediar @pyelias @Vandesm14 @theangryepicbanana
Thanks
I added a few files in the "tutorial" folder of this repl for some information on how to use this language.

rediar (298)

@Geocube101 Maybe you should make a tutorial on the learn board.

Geocube101 (591)

@rediar I'm posting it in parts. The first part is up and is basically just the markdown files copied into the description

Geocube101 (591)

@billehb the main part of the program is complete as all necessary commands have been completed. All that remains are some modules.
Feel free to tell me of any bugs

billehb (15)

it does not work

Geocube101 (591)

@billehb I know, I'm currently trying to implement a new function

Geocube101 (591)

@billehb I've changed some stuff so it should work again
(Still trying to add the "handle" statement)

billehb (15)

@Geocube101 for me as soon as I run it it just says hello works and exits

Geocube101 (591)

@billehb That's all the code in the file. I don't currently have a docs for this but the custom code to compile goes into the "program.ccl" file.
All code to be executed is in that file and it's currently set to print "Hello World"

billehb (15)

@Geocube101 can you let me know egen you are done with the program (I know it can take a Long time I just sant to know when it is done)

ChezCoder (1462)

Change the error line from No Variable Found Called 'VARIABLE NAME' to Couldn't find 'VARIABLE NAME'

Geocube101 (591)

@ChezCoder I could do that, though it may take some time as there are more than one line that checks and outputs a NameError

Geocube101 (591)

@ChezCoder I added a file (called "error_string.json") that allows for people to change the error strings (as I really liked the ones I had hard-coded in). Anyway, some strings use the format() method so those with "{}" in the string must always have "{}" in the string
More info in "tutorials/custom errors.md"