>
> And I got some confusions in understanding the AST of function
> definitions. Is there any docs or source code that I can get help from?
The AST format is not documented (and not officially stable, though not
drastically unstable either), but there are some reflection functions that
may help (expand, code_lowered, code_typed). For example:
julia> expand(quote function foo() x = 1 end end)
:(begin # none, line 1:
return $(Expr(:method, :foo,
:((top(svec))((top(apply_type))(Tuple)::Any,(top(svec))()::Any)::Any),
AST(:($(Expr(:lambda, Any[], Any[Any[:x],Any[Any[:x,:Any,18]],Any[],0],
:(begin # none, line 1:
x = 1
return 1
end::Any))))), false))
end)
There is a reflection/introspection section in the manual with some more
tips, or look at `base/reflection.jl` for the actual code (and some tricks
that aren't in the manual).
On Sun, Apr 19, 2015 at 6:42 AM, Jiyin Yiyong <[email protected]> wrote:
> I was playing with a syntax called Cirru which is like Lisp but with far
> less parentheses in JavaScript.
> https://github.com/Cirru
> And I got CirruScript which compiles to ES6 AST and then generates
> JavaScript in ES5.
> https://github.com/Cirru/cirru-script
> Later I think it's fun to have my toy language running on top of LLVM, and
> tried a few ideas. And here's my current project called CirruSepal.jl which
> transforms my code to Julia AST.
> the parser: https://github.com/Cirru/CirruParser.jl
> the prototype: https://github.com/Cirru/CirruSepal.jl
>
> For example, I got a file of Cirru like this:
>
> ```cirru
> = a :demo
> call println a
> call println (tuple 1)
> call println (cell1d 1)
> call println (call symbol a)
>
> call println true false
> ```
>
> I'm going to parse it into an Array with CirruParser.jl, then generates
> Julia AST with CirruSepal.jl using the metaprogramming skills from Julia. I
> just think it might be quite interesting that I can run a interpreter in
> Julia, or something like an alternative syntax for Julia(a inconvenient one
> though).
>
> Just want to see if anyone is interested on such a syntax for writing
> Julia AST?
>
> And I got some confusions in understanding the AST of function
> definitions. Is there any docs or source code that I can get help from?
>
> Thanks.
>