Code Monkey home page Code Monkey logo

em's Introduction

Motivations

  • Some features and syntax that I like and think would be cool
  • I want to type as little as possible, so no need for class/var prefixes because capitalization determines the construct
  • As few reserved words as possible. I want to be able to use any name
  • Integrated documentation where a documentation directory and pages are automatically created from specific comment syntax
  • Web app focused, so server and MVC constructs as standard features
    • The ultimate goal is to create web apps without external libraries like how one might use Rails with Ruby

# requires ruby 3.2.2 or newer
$ ruby source/repl/repl.rb # WIP interactive repl
$ ruby tests/test.rb # parsing and interpreting tests

A few samples of the syntax from tests/cli.em. You can run it with ruby source/cli/cli.rb tests/cli.em

Boo {
    scary = 1234
}

moo { boo ->
	boo.scary
}
!> moo(Boo.new) == 1234 # true

moo_with_comp { &boo_param ->
    scary * 2
}
!> moo_with_comp(Boo.new) == 2468 # true

x = 1;

result = if x == 2 {
  'yes'
else
  'no'
}

boo = 'does interpolation work yet? `result`'
!> boo + ' .. apparently not'

!> 'x before while loop ' + x
while x < 5 {
  x = x + 1
  !> 'x became ' + x
elswhile x < 10 {
  x = x + 2
  !> "This won't print!"
}
!> 'x after while loop ' + x

CONSTANT = 42

get_constant { multiplier = 1.6 ->
	multiplier ** multiplier * CONSTANT
}

!> 1.6 ** 1.6 * 42
!> 'constant: ' + get_constant
!> get_constant(2)

greet_with_arg { name -> 'hello `name`' }
greet_with_label { for name -> 'Mister `name`' }

!> greet_with_arg('Eko')
!> greet_with_label(for: 'Eko')

Some_Class {
  nothing =;

  something = { x y z }

  inspect { ->
    "I am some class"
  }
}

some = Some_Class.new
!> some.something # { x: nil, y: nil, z: nil }
!> some.inspect

See tests/parser.rb or tests/interpreter.rb for more of the syntax.

em's People

Contributors

figgleforth avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.