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
+ 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://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

View file

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