Remix.run Logo
artpar 2 hours ago

I made a language for using in another project, so I'll answer your questions

https://www.npmjs.com/package/wang-lang

- this new language looks and behaves exactly like javascript, except it doesnt have "eval" and "new Function", so it is CSP safe. That's the only difference. I wanted to execute dynamically generated code in chrome extension

- llm did most of the work of creating a nearley grammar and associated interpreter (whole thing is bundled, nearley is not a final dependency), elaborate tests make this quite sane to handle

- took me about total of 1 weeks for the initial mvp to try out, and then have been fixing bugs and inconsistencies with javascript behavior, about 1 day a month of effort

- mostly 0

The only reason to create was I couldnt find something similar and it was low effort thanks to llm

I also created another even smaller DSL you can say

https://www.npmjs.com/package/free-text-json-parser

It parses json embedded in plain text

yokljo an hour ago | parent | next [-]

Nice. I built something basically just like this for work for the same reason last year. It only look a few hours though, cause I just used Acorn [0] to parse my JS, then directly evaluated the AST. It also had an iteration limit and other configurable limits so I can eval stuff in the browser without crashing the tab. I did not use an LLM.

[0]: https://github.com/acornjs/acorn

artpar 43 minutes ago | parent [-]

This is exactly what I wanted and couldn't find. Ended up creating along with an interpreter (so slightly easier then walk and execute)

Hendrikto 2 hours ago | parent | prev [-]

> safe

> llm did most of the work

> it was low effort

I really wouldn’t trust its supposed safety.

artpar an hour ago | parent [-]

csp safe has a particular meaning associated it with. its not a "safe" language whatever that is. chrome webstore team is okay with it and serves my purpose. if you have submitted extensions to google chrome then you would know that any sign of "eval" or new Function in the code will lead to rejection.

procaryote an hour ago | parent [-]

So what you want is a linter, not a language

artpar 44 minutes ago | parent [-]

I want to execute dynamically generated javascript looking code in chrome extension without using eval or new function. basically eval without actually using eval.

linter would help me find and avoid usages of eval.