Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 22 2018 23:37

    rfratto on master

    Add documentation on method rec… (compare)

  • Jun 17 2017 06:35
    wafflebot[bot] unlabeled #32
  • Jun 17 2017 06:35
    rfratto closed #42
  • Jun 17 2017 06:35
    rfratto closed #32
  • Jun 17 2017 06:33
    rfratto edited #42
  • Jun 17 2017 06:33
    rfratto opened #42
  • Jun 17 2017 06:31
    rfratto unlabeled #32
  • May 15 2017 02:41

    rfratto on master

    Update README.md Remove refere… Add type annotation and instant… (compare)

  • Apr 24 2017 04:41
    rfratto edited #27
  • Apr 24 2017 04:23
    rfratto edited #27
  • Mar 26 2017 05:25
    Travis orange-lang/orange (dev/32-parser) passed (232)
  • Mar 25 2017 21:09
    Travis orange-lang/orange (master) passed (231)
  • Mar 25 2017 20:51
    Travis orange-lang/orange (master) errored (230)
  • Mar 25 2017 20:49
    Travis orange-lang/orange (master) errored (230)
  • Mar 25 2017 16:22
    Travis orange-lang/orange (dev/lexer-position) errored (225)
  • Mar 19 2017 17:27
    Travis orange-lang/orange (master) errored (223)
  • Mar 19 2017 17:20
    Travis orange-lang/orange#40 broken (221)
  • Mar 19 2017 17:16
    Travis orange-lang/orange#40 errored (220)
  • Mar 19 2017 17:11
    Travis orange-lang/orange#40 errored (219)
  • Mar 19 2017 17:07
    Travis orange-lang/orange#40 errored (218)
Robert Fratto
@rfratto
it's defined with my include to gtest/gtest.h
Robert Fratto
@rfratto
It'd probably be a good idea for me to stick a README in the test directory explaining that the tests use gtest for those who aren't familiar with the macros it provides
Robert Fratto
@rfratto
looks like plain old vim may have everything I need after all: http://releases.llvm.org/3.9.0/tools/clang/tools/extra/docs/clang-rename.html
yc
@cloutiy
Vim has it all.
yc
@cloutiy
Actually yesterday I've been trying out neovim - a modern re-write of vim. https://neovim.io/
Robert Fratto
@rfratto
yeah, neovim is pretty good. My current environment is a combination of tmux + neovim
Robert Fratto
@rfratto
Just a quick update: I definitely haven’t forgot about Orange. I’ve been really busy with other projects and I haven’t had any time to work on it. I’m still planing to get back to it ASAP :)
yc
@cloutiy
Hey no problem. I got myself https://interpreterbook.com/ a couple days ago and keeping myself busy writing a lexer, pratt parser and interpreter using Go. You know it's actually a nice language to work in.
Robert Fratto
@rfratto

Two simple changes to the language specification:

  1. Type extensions can now add new constructors, so you can add constructors to existing types.
  2. Casting syntax has changed as if it was a function (e.g., double(5)). Iternally, builtin casts work the same as having type extensions with a new constructor that takes one argument (the target type).

For example, a cast from double to int would be internally implemented like this:

extend double {
     def double(source: int) {
        // internal LLVM cast 
    }
}
This could allow for pretty cool things, like extending string to implement a cast from a number type.
yc
@cloutiy
When can I start using it ;)
I was decoding and encoding some json today, and I thought to myself...why the hell isn't json a primitive type.
Then people wouldn't to waste time writing and using libraries to convert them damn thing
Robert Fratto
@rfratto
JSON as a primitive would be a bit of a challenge in a typed language
It would basically be equivalent to a dictionary with string keys and generic object values
standard library support for json would be really good though
as for when orange will be usable, that's a good question :) i'm not putting as much work into it as i'd like to, so things are extremely so right now
yc
@cloutiy
Sometimes my ideas a bit too far fetched.
Robert Fratto
@rfratto
i'm hoping that changes soon.
haha, I wouldn't say it was far fetched. I do think JSON support should be part of the standard libraries for languages though
yc
@cloutiy
Could you give an example of your #1 - contrsuctors for type extension?
Robert Fratto
@rfratto
sure, one sec
this is quick and hacky so I’m not sure if my logic is correct, but it demonstrates a use case:
extend int {
    // define a new constructor for int that takes a string as a parameter
    def int(str: string) {
        this = 0 

        for (var i = 0; i < str.length(); i++) {
            this += (str[i] - '0') * Math.pow(10, str.length() - i)
        }
    }
}

int("15") == 15
Robert Fratto
@rfratto
This message was deleted
Robert Fratto
@rfratto

it’s important to me that built-in behaviors (like every array having a .length() method) could be defined in terms of the language itself. with that in mind, i’ve added a Generic Extensions section to the docs. https://docs.orange-lang.org/core/extensions.html#generic-extensions

For example, the builtin capabilites of arrays would be defined like this from the compiler:

extend<T> T[] {
    // default constructor for an array is an empty array 
    // since strings are an alias to char[], default ctor for a string is the empty string  
    def T(): []

    // get a c-style array 
    def ptr() -> T* {
        // LLVM generated code to get the c-style pointer from the orange array 
    }

    def length() -> int {
        // LLVM generated code to get length from array 
    }
}
i don’t know why gitter colors my code like that, but it looks really bad
yc
@cloutiy
This is interesting. Orange has some pretty novel ideas.
yc
@cloutiy
I wish that my coding skills were better than they are. I would feel much more helpful and you wouldn't be a lone contributor.
Robert Fratto
@rfratto
it’s okay, I’m hoping that once I finally get the more difficult parts of the compiler done, there’s additions to be made that more people like yourself would be comfortable with implementing
maybe standard library stuff, or smaller things inside the compiler
Robert Fratto
@rfratto
sorry for all the updates lately, but two more (& maybe the last) additions to the spec:
  1. I added initializer statements to if/switch expressions like in C++17 and Go.
if (var exists = doesUserExist(); exists == false) {
    // handle error 
}
  1. I added documentation for default constructors for classes. There are two default constructors. One takes no arguments and initializes everything to the default values. The other takes a series of optional arugments for each public member. That allows for something like this:
class Vector2D { 
    var x: int 
    var y: int 
}

Vector2D()             // x == 0, y == 0
Vector2D(x: 15)        // x == 15, y == 0 
Vector2D(y: 20)        // x == 0, y == 20 
Vector2D(x: 15, y: 20) // x == 15, y == 20
yc
@cloutiy
Regarding your second point, I've been playing with Go,, and this is the approach it takes as well. They don't have classes, but when instantiating a struct, if nothing is passed to the constructor, variables inside get initialized to their default value (int -> 0, string -> "" etc...). This behavior will be familiar. It's intuitive as well.
Robert Fratto
@rfratto
Yep, I added it from inspiration of Go (although C++ has it too). What's new here is that it uses the same syntax as other functions instead of the curly braces that Go/C++ use, and since it's a default constructor, it can be overridden or be made private to encourage using other constructors instead.
Robert Fratto
@rfratto
Good news: I’m finally going to have time to work on Orange again starting tomorrow :) Hopefully things will start progressing soon, I’ve been really itching to work on it for a while now
Robert Fratto
@rfratto
I pushed up some code on my personal github that finishes the number lexing tests I wrote. I’m temporarily testing out what a version of Orange written in Go would be like. I’ve been using Go more frequently and I like it better than C++, so I may consider porting the existing 100-or-so lines of C++ to Go and contiuining with that. We’ll see.
yc
@cloutiy
I like Go. The syntax is super simple. I've been dabbling in D the last while. D has some tooling to convert C++ to D. first post: https://forum.dlang.org/post/nimlnb$67$1@digitalmars.com
But D is very similar to C++, although much cleaner.
But Go is so simple. Helps you get to work ASAP.
Robert Fratto
@rfratto
I've tried D before in my search for a better C++, but the lack of full debugging support was a deal breaker for me. I actually finished porting the C++ code to Go last night and I'm pretty pleased with it, so I'll be writing the first iteration of the compiler in Go. I'll be finishing the lexer today and merging that all into master.
Robert Fratto
@rfratto
But yeah, Go is simple. I do enjoy using it, but it does have its problems. But I guess if I was completely happy with it (or any other language), I wouldn’t want to work on Orange :p
yc
@cloutiy
haha yes, that's why we do it isn't it. Well that's great. I'm more familiar with Go than I am with C++, so it will be much easier for me to understand what you're doing and what's going on. I'll also be interested to see your lexer and parser to see the approach you've taken and how it compares to the one I started building while following the book "Writing an Interpreter in Go". My code here if interested: https://github.com/cloutiy/monkey
Robert Fratto
@rfratto
Our lexers aren’t incredibly different, except I’m using a lookup table to get operators like = and <<. I sort the keys in the table by length of string descending, so the lexer always prefers ++ over +. I haven’t pushed that code yet for you to see, but it’ll be up later.
yc
@cloutiy
Oh that's smart. Cool, I'll have a look once I hear back.
Robert Fratto
@rfratto

Finished the lexer and merged. I actually use the gb tool for the project which allows me to write the go code outside of $GOPATH. Instructions are on the README.md if you’re unfamiliar.

Relevant lexer code here:
https://github.com/orange-lang/orange/blob/master/src/parse/lexer/lexer_lex.go
https://github.com/orange-lang/orange/blob/master/src/parse/lexer/lex_number.go

Robert Fratto
@rfratto

Really minor change to the language spec: #if preprocessor conditionals have become const if. They’re not true preprocessor directives (they’re still lexed and parsed) so I don’t want them to have that standard #if notation from C.

Also, I’ve been really slowly working through the parser. I don’t really like wrting parsers, so it’s taking me a while. Looking at my todo list, I’ve gone through about 10/24 constructs to parse so far.

All of that code currently located here: https://github.com/rfratto/orange/tree/dev/32-parser
Although I may stop using my personal github for dev branches and keep that all on the official branch soon.
Robert Fratto
@rfratto

It’s been a while, but I have a quick update to the language spec. I’ve been thinking about how to avoid the parsing ambiguities with generic instantiation. I’ll solve this in Orange easily by requiring generic instantiation in an expression (namely, while calling a generic function) to be prefixed by a .. For example, What used to be add<int>(5, 3) is now add.<int>(5,3).

It’s not too different, and hopefully with Orange’s type detection, shouldn’t be required too often. That’s all for now :)

yc
@cloutiy
approved :)
Robert Fratto
@rfratto

It took far too long (three months!) but the parser is finished :)

Up next:

  1. Semantic Analyzer. This is where most of the code is going to be, I’d bet.
  2. Code Generation: simple to implement thanks to LLVM
  3. Binary Generation: even simpler than step 2, just turns the LLVM IR into a binary and nothing else.
  4. The binary for the compiler itself. Hooks into all the compiler components to accept files and compile them.

This is still all just for milestone one, where I’m trying to get a subset of Orange created just so I can write the Orange compiler in Orange itself. The next milestone (the bootstrapped compiler) will implement the complete language spec along with support for compiler extensions.

yc
@cloutiy
Hi Robert, thanks for the update. I know it's been a while but I got a new laptop and have just been slowly reinstall stuff. Today gitter. I'm glad to see things a shaping up!