public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Przemyslaw Pawelczyk <przemyslaw@pawelczyk.it>
To: systemtap@sourceware.org
Subject: [PATCH] Support || and && in preprocessor's conditions.
Date: Sat, 20 Jun 2009 13:43:00 -0000	[thread overview]
Message-ID: <1245505428.696071.25030@debian> (raw)
In-Reply-To: <1245456101.314490.18432@debian>

---
 parse.cxx |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/parse.cxx b/parse.cxx
index a26d594..a74b513 100644
--- a/parse.cxx
+++ b/parse.cxx
@@ -332,16 +332,42 @@ parser::scan_pp (bool wildcard)
 
       // Do not evaluate the condition if we haven't expanded everything.
       // This may occur when having several recursive conditionals.
-      bool result = eval_pp_conditional (session, l, op, r);
+      bool and_result = eval_pp_conditional (session, l, op, r);
       delete l;
       delete op;
       delete r;
 
+      bool result = false;
+      const token *n;
+      while ((n = input.scan ()) && n->type == tok_operator)
+        {
+          if (n->content == "||")
+            {
+              result |= and_result;
+              and_result = true;
+            }
+          else if (n->content != "&&")
+            break;
+          l = input.scan (false);
+          op = input.scan (false);
+          r = input.scan (false);
+          if (l == 0 || op == 0 || r == 0)
+            throw parse_error ("incomplete condition after '%('", t);
+
+          and_result &= eval_pp_conditional (session, l, op, r);
+          delete l;
+          delete op;
+          delete r;
+          delete n;
+        }
+
+      result |= and_result;
+
       /*
       clog << "PP eval (" << *t << ") == " << result << endl;
       */
 
-      const token *m = input.scan (); // NB: not recursive
+      const token *m = n; // NB: not recursive
       if (! (m && m->type == tok_operator && m->content == "%?"))
         throw parse_error ("expected '%?' marker for conditional", t);
       delete m; // "%?"
-- 
1.5.6.5

  reply	other threads:[~2009-06-20 13:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-20  0:01 [PATCH] Support OR (using ||) " Przemyslaw Pawelczyk
2009-06-20 13:43 ` Przemyslaw Pawelczyk [this message]
2009-06-24 19:39   ` [PATCH] Support || and && " Josh Stone
2009-08-28  0:39 ` [PATCH 2/2] Use || and && in preprocessor's conditions in tapsets Przemyslaw Pawelczyk
2009-08-28  0:39 ` [PATCH 1/2] Support || and && in preprocessor's conditions Przemyslaw Pawelczyk
2009-08-28 18:32   ` Josh Stone

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1245505428.696071.25030@debian \
    --to=przemyslaw@pawelczyk.it \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).