The AST for ECMAScript (JS, as defined by ECMA-262) in OCaml. If I am missing something, please tell me. I have a syntax-directed definition for translating back and a lexer/parser as well. (pastebin.com)
from ChubakPDP11@programming.dev to programming@programming.dev on 16 Mar 2024 17:01
https://programming.dev/post/11534783

For my job I need to operate on JS code, transforming it and passing the abstract syntax from one program to one script, and from one LLM model to another. This AST will be take form of JSON. Then my static parser will translate it back to JS code using syntax-directed definitions.

I am not a master of JS and the standard is too verbose and does not offer any grammar specs — AFAIK, the paid version of the C2017 standard has a grammar specs, so maybe the paid version of JS standard may have a grammar? I could not find ‘paid’ PDF anywhere. How much money these organizations make by peddling standards anyways? Will somebody please standardize Rust so I can tRust it? — so it may not be comprehensive. If you see anything missing, tell me.

I don’t think I can share the JS syntax-directed definition, so here’s C’s syntax directed definition. If you need an SDD for any language, just give this to ChatGPT and tell it to make an SDD ‘like this’. It has worked for me before.

pastebin.com/nqc193zm

Thanks.

#programming

threaded - newest