Code Monkey home page Code Monkey logo

aleppo's People

Contributors

danikp avatar drobakowski avatar elbrujohalcon avatar evanmiller avatar jfacorro avatar marianoguerra avatar seriyps avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aleppo's Issues

option not to expand to instant lambda application?

some people use macros to inline stuff without duplicating code or to inline checks in guards, from what I see in expand_macro_fun and trying the example below it seems all macro invocations expand to a fun definition and invocation, I think epp doesn't do this? if it doesn't then shouldn't be a way to ask not to expand to this fun wrapping behaviour?

-define(V(Line, Type, Val), {val, Line, Type, Val}).
-define(Int(Line, Val), ?V(Line, integer, Val)).

int(Line, Val) -> ?Int(Line, Val).

should aleppo expand macros that expand to macro calls?

with some macros definitions like this:

-define(V(Line, Type, Val), {val, Line, Type, Val}).
-define(Int(Val), ?V(_, integer, Val)).

shouldn't aleppo call process_tree until the result equals the result of the last call? that is expand until the expansion doesn't result in a tree with macros?

missing support for FUNCTION_NAME, FUNCTION_ARITY etc

FUNCTION_NAME

Mod =

-module(test).
-export([t/0]).
-define(Y, 1).
t(A, B) when A > B ->
    {?Y, ?FUNCTION_NAME}.
> {ok, Tokens, _} = erl_scan:string(Mod, {0,1}).
{ok,
[{'-',{2,1}},{atom,{2,2},module}, {'(',{2,8}}, {atom,{2,9},test}, {')',{2,13}}, {dot,{2,14}},
 {'-',{4,1}}, {atom,{4,2},export}, {'(',{4,8}}, {'[',{4,9}}, {atom,{4,10},t}, {'/',{4,11}},
 {integer,{4,12},0}, {']',{4,13}}, {')',{4,14}}, {dot,{4,15}}, {'-',{6,1}}, {atom,{6,2},define},
 {'(',{6,8}}, {var,{6,9},'Y'}, {',',{6,10}}, {integer,{6,12},1}, {')',{6,13}}, {dot,{6,14}},
 {atom,{8,1},t}, {'(',{8,2}}, {var,{8,3},'A'}, {',',{8,4}}, {var,{8,6},'B'}, {')',{8,7}},
 {'when',{8,9}}, {var,{8,14},'A'}, {'>',{8,16}}, {var,{8,18},'B'}, {'->',{8,20}}, {'{',{10,5}},
 {'?',{10,6}}, {var,{10,7},'Y'}, {',',{10,8}},
 {'?',{10,10}}, {var,{10,11},'FUNCTION_NAME'},
 {'}',{10,24}}, {dot,{10,25}}],
    {12,13}}

> aleppo:process_tokens(Tokens).
** exception error:
 no function clause matching aleppo:legacy_location({var,{10,11},'FUNCTION_NAME'}) 
(.../aleppo/_build/default/lib/aleppo/src/aleppo.erl, line 462)
     in function  aleppo:reverse_and_normalize_token_locations_helper/2 
(.../aleppo/_build/default/lib/aleppo/src/aleppo.erl, line 474)
     in call from aleppo:process_tree/2
(.../aleppo/_build/default/lib/aleppo/src/aleppo.erl, line 81)

FUNCTION_ARITY

Mod =

-module(test).
-export([t/0]).
-define(Y, 1).
t(A, B) when A > B ->
    {?Y, ?FUNCTION_ARITY}.
> {ok, Tokens, _} = erl_scan:string(Mod, {0,1}).
{ok,
[{'-',{2,1}},{atom,{2,2},module}, {'(',{2,8}}, {atom,{2,9},test}, {')',{2,13}}, {dot,{2,14}},
 {'-',{4,1}}, {atom,{4,2},export}, {'(',{4,8}}, {'[',{4,9}}, {atom,{4,10},t}, {'/',{4,11}},
 {integer,{4,12},0}, {']',{4,13}}, {')',{4,14}}, {dot,{4,15}}, {'-',{6,1}}, {atom,{6,2},define},
 {'(',{6,8}}, {var,{6,9},'Y'}, {',',{6,10}}, {integer,{6,12},1}, {')',{6,13}}, {dot,{6,14}},
 {atom,{8,1},t}, {'(',{8,2}}, {var,{8,3},'A'}, {',',{8,4}}, {var,{8,6},'B'}, {')',{8,7}},
 {'when',{8,9}}, {var,{8,14},'A'}, {'>',{8,16}}, {var,{8,18},'B'}, {'->',{8,20}}, {'{',{10,5}},
 {'?',{10,6}}, {var,{10,7},'Y'}, {',',{10,8}},
 {'?',{10,10}}, {var,{10,11},'FUNCTION_ARITY'},
 {'}',{10,24}}, {dot,{10,25}}],
    {12,13}}

> aleppo:process_tokens(Tokens).
** exception error:
 no function clause matching aleppo:legacy_location({var,{10,11},'FUNCTION_ARITY'}) 
(.../aleppo/_build/default/lib/aleppo/src/aleppo.erl, line 462)
     in function  aleppo:reverse_and_normalize_token_locations_helper/2 
(.../aleppo/_build/default/lib/aleppo/src/aleppo.erl, line 474)
     in call from aleppo:process_tree/2
(.../aleppo/_build/default/lib/aleppo/src/aleppo.erl, line 81)

String concatenation

Mod =

-module(test).
-export([t/0]).
-define(Y(_X), "Hello "_X).
t(A, B) when A > B ->
    {?Y("World")}.
> {ok, Tokens, _} = erl_scan:string(Mod, {0,1}).
{ok,
[{'-',{2,1}}, {atom,{2,2},module}, {'(',{2,8}}, {atom,{2,9},test}, {')',{2,13}}, {dot,{2,14}},
 {'-',{4,1}}, {atom,{4,2},export}, {'(',{4,8}}, {'[',{4,9}}, {atom,{4,10},t}, {'/',{4,11}},
 {integer,{4,12},0}, {']',{4,13}}, {')',{4,14}}, {dot,{4,15}}, {'-',{6,1}}, {atom,{6,2},define},
 {'(',{6,8}}, {var,{6,9},'Y'}, {'(',{6,10}}, {var,{6,11},'_X'}, {')',{6,13}}, {',',{6,14}},
 {string,{6,16},"Hello "}, {var,{6,24},'_X'}, {')',{6,26}}, {dot,{6,27}}, {atom,{8,1},t},
 {'(',{8,2}}, {var,{8,3},'A'}, {',',{8,4}}, {var,{8,6},'B'}, {')',{8,7}}, {'when',{8,9}},
 {var,{8,14},'A'}, {'>',{8,16}}, {var,{8,18},'B'}, {'->',{8,20}}, {'{',{10,5}}, {'?',{10,6}},
 {var,{10,7},'Y'}, {'(',{10,8}}, {string,{10,9},"World"}, {')',{10,16}}, {'}',{10,17}},
 {dot,{10,18}}],
    {12,13}}

> {ok, Tokens1} = aleppo:process_tokens(Tokens).
{ok,
[{'-',{2,1}}, {atom,{2,2},module}, {'(',{2,8}}, {atom,{2,9},test}, {')',{2,13}}, {dot,{2,14}},

 {'-',{4,1}}, {atom,{4,2},export}, {'(',{4,8}}, {'[',{4,9}}, {atom,{4,10},t}, {'/',{4,11}},
 {integer,{4,12},0}, {']',{4,13}}, {')',{4,14}}, {dot,{4,15}},

 {atom,{8,1},t}, {'(',{8,2}}, {var,{8,3},'A'}, {',',{8,4}}, {var,{8,6},'B'}, {')',{8,7}},
 {'when',{8,9}}, {var,{8,14},'A'}, {'>',{8,16}}, {var,{8,18},'B'}, {'->',{8,20}},
 {'{',{10,5}}, {'(',{10,7}}, {'fun',{10,7}}, {'(',{10,7}}, {var,{6,11},'_X'}, {')',{10,7}},
 {'->',{10,7}}, {string,{6,16},"Hello "}, {var,{6,24},'_X'}, {'end',{10,7}}, {')',{10,7}},
 {'(',{10,7}}, {string,{10,9},"World"}, {')',{10,7}}, {'}',{10,17}}, {dot,{10,18}}, {eof,0}]}

> erl_parse:parse_form([{'-',{2,1}}, {atom,{2,2},module}, {'(',{2,8}}, {atom,{2,9},test},
                        {')',{2,13}}, {dot,{2,14}}]).
{ok,{attribute,{2,2},module,test}}

> erl_parse:parse_form([{'-',{4,1}}, {atom,{4,2},export}, {'(',{4,8}}, {'[',{4,9}},
                        {atom,{4,10},t}, {'/',{4,11}}, {integer,{4,12},0}, {']',{4,13}},
                        {')',{4,14}}, {dot,{4,15}}]).
{ok,{attribute,{4,2},export,[{t,0}]}}

> erl_parse:parse_form([{atom,{8,1},t}, {'(',{8,2}},
 {var,{8,3},'A'}, {',',{8,4}}, {var,{8,6},'B'}, {')',{8,7}}, {'when',{8,9}}, {var,{8,14},'A'},
 {'>',{8,16}}, {var,{8,18},'B'}, {'->',{8,20}}, {'{',{10,5}}, {'(',{10,7}}, {'fun',{10,7}},
 {'(',{10,7}}, {var,{6,11},'_X'}, {')',{10,7}}, {'->',{10,7}}, {string,{6,16},"Hello "},
 {var,{6,24},'_X'}, {'end',{10,7}}, {')',{10,7}}, {'(',{10,7}}, {string,{10,9},"World"},
 {')',{10,7}}, {'}',{10,17}}, {dot,{10,18}}]).

{error,{{6,24},erl_parse,["syntax error before: ",["_X"]]}}

I can offer a PR soon for FUNCTION_NAME if interested!

maps's error not throw

If Account is maps. And "Account:id()" not throw any error.
It should be:
exception error: bad argument
in function apply/3
called as apply(#{key => value},id,[])
No error and i can't debug my code.

"-" will be Syntax error

The old version can not support maps.
And the latest version can not use "-" like "util:unixtime() - calendar:time_to_seconds(time())."
"-" will be syntax error. "*", "/" and "+" are fine.
There is another discussion: ChicagoBoss/ChicagoBoss#520

problem with defines

I'm still trying to write hello-world using chicagoboss[1].

-module(mytest).

-export([start/0]).

-define(USE_BOSS_WEB_TEST, true).

-ifdef(USE_BOSS_WEB_TEST).
-define(TEST_GET_REQUEST,   boss_web_test:get_request).
-endif.

start() ->
    ?TEST_GET_REQUEST("/some_uri", [], [], []).

Looks simple. But aleppo crashes on compile:

./rebar skip_deps=true compile
==> sioweb (pre_compile)
ERROR: pre_compile failed while processing /home/user/chicagoboss/myproject: {'EXIT',
    {function_clause,
        [{lists,reverse,
             [{badarg,
                  [{dict,fetch,
                       [{'TEST_GET_REQUEST',4},
                        {dict,6,16,16,8,80,48,
                            {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
                            {{[],[],[],[],
                              [['USE_BOSS_WEB_TEST',{atom,{7,28},true}],
                               ['TEST_GET_REQUEST',
                                {atom,{10,29},boss_web_test},
                                {':',{10,42}},
                                {atom,{10,43},get_request}]],
                              [['FILE',
                                {string,1,
                                    "/home/user/chicagoboss/myproject/src/test/functional/mytest.erl"}],
                               ['MODULE_NAME',{string,1,"mytest"}],
                               ['MODULE',{atom,1,mytest}],
                               ['MACHINE',{atom,1,'BEAM'}]],
                              [],[],[],[],[],[],[],[],[],[]}}}],
                       [{file,"dict.erl"},{line,125}]},
                   {aleppo,process_tree,3,[]},
                   {aleppo,process_tree,2,[]},
                   {boss_compiler,parse_text,4,[]},
                   {boss_compiler,compile,2,[]},
                   {boss_load,'-load_dir/3-fun-0-',5,[]},
                   {lists,foldl,3,[{file,"lists.erl"},{line,1197}]},
                   {boss_load,load_dir,3,[]}]}],
             [{file,"lists.erl"},{line,94}]},
         {aleppo,process_tree,2,[]},
         {boss_compiler,parse_text,4,[]},
         {boss_compiler,compile,2,[]},
         {boss_load,'-load_dir/3-fun-0-',5,[]},
         {lists,foldl,3,[{file,"lists.erl"},{line,1197}]},
         {boss_load,load_dir,3,[]},
         {boss_load,load_dirs1,5,[]}]}}
make: *** [erl] Error 1

:((

Defines not supported inside guard expressions

It looks like, defines is not properly substituded in guard expressions.

-module(ar_test_controller, [Req]).

-define(is_ok(X), is_list(X)).

test('GET', [X]) when ?is_ok(X) ->
    ok.

rebar compile cause following error:

ERROR: pre_compile failed while processing /home/user/chicagoboss/ar:
{'EXIT',{{badmatch,{error,[{"/home/user/chicagoboss/ar/src/controller/ar_test_controller.erl",
                            [{{5,24},erl_lint,illegal_guard_expr}]}]}},
         [{boss_load,load_all_modules,3,
                     [{file,"src/boss/boss_load.erl"},{line,28}]},
          {boss_load,load_all_modules_and_emit_app_file,2,
                     [{file,"src/boss/boss_load.erl"},{line,42}]},
          {boss_rebar,compile,4,
                      [{file,"../ChicagoBoss/priv/rebar/boss_rebar.erl"},
                       {line,85}]},
          {boss_plugin,pre_compile,2,
                       [{file,"priv/rebar/boss_plugin.erl"},{line,105}]},
          {rebar_core,run_modules,4,[]},
          {rebar_core,execute,4,[]},
          {rebar_core,process_dir0,6,[]},
          {rebar_core,process_commands,2,[]}]}}
make: *** [erl] Error 1

Guard expressions for case clauses produces same errors.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.