GithubHelp home page GithubHelp logo

chermehdi / comet Goto Github PK

View Code? Open in Web Editor NEW
29.0 29.0 7.0 168 KB

A programming language implementation in Go.

License: Apache License 2.0

ANTLR 1.47% Go 98.53%
educational golang interpreter programming-language

comet's Introduction

Hi there, I'm Mehdi welcome to my profile.

  • I am a Software Engineer, Living in London, and a Huge Rust and Go enthusiast.

  • Mostly interested in projects involving (but not limited to) Compilers, Programming languages, Developer tools ...

  • I want to contribute more to open source projects (other than the ones that I create), and upload more educational videos and live streams to Youtube and hopefully blog more regularly.

  • I am pationate about teaching people what I learned, So if you have a project involving teaching people new things, feel free to reach out.

comet's People

Contributors

anouard24 avatar chermehdi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

comet's Issues

Bug in toString a CometArray

I got a panic after using toString(anArray), because the builtin function toString is not supported for CometArray

>> var cc = [1, 2, 3]
CometNop
>> cc
[CometInt(1), CometInt(2), CometInt(3)]
>> println(cc)
&{3 [0xc0001020b0 0xc0001020b8 0xc0001020c0]}
CometNop
>> toString(cc)
panic: All types should have been exhausted!!

goroutine 1 [running]:
github.com/chermehdi/comet/std.ToString(0x667a58, 0xc0001042a0, 0x1)

I think, We have to implement two functions to represent objects as strings, for example:

  • A debug function should return: CometArray[CometInt(1), CometInt(2), CometInt(3)]
  • The toString function should return just [1, 2, 3]

Add the ability to lex/parse other number formats

Comet only considers numbers to only be represented in decimal format, which is not realistic in a programming language.

We expect Comet to be able to lex and parse numbers of binary, hex, octal format as well:

var a = 0xcafebabe
var b = 0b10100000
var c = 012

Bug in variable declaration

I tried this:

var a = 7
var a = "Test"

and it works, it erase old value of a instead of returning a CometError.

We have to fix this and I think, We must implement something to not allowing variable shadowing either, it's a source of bugs.

The printf built-in function does not work as expected

I tried printf("Hi\n") in the REPL and the result was Hi\n%!(EXTRA []interface {}=[])CometNop.

So, the issues are:

  • printf does not interpret special characters like \t or \n.
  • if we print something without other arguments, printf print the extra empty []CometObject that was intended to be full of other arguments.

Add better toString representation

Built-in types need better toString representation for debugging purposes.

Values and especially functions only show the type, we want something that shows the type signature as well.

Better Error reporting

Comet should provide a mechanism for better error reporting, this should be accomplished in multiple steps:

  1. Make all the current error messages contain as much information as available / needed.
  2. Make a dictionary of all the available errors and give them numbers for future pointers in the docs.
  3. Print spans for where the error happened.

Built-ins functions are not reserved keywords or known identifiers

I tried that:

>> println
Comet error:

        Identifier (println) is not bounded to any value, have you tried declaring it?
>> var println = 5
CometNop
>> println
CometInt(5)
>> println("Hello, World!")
Hello, World!
CometNop

As a Python developer, I'm expecting that:

>> println
<func builtins.println>

They are two options:

  • Let the developer overwrite builtins functions like user's functions:
>> func add(n) {2*n}
<func add(n)>
>> add = 70
CometInt(70)
  • Make builtins functions reserved keywords

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.