Code Monkey home page Code Monkey logo

odd's Introduction

Odd Language

An orange square with rounded corners and a thick, fat, darker orange outline. Within the square, the name of the language is carved out and outlined identically. The ascenders of the two d's extend out of the square's outline.

Hmm, that's odd...



🧠 Philosophy

Odd is highly W.I.P. but these are the main goals of the language:

  • Odd must have functional, expressive and flowing syntax.
    • Programming "patterns" are often a sign of lacking expressiveness within a language. We like a solid language over SOLID patterns.
    • Programs are read far more often than they are written. Odd should contain little to no weird jumps in program flow for readers to trip over.
  • Odd must have no (unnecessary) dependencies.
    • Full ownership of the codebase ensures any bug is our responsibility to fix, but also any feature ours to add.
  • Odd must run on every machine (within reason, of course).
    • WebAssembly is a promising target platform to immediately work on most devices.
    • A tiny footprint should allow the language to be used or embedded anywhere. Imagine your IOT devices running Odd đŸ¤¯.
    • Having an old(er) or less powerful device should never be a reason to be unable to program.


🤸 Contribute

Feel free to contribute. Please read our contributing guidelines and then create an issue or a pull request.



đŸ–Ĩī¸ Usage

Download the latest release here.

Local development

Firstly, make sure you have installed NodeJS and its package manager, npm.

Odd is guaranteed to work with Bun version 1.1.7 and NodeJS version 20.11.1, but should be compatible with earlier Node versions down to v12 (inclusive, possibly requiring the --harmony flag).

We recommend you use Yarn as a package manager over npm. Of course, using npm is fully supported, and it comes with Node out-of-the-box!

Afterwards, open up your shell of choice and run the following commands:

yarn; # install dependencies (you can use npm i).
bun run repl; # start a repl

Compiling from source

You can compile the source to a binary yourself, using the build command:

bun run build; # compile
./build/odd # run the repl binary.

For a more in-depth look at how Odd works, have a look at the documentation.



đŸ—ēī¸ Roadmap

Some work has yet to be done for odd to release as v1.0. The following is a list of development milestones to get to v1.0:

  • 0.1: CLI REPL
  • 0.2: Modules
  • 0.3: Pattern matching
  • 0.4: Type system (ℹī¸ available for testing in v0.4.0-alpha)
  • 0.5: LSP for proper editor integration
  • 0.6: Intelligble and helpful errors

...

  • 1.0: 🏁 Standalone executable for real-world use.


Š License

Conceptualised and authored by @maanlamp. This project is licensed under MIT.

odd's People

Contributors

dependabot[bot] avatar maanlamp avatar thomaslem avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

thomaslem

odd's Issues

Create eslint config

Your codestyle is all over the place, and contributers have no idea what style to use. Make an odd eslint config please :)

Rewrite lexer

The lexer works but I cannot remember what anything does. That's bad. Please rewrite your horrible mess you dummy.

Make the entire processor pipeline work with streams

For testing, we're processing small files. When the language will be used in bigger projects, it will not scale if it has to load and save everything into memory. Streams were introduced exactly for this use case, so we should use them.

Log the correct unidentifiable lexeme when throwing an error

When the lexer has gone through all defined grammars but finds none, it throws an error. Currently it just says that the unidentifiable lexeme and the entire string after it are all unidentifiable. The lexeme should be cut off at a point where actually no grammar can be found.

Rewrite lexer to use modular grammar

The old architecture does not allow scaling in any way. All features must be hacked into the code. Even the cleanest code is a chore to traverse if all you want to do is add a feature, or just update a certain part of the compiler. By transitioning to a more plugin-based architecture, we explicitly design all parts of the language as plugins, allowing for easy additions and removals, as well as a inherently easy-to-maintain structure.

Allow for several levels of specificity of lexical token types

There are some lexemes that benefit from having a very specific type, but it would alse be very useful for developing to adress a generalised group of specifik tokens, ergo:

const allowedTypes = [
  "integer number",
  "floating point number",
  "single line comment",
  "multi line comment"
];
//Check something against allowedTypes

Could (and should) be shortened by generalising them as such:

const allowedTypes = [
  "number",
  "comment"
];
//Check something against allowedTypes

We need to think about wether it's useful to implement this as a lexer feature, or if we sould just check if the type includes the shortened version (as a whole word).

Perhaps in a way like this:

const Lexer = require("./Lexer");
const lexer = new Lexer();
lexer.rule("super,specific,type", /regex/);
/* > LexicalToken: {
  types: ["super", "specific", "type"],
  type: "super.specific.type",
  lexeme: ...
} */

This would require every token to either have a new property which is an array of all levels of specificity separated by a delimiter, or just store the raw string as a type and splitting by delimitter on demand.

Lexer freezes sometimes after finding unrecognised lexemes

When an error occurs, the cause of the error will be stripped out of the input, and will be used for error logging. This normally works, but in some cases it will freeze the lexer. No idea why yet.

This does not freeze

const 💩 = 13;

This does freeze

const 💩 💩 = 13;

It seems this is caused by having any other unrecognised lexeme after any recognised tokens, such as the whitespace in the aforementioned example.

Assigning multiple lexical tokens with one regex

As of now, you can only assign a single token that complies to a single rule, but regular expressions can give back countless matches. We should look into a syntax for assigning multiple tokens with one regex, e.g:

const Lexer = require("./Lexer");
const lexer = new Lexer();
lexer.rule([
  "builtin math",
  "operator",
  "builtin math method"
], /\b(Math)(.?)(floor|round|ceil)\b/);

Make preprocessor recognise directives

The preprocessor does not work yet. In order for it to work, it must recognise the beginning and ending of preprocessor directives from tokens generated by the lexer.

Rewrite entire compiler architecture to be (more) modular

The old architecture does not allow scaling in any way. All features must be hacked into the code. Even the cleanest code is a chore to traverse if all you want to do is add a feature, or just update a certain part of the compiler. By transitioning to a more plugin-based architecture, we explicitly design all parts of the language as plugins, allowing for easy additions and removals, as well as a inherently easy-to-maintain structure.

Have seperate processor stages

In order for some plugins (such as the preprocessor) to work, they must be able to access the token stream instead of an AST. There should be a way for a user to tell a plugin what stage to hook into.

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.