parse icon indicating copy to clipboard operation
parse copied to clipboard

Whether there is js AST to json format with scope ?

Open wrenchonline opened this issue 4 years ago • 4 comments

For example:

Stmt(if (((((document.location).href).indexOf)("default="))>=0) Stmt({ Decl(var Binding(lang = ((((document.location).href).substring)((((((document.location).href).indexOf)("default="))+8))))) Stmt((document.write)((((("<option value='"+lang)+"'>")+(decodeURI(lang)))+"</option>"))) Stmt((document.write)("<option value='' disabled='disabled'>----</option>")) })) Stmt((document.write)("<option value='English'>English</option>")) Stmt((document.write)("<option value='French'>French</option>")) Stmt((document.write)("<option value='Spanish'>Spanish</option>")) Stmt((document.write)("<option value='German'>German</option>"))

to

"Stmt":{ "xxx":"xxxx" ......... }

wrenchonline avatar Oct 15 '21 02:10 wrenchonline

I don't understand what you need. What problem do you have? You can only convert object or array literals (and decimal, string, true, false, null literals) to JSON...

tdewolff avatar Oct 17 '21 21:10 tdewolff

I don't understand what you need. What problem do you have? You can only convert object or array literals (and decimal, string, true, false, null literals) to JSON...

This actually involves the ast standard of js, which called estree .I think it an json format and can use for many other tools

Cyberhan123 avatar Oct 23 '21 04:10 Cyberhan123

Do you want this library to be able to generate an AST tree according to the estree standard? What do you expect it to produce? Can you give me an example?

tdewolff avatar Oct 24 '21 19:10 tdewolff

Do you want this library to be able to generate an AST tree according to the estree standard? What do you expect it to produce? Can you give me an example?

You can refer to this link https://astexplorer.net/ ,and we can do it together if you want .Although my level is limited

Cyberhan123 avatar Oct 25 '21 12:10 Cyberhan123

You can output JSON by calling ast.JSONString() (string, error) or using the JSON(io.Writer) error interfaces on all AST nodes. Considering this issue fixed.

tdewolff avatar Oct 26 '23 00:10 tdewolff