Giter VIP home page Giter VIP logo

hermes-swift's Introduction

Welcome!!! πŸ€“

About Me πŸ‡ΈπŸ‡» πŸ‡¨πŸ‡± πŸ‡¨πŸ‡¦

Hi, my name is Franklin Cruz, I'm a developer I love coding and most of all learn new things, this is my personal GitHub account where I work on my side projects aimed to learn and practice new technologies, while also having fun πŸ˜‰.

I'm mostly specialized in iOS Development, but life has taken me into the path of backend, Android, and a little Web development. My work experience so far:

Current

  • Senior Software Engineer, iOS at League

Past:

Technologies and tools

Here is a list of tools and technoligies I use in to work, some of them you can find it in use here at github and some I use on my current job.

Github Stats

Here are some stats about what I've doing here! πŸ”¬


My Current Projects πŸ§‘πŸΎβ€πŸ’»

Hermes Swift: 🍎

A compiler and interpreter written in swift! based on these great books:

Hermes

My Personal Blog: πŸ•ΈοΈ

I started building this to practice my web development skills that are a bit rusty

Blog

TODO All: πŸ“±

Yeah, I know this is a little cliche but I'm using this project to practice and get familiar with Swift UI and other new frameworks for iOS development. The idea is to build a fully functional TODO app closer to what you'll find in apps like "Todoist" than the typical tutorial app.

Blog

What's comming πŸ€”

I want to learn Go Lang so I'm preparing a new project that will include a backed written in go!

hermes-swift's People

Contributors

yamidaisuke avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

hermes-swift's Issues

Wrong argument count when a built-in function is called inside a closure

Running the following Monkey Code snippet:

let reduce = fn(arr, initial, f) {
    let iter = fn(arr, result) {
        if (len(arr) == 0) {
            result
        } else {
            iter(rest(arr), f(result, first(arr)));
        }
    };
    iter(arr, initial);
};

let sum = fn(arr) {
    reduce(arr, 0, fn(initial, el) { initial + el });
};

let array = [1, 2, 3, 4, 5];
let sumVal = sum(array);
sumVal;

using the compiler is throwing the error:

Incorrect number of arguments in function call expected: 1 but got: 2

This happens because the call for first gets past two arguments the first being the array and the second the captured value of result

Update Readme file

Update readme file to reflect compiler features, command line flags and new implemented language features.

Also put a demo gif with good resolution

Variable names can't contain numbers

Declaring a variable with names like the following:

let a100 = 100;
let b_1 = 1;
let b1a = 10;

Generates an error, however, these are valid identifiers and should be treated as such.

A valid identifier starts with a letter a-Z or underscore and then is followed by any number of letters, numbers, underscores without any space in between.

Support floating point values in Monkey

We should allow the use of floating-point values in both Hermes interpreter and VM for Monkey Lang.

This must include arithmetic and boolean operations with the following rules:

Arithmetic Operators

  • Unary minus: -
  • Addition: +
  • Substract: -
  • Multiplication: *
  • Division: \

Cases

  • float <operator> float = float
  • float <operator> int = float
  • float + string = string

Comparison Operators

  • Lower than: <
  • Lowe than or equal: <=
  • Greater than: >
  • Greater than or equal: >=
  • Equals: ==
  • Not Equals: !=

Cases

  • float <operator: ==, !==> object = boolean
  • float <operator> int = boolean
  • float <operator> float = boolean

Handle non ASCII keys on REPL

Currently the REPL command line tool breaks if non ASCII keys (like arrow keys) are pressed.

The solution will be to handle this keys and allow then to work as expected:

  • up/down Arrorws: Should move between previously typed commands
  • left/right Arrows: Should allow to move in the current input and edit it as needed
  • Other Keys: Should not mess the input and work as expected on any cli

Improve the ".env" REPL command

The REPL supports "commands" in the form of .<command-name> structure, one of the first commands added was env which will print the values store in the current execution environment including inner and outer values.

The current output is not so friendly, particularly for arrays and objects the output can be better. For example:

>>> .env
{
  d: (type: let, value: [100, {"foo" : "bar"}]),
  a: (type: let, value: 100),
  z: (type: let, value: {"env" : "[100, {"foo" : "bar"}]"}),
  b: (type: let, value: {"foo" : "bar"}),
  outer: nil
}

Could be something similar to:

{
  d: (
    type: let, 
    value: [
      100, 
      {
        "foo" : "bar"
      }
    ]
  )
  .....
}

Add all options into the CLI

Description

The CLI tool for Monkey should include all available tools from Hermes

Solution

Support the following features:

  • Run an evaluated REPL
  • Run a compiled REPL
  • Evaluate a Monkey code file (.mky)
  • Compile a Monkey code file (.mky) and generate binary file (.mkc)
  • Execute a Monkey binary file

Support for null literals

null should be accepted as a literal value allowing the following expression to be valid:

let a = fn() {
  return null;
}

a();

Prevent variable redeclaration

Currently we can type the following code:

let a = 10;
a;
let a = 20;
a;

Which will produce the output:

10
20

The line let a = 20; should be considered an error, the correct way will be to assign the value like a = 20;

Quotes inside comments

Having double quotes inside a comment string is generating a compilation error.

// puts("Bye World!");
Parsing Error:
Missing prefix parse function for

Encode Monkey Lang values in bytes

Description

The Hermes compiler should encode values currently stored in the constant pool as binary so we can later dump this into a compiled executable file for Hermes VM.

Solution logic description

Each value must emit a number of bytes (might vary for each language): Although Monkey has only a handful of types Hermes should support the addition of new languages which might include support for classes, structs, or other kinds of user-generated types that we might need to support, for this the bytes required to determinate the type should be defined by the implementing language.

After the type bytes, the bytes representing the value should be emitted, starting with a number of bytes indicating the total size of the value.

On top of that, we will create a constant table that will match the constant index to the right starting byte of the value for parsing.

Problems

Some problems to deal with this solution are the following:

  • Separate constant bytes from instructions in a clear way for the VM
  • Keep track of local constant pool for closures
  • Parse complex types like hashmaps and arrays

Document Monkey Lang

We should have a set of documentation of all the features supported in this implementation of the Monkey language. This will be used in my other project to create an IDE app for Monkey!! πŸ˜ƒ

Implement a Monkey standard math library in Monkey!

Description

As any respectable language Monkey should have a set of standard libraries so let's start with the Math lib.

Solution:

Implement the following:

  • Math constants
  • Trigonometric functions
  • min, max functions
  • round, floor and ceil functions
  • Combinatory and permutations
  • Exponentials and Logarithmics
  • Factorials

Write binary executable files from Hermes compiler

Description

After creating the compiled code the compiler should be able to write the de result into a binary file which can later be read and executed by the VM.

Solution

The final binary file must include:

  • A marker to indicate the compiler version so we later know which VM version can execute it
  • The binary representation of the constant pool.
  • The compiled instructions

Implement other script require in Monkey

Description

Monkey code files should be able to require or include other code files allowing better code structure and re-use

Solution

Implement the include "<reference>"; statement for Monkey. This statement will load and incorporate the contents of the referenced file into the current one.

Potential problems

Keep an eye on cyclic references!.

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.