Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm trying to build a programming language that might best be characterized as rust - ownership + GC + goroutines (coroutines with an automatic yield semantic).

My rationale for starting this project was that I like specific features or facilities of many individual languages, but I dislike those languages for a host of other reasons. Furthermore, I dislike those languages enough that I don't want to use them to build the projects I want to build.

I'm still at a relatively early point in the project, but it has been challenging so far. I'm implementing the compiler in Crystal, and I needed a PEG parser combinator library or a parser generator that targeted Crystal, but there wasn't a PEG parser in Crystal that supported left recursive grammar rules in a satisfactory way, so that was sub-project number 1. It took two years, I'm ashamed to say, but now I have a functioning PEG parser (with seemingly good support for left recursive grammar rules) in Crystal that I can use to implement the grammar for my language.

There is still a ton more to be done - see http://www.semanticdesigns.com/Products/DMS/LifeAfterParsing... for a list of remaining ToDos - but I'm optimistic I can make it work.



Maybe check out the https://vlang.io. It might be similar to what you are doing and personally I admire the ideas and decisions the author made so far.


I saw vlang.io a few months ago. Every time I come back to the site, my jaw hits the ground again. I am utterly impressed by Alexander's productivity - it blows me away every time I consider it.

I think V is an impressive language, but it isn't quite geared toward my vision of what a language ought to be.

I am more a Rubyist than a C, Rust, or Go developer, and so my preference is for a higher level language that's a little more pleasant to use and doesn't make me think about some details that I consider "irrelevant". I'm firmly in the "sufficiently smart compiler" camp, and think that I shouldn't have to think about those low level details that only matter for the sake of performance - the compiler ought to handle that for me.


Neat! I spend a lot of time working with and on parsers and parser generators.

Did you use Sérgio Medeiros' algorithm for left recursion, perchance?


No. I was pretty naive in my initial attempts. I tried for many months to make Laurence Tratt's Algorithm 2 (see https://tratt.net/laurie/research/pubs/html/tratt__direct_le... ) work, but ultimately I failed. I recall running into some problem with my implementation of Tratt's idea that led me to conclude that his Algorithm 2 doesn't work as stated. My reasoning is buried in a git commit message from many months ago - I'd have to go look it up.

My takeaway from Tratt's explanation was that the general technique of growing the seed bottom-up style when in left-recursion - I think I've also seen that idea termed "recursive ascent" somewhere else but I can't place it offhand - seemed reasonable, so that's what I kept working on until I figured out something that seemed to work.

Later on, I ran across https://github.com/PhilippeSigaud/Pegged/wiki/Left-Recursion, which describes Sergio Medeiros' technique at a high level. One of the nice things I used from the Pegged project was the unit test suite. I re-implemented some of the unit tests from Pegged in my own PEG implementation and discovered that it failed at those unit tests.

It took me another number of months to figure out why my implementation failed the unit tests. I re-jiggered my implementation to make it handle the scenarios captured by those unit tests, and then naively thought "hey, it works!"...

All was well until I ran across another set of unit tests in the Autumn PEG parser (see https://github.com/norswap/autumn). My implementation failed some of those as well. After another number of months, I had a fix for those too.

Long long long story short, this process continued until I couldn't find any more unit tests that my implementation would fail, so once again I'm at the point where I think "well, I think it works".

There have been a number of occasions where I've thought "if this doesn't work, I'm just going to re-implement Pegged in Crystal!". Perhaps that's what I should've done. Ha ha! In a few months, when I find another test case that breaks my implementation, I may just do that. We'll see. I hope it doesn't come to that. Fingers crossed. :-)


Sounds like a dialect of ML!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: