Fork me on GitHub
#sci
<
2021-12-17
>
haywood19:12:36

👋:skin-tone-2: Is there a way to generate an AST using SCI? I have been digging around and trying sci.impl.analyze/analyzer but am starting to think it doesn’t exist and wanted to confirm.

borkdude19:12:09

@haywood SCI does not expose an intermediate representation. can you explain why you would need this?

borkdude19:12:28

What it does expose is: 1) reading an s-expression from a string, 2) evaluating that s-expression in a context

haywood19:12:50

yea I’m working on a web application which is basically a local dev environment in the browser which is built on a sci compiler. I’m looking to venture into greater ‘no code’ abstractions, so I want to take some source strings that users make, parse the AST, and generate an HTML form representation (and then eventually go back the other way)

borkdude19:12:27

that might be possible using (def rdr (sci/reader "(+ 1 2 3)")) (def ctx (sci/init {})) (def ast (sci/parse-next ctx rdr)) (sci/eval-form* ctx ast)

borkdude19:12:42

depending on your definition of AST

haywood19:12:44

ah, nice I was going to try that

haywood19:12:01

well, not that exactly but let me give it a shot 🙂