Skip to content

David Callanan (owner of the CodePulse YouTube channel)'s programming language, ++'d

License

Notifications You must be signed in to change notification settings

angelcaru/myopl-plus-plus

 
 

Repository files navigation

MYOPL++

David's language with some improvements. That's it.

Additions so far:

  • Multi-line comments. #* multi-line comment *#
  • Import statements. IMPORT "./path/to/library/some_library.myopl"
  • Optional parameters. FUN a(x, y=1, z=2) -> x+y+z; a(1); a(1, 2); a(1, 2, 3)
  • Closures: In the original, FUN wrapper(x) -> FUN haxxor() -> x; FUN defineX(x, f) -> f(); PRINT(defineX("hacked", wrapper("closure working"))) would print hacked instead of the expected result of closure working. This functionality is now implemented properly.
  • DO expression. DO [stuff] END. Full behavior in do.myopl
  • TRY statement. TRY PRINT(1/0) CATCH AS error; PRINT("uhhhhhhhhhhhhhhhhhhh... infinity?"); PRINT(error); END
  • Dynamic arguments. FUN whatever(arg FROM $/2) -> arg; PRINT(whatever(1))
  • No VAR keyword. Just assign variables with <name> = <expr>
  • FOR-IN loops. FOR char IN "abc" THEN PRINT(char)
  • Proper indexing. list = [1, 2, 3]; PRINT(list[0]); list[0] = 4; PRINT(list[0])
  • Dictionaries. dict = {"abc": 123}. Full behavior in dict.myopl
  • Added file descriptor-based file I/O. file-io.myopl
  • Backslash makes lexer skip next character.
  • More escape characters. The lexer now supports every single escape sequence Python does, including stuff like "Hello,\x0AWorld".
  • _ variable is automatically set to the last evaluated expression in the REPL.
  • Top-level RETURN (exit code)
  • SWITCH statements (my language is now better than Python 3.9). switch.myopl
  • WAIT function.
  • ARGV variable.
  • CONST keyword. CONST x = 3; x = 4 # error

-- Original README starts below --

py-myopl-code

All code for my "Make your own programming language in Python" tutorial series on YouTube: https://www.youtube.com/playlist?list=PLZQftyCk7_SdoVexSmwy_tBgs7P0b97yD

This code is an interpreter for a BASIC-like language written in Python 3.

The latest code is in the folder which is for the latest episode (ep14).

I'm now finished with the development of this project, and the tutorials are complete on YouTube.

Forks

Improvements have been made by others so I'll link to them here:

  • AdrianGjerstad - started on standard library and added string indexing

About

David Callanan (owner of the CodePulse YouTube channel)'s programming language, ++'d

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%