Live data from Hacker News

How to implement a programming language in JavaScript

lisperator.net

31–39 of 39 posts

Re: How to implement a programming language in JavaScript

#31

Earlier quoted context omitted.

This is all true, for sure, but I'd like to point out that PEGs are a formalism that isn't much harder to learn than regular expressions, and totally appropriate for parsing a fairly large class of languages. I've also seen PEG-based (pakrat) parser generators for just about every programming language (some better than others, of course). Again, these tend to be not much harder to learn than regular expressions, and…

Thanks for addending :-) I wasn't aware of PEGs. That definitely does look promising for a lot of cases.

I recommend checking out https://en.m.wikipedia.org/wiki/OMeta and https://github.com/cdglabs/ohm

Re: How to implement a programming language in JavaScript

#33
post #29
post #28

Earlier quoted context omitted.

Parsing is the smallest part of writing a compiler.

It's also one of the most conceptually difficult parts, which makes it a good learning opportunity.

One common criticism of compiler classes is that the first semester spends all of its time on parsing, so the students don't learn very much about compilers. And btw, there's an infinite number of conceptually difficult parts when it comes to optimization.

Re: How to implement a programming language in JavaScript

#34
post #29
post #28

Earlier quoted context omitted.

Parsing is the smallest part of writing a compiler.

It's also one of the most conceptually difficult parts, which makes it a good learning opportunity.

"It's also one of the most conceptually difficult parts"

... except all the others.

Re: How to implement a programming language in JavaScript

#35
post #22

If anyone is interested in making a language in JS I can recommend the "Nearley" parser/lexer: http://nearley.js.org Very easy parser/lexer to use, accepts a larger class of grammars than yacc/lex and is reasonably fast. I use it for the language in my project: http://emunotes.com and Nearley is fast enough to parse stuff as the user is entering text. It may be tempting to see if you can get away with not using a par…

Emunotes is really cool. A magical word processor. Is there a way to make functions that connect to expanded services?

Re: How to implement a programming language in JavaScript

#36

Earlier quoted context omitted.

Thanks for addending :-) I wasn't aware of PEGs. That definitely does look promising for a lot of cases.

I recommend checking out https://en.m.wikipedia.org/wiki/OMeta and https://github.com/cdglabs/ohm

This. OMeta and Ohm are awesome.

Re: How to implement a programming language in JavaScript

#37
post #29
post #28

Earlier quoted context omitted.

Parsing is the smallest part of writing a compiler.

It's also one of the most conceptually difficult parts, which makes it a good learning opportunity.

Conceptually? I'd say it can be tedious, if done by hand, but the concepts are pretty simple.

Re: How to implement a programming language in JavaScript

#39
post #22

If anyone is interested in making a language in JS I can recommend the "Nearley" parser/lexer: http://nearley.js.org Very easy parser/lexer to use, accepts a larger class of grammars than yacc/lex and is reasonably fast. I use it for the language in my project: http://emunotes.com and Nearley is fast enough to parse stuff as the user is entering text. It may be tempting to see if you can get away with not using a par…

Emunotes is really cool. A magical word processor. Is there a way to make functions that connect to expanded services?

Thanks; if you by expanded services mean integration with external pieces of user-defined javascript or data sources (such as a YQL query) it is a good and very potent idea. It is something I like to do a little further down the road. In the near future I am focusing on graphics and collaborative features.
Post reply on HN