Better HN
topnewbestaskshowjobs
Log inSign up

rickardlindberg

62 karma · joined Feb 24, 2019 (7y ago) · 3 submissions

Submissions

comment 7y ago · link · parent

Yes, you are right that the parser grammars are much like PEGs and it's the code generator grammars that match other objects than characters.

The reason I chose to implement it that way in the article is that I modeled RLMeta after OMeta. If I remember correctly, their reason for doing so was that they thought compilers would be easier to write if all passes (parsing, code generation, ...) could be written using the same language.

I think using the same DSL for code generators works quite well and they become quite readable. Perhaps there is a better DSL suited for code generation, and it would be interesting to experiment with that as well.

You are right that the toy examples could generate code directly in the parser. There is no need for a separate code generator step. But the RLMeta compiler would be much less readable without a separate code generator step I think. The reason I introduced an AST in the toy example was to introduce the concept before I showed it in the RLMeta implementation.

comment 7y ago · link · parent

As far as I know, PEGs work only on streams of characters. RLMeta works on streams of arbitrary Python objects. The syntax currently has support for matching characters, strings, and lists. Does that clarify it?

3.

A meta approach to implementing programming languages (2018)(rickardlindberg.me ↗)

134 points · by rickardlindberg · 7y ago · 40 comments