Skip to content

DELOLCAT/OmniScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

268 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OmniScript: Write once, run wherever you want

NOTICE: OmniScript is still indev, expect breaking changes

For contributing, see CONTRIBUTING.md

OmniScript is a dynamic programming language that focuses on these main features:

  • A ridiculously simple stack based VM (OmniVM) that you could implement almost anywhere - even in Scratch mods (currently only 19 instructions)
  • Readability of code
  • Ease of packaging (code compiles down to a single .omc bytecode file)
  • Compatibility: Supports @require flags (ex. @require fs, gui) so OmniScript can work smoothly across multiple runtime environments. This system is indev, so expect better features in the near future. This also means that runtimes can be even smaller, and also on embedded systems.

Currently implemented features

  • Variables
  • Functions
  • Basic builtins (print, input, to_(type))
  • Arrays (methods indev)
  • The requirements syntax
  • Stack traces
  • Optional function arguments

Usage

Writing a program

Since OmniScript is still in early development, there aren't many features.

  • Types: 'string', integer: 2, float: 3.14, and booleans true/false
  • Functions: name(args)
  • Comments (multi-line soon): # I am a comment

Example:

print('foo, bar', ' baz') # The print function takes multiple arguments, and concatenates them (without a space)
  • Variables:
this_is_a_var = 'foo'
print(this_is_a_var)
  • Arithmetic:
print(5 + 5 / 2)
  • Conditionals:
num = input('Enter a number\n>>> ') # The input function prints a message and waits for user input, returning the input given by the user.

print(num == 5)
if num == 5 {
  print('The number is equal to 5')
} else if num == 10 {
  print('The number is equal to 10')
} else {
  print('The number is not equal to 5 or 10')
}
  • Functions (and recursion):
func fib(n) {
  if n <= 1 {
    return n
  }
  return fib(n - 1) + fib(n - 2)
}

print(fib(10)) # => 55
  • Requirements:
@require strings.methods, attributes # A bare require statement will cause the VM to exit when starting to execute.
print('hi'.upper())

@require types.arrays {
  arr = []
  arr.push('test')
} else {
  print('Arrays not supported') # Any code that tries to use arrays in here will fail to compile
}

@require indexes # All bare require statements are collected. This whole program will fail on launch if the runtime doesn't support indexes
# ...
  • Imports: main.om
import some_mod
print(some_mod.hi())

some_mod.om

export func hi() {
  print('Hello from some_mod!')
  return 'some value'
}

CLI

To run a program, use omni run:

$ omni run examples/fib.om 
55

To compile a program, use omni compile:

$ omni compile examples/fib.om
Compiling with debug (source+line info). See `omni compile --help` for more info
Wrote to examples/fib.omc

To run compiled programs, use omvm run:

$ omvm run ./examples/fib.omc
55

Roadmap

View GithubMilestones (currently v0.1.0) to see progress

(completed features will be moved to Currently Implemented Features)

v0.1.0

  • A Better requirements system
  • Better compiler error messages
  • More advanced imports
  • For loops

v0.2.0

  • Dynamic modules
  • Dictionaries
  • A better standard library (though certain imports, like fs, would need an @require flag)
  • An (optional for max compatibility) binary bytecode format

v0.3.0

  • Classes (via prototypes)
  • A REPL
  • Async support (through an @require flag)

Build

Prerequisites

  • Rust
  • The uv package manager (will also auto-install the correct Python version for this project)

Steps

Clone the repo:

git clone https://github.com/DELOLCAT/OmniScript.git
cd OmniScript

Run build.py with uv:

uv run build.py

The output would be stored in dist/

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages