• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Using defmacro badly...

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 143
  • Views 13322
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using defmacro badly...

markbeck
markbeck over 14 years ago

Greetings all,

I'm trying to do something which I suspect may not be possible, but I figured I should ask.

I wish to create a macro that allows the user to write the contents of the @rest into a file.

e.g.

MyFileMacro( This is what I want to be written to a file)

I found that if I defined the following macro, I can get close:

(defmacro MyFileMacro (@rest body)
    sprintf(t_body "%L" `,body)
    `FunToWriteOutFile(,t_body)
)

This sorta works, but I have to clean up what is sent to `,body before writing it out to a file. `,body appears to be a bunch of function strings and so I end up with lots of '(' and ')' characters.

The issue I'm encountering is when the user enters in characters that are interpreted as a badly formed macro call...

e.g. MyFileMacro( blah{blah} )

This gives me a syntax error since skill is trying to interpret the contents of body before sending it to `,body.

 Basic question:

Is there a way to force the @rest body contents to be identically returned without any interpretation, such that I can then shove it into a string, or just get it to always interpret it as a string?

 Thanks,
Mark

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 14 years ago
    Mark,

    Fundamentally this is not doable. The arguments to the macro are still parsed by the SKILL parser, just not evaluated. This means it will follow SKILL syntax - so if you were to use SKILL operators it would try to convert into appropriate function calls. So

    sstatus(printinfix nil)
    MyFileMacro(hello + world)

    Would end up with "(plus hello world)"

    (I think - didn't test it).

    If you ended up with part of a SKILL expression, it will just break:

    MyFileMacro(hello +)

    So no, you can't do this. Macros are not intended for this kind of thing.

    Isn't it easier just to put the quotes in yourself?

    Regard,

    Andrew
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 14 years ago
    Mark,

    Fundamentally this is not doable. The arguments to the macro are still parsed by the SKILL parser, just not evaluated. This means it will follow SKILL syntax - so if you were to use SKILL operators it would try to convert into appropriate function calls. So

    sstatus(printinfix nil)
    MyFileMacro(hello + world)

    Would end up with "(plus hello world)"

    (I think - didn't test it).

    If you ended up with part of a SKILL expression, it will just break:

    MyFileMacro(hello +)

    So no, you can't do this. Macros are not intended for this kind of thing.

    Isn't it easier just to put the quotes in yourself?

    Regard,

    Andrew
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information