MarpaX-Languages-C-AST

 view release on metacpan or  search on metacpan

share/dist/MarpaX-Languages-C-AST/xslt/csl.xsl  view on Meta::CPAN

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:csl="urn:csl">
  <xsl:output method="xml" omit-xml-declaration="no" cdata-section-elements="size" />

  <!-- =================================================================== -->
  <!--                                  MAIN                               -->
  <!-- =================================================================== -->

  <xsl:template match="/">
    <csl>
      <xsl:call-template name="anyDeclarator" />
    </csl>
  </xsl:template>

  <!-- =================================================================== -->
  <!--                              anyDeclarator                          -->
  <!-- =================================================================== -->
  <xsl:template name="anyDeclarator">
    <!--
        We search any declarator (abstract or not) from current node that is
        not a child of a scoped declaration nor array size definition, and
        that is at the end of an eventual () chain of the same declarator
        type.
        The absence of declarator is possible when we are called recursively
        for a parameterTypeList content. The signature is then well known:
        <parameterDeclaration>
          <declarationSpecifiers>
          ...
          </declarationSpecifiers>
        </parameterDeclaration>

        Note that old C-styleI identifierList will never match a declarator.
    -->
    <identifiers>
      <xsl:for-each select=".//*[
                            (
                             (
                              (local-name()='directDeclarator' and not(descendant::*[self::directDeclarator])) or
                              (local-name()='abstractDeclarator' and not(descendant::*[self::abstractDeclarator]))
                             )
                             and not
                              (ancestor::*
                               [
                               self::structDeclarationList or
                               self::parameterTypeList     or
                             
                               self::typeQualifierList     or
                               self::assignmentExpression
                               ]
                              )
                             )
                            ]
                            ">
        <xsl:if test="csl:fileOk(./@file) != 0" >
          <xsl:choose>
            <xsl:when test="local-name()='directDeclarator'">
              <xsl:text disable-output-escaping="yes">&lt;</xsl:text>identifier text="<xsl:value-of select="./@text" />"<xsl:text disable-output-escaping="yes">&gt;</xsl:text>
              <xsl:call-template name="directDeclarator" />
              <xsl:text disable-output-escaping="yes">&lt;&#47;identifier&gt;</xsl:text>
            </xsl:when>
            <xsl:when test="local-name()='abstractDeclarator'">
              <xsl:text disable-output-escaping="yes">&lt;</xsl:text>identifier text="<xsl:value-of select="csl:getAnonIdentifier()" />"<xsl:text disable-output-escaping="yes">&gt;</xsl:text>
              <xsl:call-template name="abstractDeclarator" />



( run in 1.751 second using v1.01-cache-2.11-cpan-b16cb0d3907 )