More resources

This commit is contained in:
Daniel Flanagan 2019-11-19 21:11:28 -06:00
parent 06f1e3195f
commit db508c0d0f
2 changed files with 17 additions and 4 deletions

View file

@ -72,6 +72,15 @@ probably never even happen.
## Development Resources ## Development Resources
+ https://hexdocs.pm/elixir/syntax-reference.html#the-elixir-ast
+ https://medium.com/cirru-project/resources-on-elixir-ast-e045b613f284
+ https://elixir-lang.org/getting-started/meta/quote-and-unquote.html
+ https://hexdocs.pm/elixir/Kernel.SpecialForms.html
+ http://slides.com/chrismccord/elixir-macros
+ http://zhenwusw.github.io/blog/2014/10/20/metaprogramming
+ https://www.theerlangelist.com/2014/06/understanding-elixir-macros-part-1.html
+ https://www.theerlangelist.com/2014/06/understanding-elixir-macros-part-3.html
+ https://pragprog.com/book/cmelixir/metaprogramming-elixir
+ https://pl-rants.net/posts/leex-yecc-in-elixir/ + https://pl-rants.net/posts/leex-yecc-in-elixir/
+ https://notes.eellson.com/2017/01/22/html-parsing-in-elixir-with-leex-and-yecc/ + https://notes.eellson.com/2017/01/22/html-parsing-in-elixir-with-leex-and-yecc/
+ https://github.com/elixir-lang/elixir/commits/master?after=e2c78e8ba948739768a335999e35a06d5eb5ad4b+15680 + https://github.com/elixir-lang/elixir/commits/master?after=e2c78e8ba948739768a335999e35a06d5eb5ad4b+15680

View file

@ -10,13 +10,20 @@ defmodule Lytlang do
value value
end end
def from_lytlang(string, binding \\ [], opts \\ []) do def from_lytlang(
code,
binding \\ [context: @root_module, import: Kernel, import: Elixir],
opts \\ []
)
def from_lytlang(string, binding, opts) do
string string
|> String.to_charlist() |> String.to_charlist()
|> tokenize() |> tokenize()
|> parse() |> parse()
|> to_ast_node(binding, opts) |> to_ast_node(binding, opts)
|> to_elixir_ast(opts) |> to_elixir_ast(opts)
|> IO.inspect(label: "EX AST")
end end
def tokenize(string) do def tokenize(string) do
@ -49,12 +56,10 @@ defmodule Lytlang do
def to_elixir_ast({{:literal, expr}, {_meta, _binding, _ast_opts}, _leaves}, _opts) do def to_elixir_ast({{:literal, expr}, {_meta, _binding, _ast_opts}, _leaves}, _opts) do
expr expr
|> IO.inspect(label: "EX AST")
end end
def to_elixir_ast({s, {_meta, binding, _ast_opts}, leaves}, _opts) do def to_elixir_ast({s, {_meta, binding, _ast_opts}, leaves}, _opts) do
{s, binding, to_elixir_ast(leaves)} {s, binding, to_elixir_ast(leaves)}
|> IO.inspect(label: "EX AST")
end end
@spec to_ast_node(any, keyword, keyword) :: astnode @spec to_ast_node(any, keyword, keyword) :: astnode
@ -67,7 +72,6 @@ defmodule Lytlang do
{_s, {_meta, binding, opts}, {_s, {_meta, binding, opts},
_operands} -> _operands} ->
{s, {nmeta, nbinding, nopts}, operands} = to_ast_node(expr, binding, opts) {s, {nmeta, nbinding, nopts}, operands} = to_ast_node(expr, binding, opts)
{s, {nmeta, Keyword.merge(binding, nbinding), Keyword.merge(opts, nopts)}, operands} {s, {nmeta, Keyword.merge(binding, nbinding), Keyword.merge(opts, nopts)}, operands}
end) end)
end end