title: ClaiR/Rascal: Best way to list public functions?
body: <p>I am parsing an C++ header file using ClaiR and want to get a list of the public functions.</p>
  
  <pre><code>visit(ast) {
      case \class(_, name(n), _, decs): {
          println("class name: &lt;n&gt;");
          isPublic = true;
          for (dec &lt;- decs) {
              switch(dec) {
                  case \visibilityLabel(\public()): {
                      println("Public functions");
                      isPublic = true;
                  }
                  case \visibilityLabel(\protected()): {
                      println("Protected functions");
                      isPublic = false;
                  }
                  case \visibilityLabel(\private()): {
                      println("Private functions");
                      isPublic = false;
                  }
                  case \simpleDeclaration(_, [\functionDeclarator([*_], [*_], name(na), [*_], [*_])]): {
                      if (isPublic) {
                          println("public function: &lt;na&gt;");
                      }
                  }
              }
          }
      }
  }
  
  </code></pre>
  
  <p>The above code works. But is there a better (smaller) way of acquiring the public functions?</p>