Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERL-1092: epp_dodger can't parse macro with arguments and ; #4056

Open
OTP-Maintainer opened this issue Nov 7, 2019 · 1 comment
Open

ERL-1092: epp_dodger can't parse macro with arguments and ; #4056

OTP-Maintainer opened this issue Nov 7, 2019 · 1 comment
Labels
bug Issue is reported as a bug help wanted Issue not worked on by OTP; help wanted from the community priority:low team:VM Assigned to OTP team VM

Comments

@OTP-Maintainer
Copy link

Original reporter: elbrujohalcon
Affected version: Not Specified
Component: syntax_tools
Migrated from: https://bugs.erlang.org/browse/ERL-1092


h2. Symptoms

{{epp_dodger:parse_file/1}} returns an error when trying to parse a module with a macro with arguments and {{;}} in its body.
h2. Steps to Reproduce It

1. Create a module like the following one:

 -module(demo).
 -define(MACRO(Arg), false; true).

 2. Try to parse it using {{epp_dodger}}.
h2. What Should Happen

Something along the lines of…

 
 1> epp_dodger:parse_file("demo.erl").
 {ok,[{tree,attribute,
 \{attr,1,[],none},
 \{attribute,{tree,atom,{attr,1,[],none},module},
 [\{tree,atom,{attr,1,[],none},demo}]}},
 {tree,attribute,
 \{attr,2,[],none},
 \{attribute,{atom,2,define},
 [{tree,application,
 \{attr,2,[],none},
 \{application,{var,2,'MACRO'},[\{var,2,'Arg'}]}},
 \{tree,text,{attr,2,[],none},"false ; true "}]}}]}
h2. What Happens

1> epp_dodger:parse_file("demo.erl").
 {ok,[{tree,attribute,
 \{attr,1,[],none},
 \{attribute,{tree,atom,{attr,1,[],none},module},
 [\{tree,atom,{attr,1,[],none},demo}]}},
 {error,{2,erl_parse,["syntax error before: ","';'"]}}]} 
h2. Additional Notes
h3. If we remove the argument but not the parentheses, it still fails

 12> io:format("~s~n", [os:cmd("cat demo.erl")]), epp_dodger:parse_file("demo.erl").
 -module(demo).
 -define(MACRO(), false; true).
 {ok,[{tree,attribute,
 \{attr,1,[],none},
 \{attribute,{tree,atom,{attr,1,[],none},module},
 [\{tree,atom,{attr,1,[],none},demo}]}},
 {error,{2,erl_parse,["syntax error before: ","';'"]}}]}
h3. If we remove the parentheses, it works

13> io:format("~s~n", [os:cmd("cat demo.erl")]), epp_dodger:parse_file("demo.erl").
 -module(demo).
 -define(MACRO, false; true).
 {ok,[{tree,attribute,
 \{attr,1,[],none},
 \{attribute,{tree,atom,{attr,1,[],none},module},
 [\{tree,atom,{attr,1,[],none},demo}]}},
 {tree,attribute,
 \{attr,2,[],none},
 \{attribute,{tree,atom,{attr,2,[],none},define},
 [\{var,2,'MACRO'},
 \{tree,text,{attr,2,[],none},"false ; true "}]}}]}
h3. If we remove the ;, it works

14> io:format("~s~n", [os:cmd("cat demo.erl")]), epp_dodger:parse_file("demo.erl").
 -module(demo).
 -define(MACRO(), false or true).
 {ok,[{tree,attribute,
 \{attr,1,[],none},
 \{attribute,{tree,atom,{attr,1,[],none},module},
 [\{tree,atom,{attr,1,[],none},demo}]}},
 {tree,attribute,
 \{attr,2,[],none},
 \{attribute,{atom,2,define},
 [{tree,application,
 \{attr,2,[],none},
 \{application,{var,2,'MACRO'},[]}},
 {tree,infix_expr,
 \{attr,2,[],none},
 \{infix_expr,{tree,operator,{attr,2,[],none},'or'},
 \{atom,2,false},
 \{atom,2,true}}}]}}]}
h3. If we use {{quick_parse_file/1}}, it works but it ignores the macro

 15> io:format("~s~n", [os:cmd("cat demo.erl")]), epp_dodger:quick_parse_file("demo.erl").
 -module(demo).
 -define(MACRO(), false; true).
 {ok,[\{attribute,1,module,demo}]}

 
@OTP-Maintainer
Copy link
Author

elbrujohalcon said:

The attached file is the not-botched-by-Jira version of the description. :(

@OTP-Maintainer OTP-Maintainer added bug Issue is reported as a bug help wanted Issue not worked on by OTP; help wanted from the community team:VM Assigned to OTP team VM priority:low labels Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug help wanted Issue not worked on by OTP; help wanted from the community priority:low team:VM Assigned to OTP team VM
Projects
None yet
Development

No branches or pull requests

1 participant