Check out cool esmeta project #4439
Replies: 2 comments
-
This does look cool. But can you summarize how you think it might be applied/useful to Oxc? I don't have a formal computer science background, so some of the jargon is unfamiliar to me ("mechanized specification"?). If you have time, and you do understand it, would you be able to explain at a bit of a more "tell it to me like I'm 5" level what its purpose is? |
Beta Was this translation helpful? Give feedback.
-
@overlookmotel . No formal computer science background is needed. You just need to understand interpreters. esmeta simply reads ECMAScript spec and translates it to so-called Intermediate Representations for ECMAScript Specification (IRES). For example, this is fragment of ECMAScript spec:
Esmeta converts this text to the following IRES:
As well as I understand, this conversion is performed using some generic algorithm. Unfortunately, the generic algorithm sometimes doesn't work, so esmeta resorts to hardcoded ad hoc list of English phrases: https://github.com/es-meta/esmeta/blob/main/src/main/resources/manuals/rule.json . Also, ECMAScript spec contains js grammar. Esmeta reads this grammar and builds parser out of it. Also, esmeta is unfinished. Not all algorithms can be converted right now. Here is current statistics: https://github.com/es-meta/esmeta/blob/main/src/main/resources/result/spec-summary . ECMAScript consists of algorithms like above. It is essentially ready-to-use interpreter. So, after conversion to IRES we essentially get interpreter. (But some parts are still needed to be written manually, for example, obscure parts of parser.) Okay, so we got interpreter. Then we can run it on test262 tests. Also, esmeta has debugger, which can debug ECMAScript spec, i. e. you can actually step-by-step debug algorithms with steps like Esmeta helped to fix many bugs in ECMAScript spec. Now esmeta is part of CI at https://github.com/tc39/ecma262 , so every PR is checked using esmeta.
To generate js interpreter directly from ECMAScript spec. This enables us to check resulting interpreter against test262 and against other js implementations. Also, in process of converting esmeta performs some consistency checks of the specification.
As well as I understand, Nova is based on Oxc. This post ( https://trynova.dev/blog/why-build-a-js-engine ) about Nova contains this phrase:
Esmeta solves exactly this problem! With esmeta you can just edit specification itself and get interpreter for modified version! |
Beta Was this translation helpful? Give feedback.
-
https://github.com/es-meta/esmeta . This is Scala program, which parses ecmascript spec and... converts it into actual interpreter!
Beta Was this translation helpful? Give feedback.
All reactions