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

Makedep: Better handling of parentheses #626

Merged
merged 2 commits into from
May 8, 2024

Conversation

marshallward
Copy link
Member

The makedep tool was updated to handle parentheses in preprocessor expressions.

The expression #if (defined a) could not be parsed due to poor ad-hoc handling of parentheses, making it impossible to build the AM2-based coupled models with makedep,

The tool has has been significantly overhauled to include better overall unary operator support.

  • defined is now more of an operation than an exception, since it is pushed to the stack like any other operator.

  • Parentheses are now handled as "operators", with ) triggering an operator stack push and ( conducting the actual operation (in this case simply returning the contents).

  • In order to handle the possibility of macros within parentheses, macros are now evaluated only immediately before used in expressions, rather than the instant they are first encountered.

This redesign has allowed for many edge cases to be consolidated into the general purpose parser, greatly simplifying the code.

The makedep tool was updated to handle parentheses in preprocessor
expressions.

The expression `#if (defined a)` could not be parsed due to poor ad-hoc
handling of parentheses, making it impossible to build the AM2-based
coupled models with makedep,

The tool has has been significantly overhauled to include better overall
unary operator support.

* `defined` is now more of an operation than an exception, since it is
   pushed to the stack like any other operator.

* Parentheses are now handled as "operators", with `)` triggering an
  operator stack push and `(` conducting the actual operation (in this
  case simply returning the contents).

* In order to handle the possibility of macros within parentheses,
  macros are now evaluated only immediately before used in expressions,
  rather than the instant they are first encountered.

This redesign has allowed for many edge cases to be consolidated into
the general purpose parser, greatly simplifying the code.
@marshallward marshallward requested a review from adcroft May 7, 2024 20:47
Copy link
Member

@adcroft adcroft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adcroft adcroft merged commit 1829b7f into NOAA-GFDL:dev/gfdl May 8, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants