Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6588215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:01:12+00:00 2026-05-25T17:01:12+00:00

Normal Erlang attributes can be modified by parse tranformations. This does not apply to

  • 0

Normal Erlang attributes can be modified by parse tranformations. This does not apply to the “-define” attributes, as they are handled by the preprocessor. What would you do if you would like to alter the value of all macros without changing the file itself?

Ideally I want to call some modified version of the compiler which would have the following effect:

When run with input…

...
-define(constant, 45).
-define(debug(X), io:format(X)).
...
   ?debug(?constant) % Line: 7
...

.. and a parameter …

something:external

the result would be some abstract form which instead of…

{call,7,
      {remote,7,{atom,7,io},{atom,7,format}},
      [{integer,7,45}]}

… would have:

{call,7,
      {remote,7,{atom,7,something},{atom,7,external}},
      [{call,7,
             {remote,7,{atom,7,something},{atom,7,external}},
             []}]}

Of course the resulting code would probably not be executable, but could enable some ‘quality’ analysis on the usage of macros.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:01:13+00:00Added an answer on May 25, 2026 at 5:01 pm

    A syntax tree with preprocessor macros included can not be provided by the normal compiler.
    As you have noted macros are expanded by the preprocessor before the source is fed to the parser.

    There is a way to get a pseudo-parse-tree (the normal parse tree returned by erl_parse can’t represent macros): Use the module epp_dodger

    epp_dodger – bypasses the Erlang preprocessor.

    This module tokenises and parses most Erlang source code without expanding preprocessor directives and macro applications, as long as these are syntactically "well-behaved". Because the normal parse trees of the erl_parse module cannot represent these things (normally, they are expanded by the Erlang preprocessor epp(3) before the parser sees them), an extended syntax tree is created, using the erl_syntax module.

    However this can’t be integrated in a parse transform.

    But you can peruse the syntax trees as you like and feed the result to the compiler if you need this. For just reasoning about the code the parse-tree and Erlang Syntax Tools are all you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For normal situations, the didUpdateToLocation (of CLLocationManager) does not work any more when the
The normal client_side_validation gem does not work with rails 3.1 so i would like
With normal PHP string you can do this: $str = Hello ; $str .=
Under normal circumstances, a VB.NET application of mine can check the ClientName environmental variable
In normal mode I can hit Ctrl + E which deletes the rest of
Generating normal columnar data in excel file is quite easy but does any one
A normal UserControl looks like this in XAML: <UserControl x:Class=mynamespace.foo ...namespaces...> <!-- content -->
The normal flow for resetting a user's password by mail is this: Generate a
So normal class methods and object creation goes like this... $obj = new Class();
For a normal index constraint, you can find the columns it is on by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.