Jelajahi Sumber

somehow working parse to xsd... todo inc elements from other namespace who has attribute... to generate new struct, and struct const

a.binder 5 tahun lalu
induk
melakukan
7a64ab8e1a

+ 2 - 2
SE/schema/WPS_Functions/automation_driven/build_automation_driven.xml

@@ -41,13 +41,13 @@
    
    
    
-   <target name="automation_driven.submodule.struct.read.xml"
+   <target name="automation_driven.submodule.struct.read.xsd"
       description="to initially generate xsd from automation_driven.submodule.struct.h file">
       <xslt basedir="${automation_driven.submodule.basedir}"
          destdir="${automation_driven.submodule.temp}"
          force="true"
          in="${empty.xml}"
-         out="${automation_driven.submodule.struct.read.xml}"
+         out="${automation_driven.submodule.struct.read.xsd}"
          style="${automation_driven.submodule.struct.read.xsl}"> <!-- ${automation_driven.submodule.struct.h} -->
          <factory name="net.sf.saxon.TransformerFactoryImpl">
             <attribute name="http://saxon.sf.net/feature/xinclude-aware" value="true"/>

+ 10 - 9
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/testing_pwm_amp/___P5_LIB/p5__struct.h

@@ -6,7 +6,7 @@
   
   
   
-  
+
   
   typedef int P5__ARRAY_T;
   typedef  P5__ARRAY_T P5__ARRAY__INDEX_T ;
@@ -18,7 +18,7 @@
   
   typedef int P5__LATENCY_T; //FOR TIMESLOTS
   typedef P5__LATENCY_T P5__LATENCY_TASK_EXEC_TIME_T ;
-  typedef unsigned long P5__LATENCY_TIMESTAMP_T ;
+  typedef unsigned_long_T P5__LATENCY_TIMESTAMP_T ;
   typedef P5__LATENCY_T P5__LATENCY_TASK_EXEC_TICKS_T ;
   typedef P5__LATENCY_T P5__LATENCY_TASK_EXEC_TICK_T ;
   typedef P5__LATENCY_T P5__LATENCY_TASK_EXEC_DIFFS_T ; //TODO jak sa wahania zeby walilo
@@ -92,10 +92,11 @@
   
   
   
-  struct P5__TASK__CONFIG__NAME__INDEX__ARRAY_S {
+    struct P5__TASK__CONFIG__NAME__INDEX__ARRAY_S { //test
         P5__TASK__CONFIG__NAME__INDEX_T P5__TASK__CONFIG__NAME__INDEX_A ;
-  };
+};
   
+ 
   typedef P5__TASK__CONFIG__NAME__INDEX__ARRAY_S P5__TASK__CONFIG__NAME__INDEX__ARRAY_T ;
 
 
@@ -103,10 +104,10 @@
 
 
   struct P5__TASK__TYPE__SEQUENCE__ARRAY_S {
-        P5__TASK__CONFIG__NAME__INDEX_T P5__TASK__CONFIG__NAME__INDEX_A; //todo assert  refs
-        P5__TASK__TYPE__ASSERT_T P5__TASK__TYPE__ASSERT_A; //
-        P5__TASK__CONFIG__NAME__INDEX__ARRAY_T P5__TASK__CONFIG__NAME__INDEX__ARRAY_A[P5__TASK__CONFIG__NAME__INDEX__ARRAY__LIMIT] ; //todo manage
-        P5__TASK__TYPE__SEQUENCE__ARRAY__ASSOC__INDEX_T P5__TASK__TYPE__SEQUENCE__ARRAY__ASSOC__INDEX_A ; //REKORD WZAJ REL
+        P5__TASK__CONFIG__NAME__INDEX_T P5__TASK__CONFIG__NAME__INDEX_A ;
+        P5__TASK__TYPE__ASSERT_T P5__TASK__TYPE__ASSERT_A ;
+        P5__TASK__CONFIG__NAME__INDEX__ARRAY_T P5__TASK__CONFIG__NAME__INDEX__ARRAY_A[P5__TASK__CONFIG__NAME__INDEX__ARRAY__LIMIT] ;
+        P5__TASK__TYPE__SEQUENCE__ARRAY__ASSOC__INDEX_T P5__TASK__TYPE__SEQUENCE__ARRAY__ASSOC__INDEX_A ;
    };
   typedef P5__TASK__TYPE__SEQUENCE__ARRAY_S P5__TASK__TYPE__SEQUENCE__ARRAY_T;
   
@@ -281,7 +282,7 @@ struct P5__TASK__TYPE__SEQUENCE__ARRAY__ASSOC_S {  //aby podlaczyc ze soba struk
  // P5__TASK__CONFIG_A[P5__TASK__CONFIG__LIMIT] = {} ;
   
   
-  typedef unsigned long   P5__TASK__CACHED__VALID__MILLIS_T ;
+  typedef unsigned_long_T P5__TASK__CACHED__VALID__MILLIS_T ;
  static   P5__TASK__CONFIG_T P5__TASK__CONFIG_A[P5__TASK__CONFIG__LIMIT] = {} ;
 
   struct P5__TASK__CACHED_S { //wycacheowana struktura, odbudowywana -child do parenta?

+ 254 - 25
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/testing_pwm_amp/automation_driven.submodule.struct.read.xsl

@@ -17,18 +17,59 @@
     
     <xsl:param name="text-encoding" as="xs:string" select="'iso-8859-1'"/>
     
+    <xsl:param name="vPrefix" select="'automation_driven.submodule.struct'"/>
     
+    <xsl:function name="automation_driven.submodule.struct:typeFix">
+        <xsl:param name="type"/>
+        <xsl:choose>
+            <xsl:when test="$type = 'int'">xs:int</xsl:when>
+            <xsl:when test="$type = 'String'">xs:string</xsl:when>
+            <xsl:otherwise><xsl:value-of select="$vPrefix"/>:<xsl:value-of select="$type"/></xsl:otherwise>
+        </xsl:choose>
+    </xsl:function>
     
+    <xsl:template name="automation_driven.submodule.struct:ContentType">
+        <xsl:param name="base" required="yes"/>
+        <xsl:choose>
+            <xsl:when test="$base = 'xs:int' or $base = 'xs:string'">
+                <xs:simpleContent>
+                    <xs:extension base="{$base}"/>
+                </xs:simpleContent>
+            </xsl:when>
+            <xsl:otherwise>
+                <xs:complexContent>
+                    <xs:extension base="{$base}"/>
+                </xs:complexContent>
+            </xsl:otherwise>
+        </xsl:choose>
+    </xsl:template>
+    
+    
+    <xsl:template name="automation_driven.submodule.struct:get_maxOccurs">
+        <xsl:param name="vText" required="yes" tunnel="yes"/>
+        <xsl:param name="constName" required="yes"/>
+        <!--<xsl:comment>
+            #27 will get maxOccurs fr constName <xsl:value-of select="$constName"/>
+        </xsl:comment>-->
+        <xsl:variable name="ltb">\s*const.*<xsl:value-of select="$constName"/>\s*=\s*(\d*)\s*;</xsl:variable>
+        <xsl:analyze-string select="$vText" regex="{$ltb}">
+            <xsl:matching-substring>
+                <xsl:value-of select="regex-group(1)"/>
+            </xsl:matching-substring>
+        </xsl:analyze-string>
+        
+    </xsl:template>
     
     
     <xsl:template name="automation_driven.submodule.struct:read.xml" >
-        <xsl:variable name="vText" select=
-            "unparsed-text($automation_driven.submodule.struct:h,$text-encoding)"/>
         
+        <xsl:param name="vText" select=
+            "unparsed-text($automation_driven.submodule.struct:h,$text-encoding)" />
+         
         <!--<xsl:variable name="vLines" select=
             "tokenize($vText, '&#xD;?&#xA;')[normalize-space()]"/>-->
         
-        <automation_driven.submodule.struct:read.xml>
+        <xs:schema>
             <!--<xsl:variable name="struct.h.txt">
                 <struct.h.txt>
                     <xsl:for-each select="tokenize($vText, '&#xD;?&#xA;')[normalize-space()]">
@@ -40,29 +81,203 @@
             </xsl:variable>-->
             <!--<xsl:apply-templates mode="automation_driven.submodule.struct:read.xml" select="$struct.h.txt"/>-->    
             
-            <xsl:analyze-string select="$vText" regex="typedef(.+) (.+);(.*)">
+            <xsl:attribute name="targetNamespace">http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/automation_driven/automation_driven/automation_driven.submodule.struct.xsd</xsl:attribute>
+            
+            
+            
+            
+            <xs:complexType mixed="false" name="String">
+                <xs:simpleContent>
+                    <xs:extension base="xs:string"/>
+                </xs:simpleContent>
+            </xs:complexType>
+            
+            
+            
+            
+            <xs:complexType name="unsigned_long_T">
+                <xs:simpleContent>
+                    <xs:extension base="xs:unsignedLong"/>
+                </xs:simpleContent>
+            </xs:complexType>
+            
+            <!--<xsl:variable name="ltb">{</xsl:variable>-->
+            <!--<xsl:variable name="ltb">\s(.*)struct(.*)\{\s*,\s(.*)\s,\s(.*)}\s</xsl:variable>-->
+            <!--<xsl:variable name="ltb">struct(.*) (.*)\{\s*((.+) (.+)(.*);)\s*.*\}.*;</xsl:variable>-->
+            <!--<xsl:variable name="ltb">struct(.*) (.*)\{\n*((.+) (.+)(.*);).*EOF</xsl:variable>-->
+            <!--<xsl:variable name="ltb">\sstruct(.*) (.*)\{\n\s{2,}((.+) (.+)(.*);(.*)\n)\s*.*\}.*;.*\n\s</xsl:variable>-->
+            <!--<xsl:variable name="ltb">struct(.*) (.*)\{\n\s*((.+) (.+)(.*);.*\n)\s.*\}.*;.*\n</xsl:variable>-->
+            <!--<xsl:variable name="ltb">^.*struct(.*) (.*)\{$(^(.+) (.+)(.*);.*$)^.*\}.*;</xsl:variable>-->
+            <!--<xsl:variable name="ltb">^.*struct(.*) (.*)\{$(^(.+) (.+)(.*);.*$)^.*\}.*;</xsl:variable>-->
+            <!--<xsl:variable name="ltb">^struct (\S*) (\s*)\{(\s*)$\s(^(\s*)(\S*)(\s*)(\S*)(\s*);$)\s^.*\}.*$</xsl:variable>-->
+            <!--<xsl:variable name="ltb">\s^struct(.*)\{$\s(^(.*);$)\s^\};$</xsl:variable>-->
+            <!--<xsl:variable name="ltb">\s((^struct(.*)\{$))\s((^.*;))\s^\};$</xsl:variable>-->
+            <xsl:variable name="ltb">^.*struct (\S*)(\s*)\{.*\s(^.*;.*$\s)+^(\s*)\};.*$</xsl:variable>
+            
+            <xsl:analyze-string select="$vText" regex="{$ltb}" flags="m">
                 <xsl:matching-substring>
                     <xsl:choose>
-                        <xsl:when test="matches(regex-group(1),'unsigned')">
-                            <xs:complexType>
+                        <xsl:when test="1 = 1"><!-- matches(regex-group(1),'_S') -->
+                            <xs:complexType >
+                                <xsl:attribute name="name" select="normalize-space(regex-group(1))"/>
+                                <xs:sequence>                  
+                                                <xsl:variable name="ltb">^\s*(\S+) (\S+)\s*;.*$</xsl:variable>
+                                                <xsl:variable name="regex-group-0" select="regex-group(0)"/>
+                                                <xsl:analyze-string select="$regex-group-0" regex="{$ltb}"  flags="m">
+                                                            <xsl:matching-substring>
+                                                                <xsl:choose>
+                                                                    <xsl:when test="matches(regex-group(2),'\[')"><!-- matches(regex-group(1),'_S') -->
+                                                                        
+                                                                        <!-- TODO get limit -->
+                                                                        <xsl:variable name="ltb">\s*(\S+)\[(\S+)\].*</xsl:variable>
+                                                                        <xsl:variable name="regex-group-1-type" select="regex-group(1)"/>
+                                                                        <xsl:variable name="regex-group-2-limit" select="regex-group(2)"/>
+                                                                            <xsl:analyze-string select="regex-group(2)" regex="{$ltb}"  flags="m">
+                                                                                <xsl:matching-substring>
+                                                                                    <xsl:variable name="regex-group-2-limit-name-1" select="normalize-space(regex-group(1))"/>
+                                                                                    <xsl:variable name="maxOccurs">
+                                                                                        <xsl:call-template name="automation_driven.submodule.struct:get_maxOccurs">
+                                                                                            <xsl:with-param name="constName" select="regex-group(2)"/>
+                                                                                            <xsl:with-param name="vText" select="$vText" tunnel="yes"/>
+                                                                                        </xsl:call-template>
+                                                                                    </xsl:variable>
+                                                                                    <xsl:comment>#89_OK get limit r:<xsl:value-of select="$ltb"/> 
+                                                                                        v:<xsl:value-of select="$regex-group-2-limit"/>
+                                                                                        res:<xsl:value-of select="regex-group(1)"/> 
+                                                                                         maxOccurs:<xsl:value-of select="$maxOccurs"/>
+                                                                                         regex-group-2-limit-name-1:<xsl:value-of select="$regex-group-2-limit-name-1"/>
+                                                                                    </xsl:comment>
+                                                                                   
+                                                                                    <xs:element name="{$regex-group-2-limit-name-1}"
+                                                                                        type="{$vPrefix}:{normalize-space($regex-group-1-type)}"
+                                                                                        maxOccurs="{$maxOccurs}">                                                                       
+                                                                                        <!--<xs:annotation>
+                                                                                            <xs:documentation> #str72_B_OCCURS</xs:documentation>
+                                                                                        </xs:annotation>-->
+                                                                                    </xs:element>
+                                                                                   
+                                                                                </xsl:matching-substring>
+                                                                                <xsl:non-matching-substring>
+                                                                                    <xsl:comment>#89_N get limit r:<xsl:value-of select="$ltb"/> 
+                                                                                        v:<xsl:value-of select="$regex-group-2-limit"/></xsl:comment>
+                                                                                </xsl:non-matching-substring>
+                                                                            </xsl:analyze-string>
+                                                                        
+                                                                        
+                                                                    </xsl:when>
+                                                                    <xsl:otherwise>
+                                                                        <xs:element name="{normalize-space(regex-group(2))}"
+                                                                            type="{$vPrefix}:{normalize-space(regex-group(1))}">                                                                       
+                                                                            <!--<xs:annotation>
+                                                                                <xs:documentation> #str72_B
+                                                                                    gr 1 <xsl:value-of select="normalize-space(regex-group(1))"/>
+                                                                                    gr_2 <xsl:value-of select="normalize-space(regex-group(2))"/>
+                                                                                    gr_3 <xsl:value-of select="normalize-space(regex-group(3))"/>
+                                                                                    gr_4 <xsl:value-of select="normalize-space(regex-group(4))"/>
+                                                                                    gr_0 <xsl:value-of select="normalize-space(regex-group(0))"/>
+                                                                                </xs:documentation>
+                                                                            </xs:annotation>-->
+                                                                        </xs:element>
+                                                                    </xsl:otherwise>
+                                                                </xsl:choose>
+                                                                <!--<xsl:element name="{normalize-space(regex-group(1))}">
+                                            <xsl:value-of select="normalize-space(regex-group(2))"/>
+                                        </xsl:element>-->
+                                                            </xsl:matching-substring>
+                                                            <!--<xsl:non-matching-substring>
+                                                                <xs:annotation>
+                                                                    <xs:documentation> #str72_C non-matching-substring from <xsl:value-of select="$regex-group-0"/> and regex <xsl:value-of select="$ltb"/>
+                                                                        gr 1 <xsl:value-of select="normalize-space(regex-group(1))"/>
+                                                                        gr_2 <xsl:value-of select="normalize-space(regex-group(2))"/>
+                                                                        gr_3 <xsl:value-of select="normalize-space(regex-group(3))"/>
+                                                                        gr_4 <xsl:value-of select="normalize-space(regex-group(4))"/>
+                                                                        gr_0 <xsl:value-of select="normalize-space(regex-group(0))"/>
+                                                                    </xs:documentation>
+                                                                </xs:annotation>
+                                                            </xsl:non-matching-substring>-->
+                                                        </xsl:analyze-string>
+                                    
+                                </xs:sequence>
+                                
+                                <!--<xs:annotation>
+                                    <xs:documentation> #str72 
+                                        gr 1 <xsl:value-of select="normalize-space(regex-group(1))"/>
+                                        gr_2 <xsl:value-of select="normalize-space(regex-group(2))"/>
+                                        gr_3 <xsl:value-of select="normalize-space(regex-group(3))"/>
+                                        gr_4 <xsl:value-of select="normalize-space(regex-group(4))"/>
+                                        gr_0 <xsl:value-of select="normalize-space(regex-group(0))"/>
+                                    </xs:documentation>
+                                </xs:annotation>-->
+                            </xs:complexType>
+                        </xsl:when>
+                        
+                        <xsl:otherwise>
+                            
+                            <xs:complexType >
                                 <xsl:attribute name="name" select="normalize-space(regex-group(2))"/>
-                                <xsl:attribute name="type" select="normalize-space(regex-group(1))"/>
+                                <xs:annotation>
+                                    <xs:documentation> #str74  
+                                        <xsl:value-of select="normalize-space(regex-group(0))"/>
+                                    </xs:documentation>
+                                </xs:annotation>
+                                <xs:sequence/>
+                            </xs:complexType>                            
+                        </xsl:otherwise>
+                    </xsl:choose>
+                    <!--<xsl:element name="{normalize-space(regex-group(1))}">
+                        <xsl:value-of select="normalize-space(regex-group(2))"/>
+                    </xsl:element>-->
+                </xsl:matching-substring>
+            </xsl:analyze-string>
+            
+            
+            
+            
+            
+            <xsl:analyze-string select="$vText" regex="(.*)typedef(.+) (.+);(.*)">
+                <xsl:matching-substring>
+                    <xsl:choose>
+                        <xsl:when test="matches(regex-group(1),'//')">
+                            <xsl:comment>
+                                <xsl:value-of select="regex-group(0)"/>
+                            </xsl:comment>
+                        </xsl:when>
+                        <xsl:when test="matches(regex-group(2),'unsigned')">
+                            <xs:complexType>
+                                <xsl:attribute name="name" select="normalize-space(regex-group(3))"/>
+                                <xs:annotation>
+                                    <xs:documentation>#219
+                                        <xsl:value-of select="normalize-space(regex-group(0))"/>
+                                    </xs:documentation>
+                                </xs:annotation>
+                                <xs:complexContent>
+                                    <xs:extension base="{$vPrefix}:{normalize-space(regex-group(2))}"/>
+                                </xs:complexContent>
                                 <!--<xsl:attribute name="type" select="tokenize(regex-group(1),' ')[1 to 2]"/>-->
                                 <!--<xsl:attribute name="name0" select="normalize-space(regex-group(0))"/>-->
                             </xs:complexType>
                         </xsl:when>
-                        <xsl:when test="string-length(normalize-space(regex-group(1))) &gt; 0">
+                        <xsl:when test="string-length(normalize-space(regex-group(2))) &gt; 0">
                             <xs:complexType>
                                 
-                                <xsl:attribute name="name" select="normalize-space(regex-group(2))"/>
-                                <xsl:attribute name="type" select="normalize-space(regex-group(1))"/>
+                                <xsl:attribute name="name" select="normalize-space(regex-group(3))"/>
+                                <xs:annotation>
+                                    <xs:documentation>#235
+                                        <xsl:value-of select="normalize-space(regex-group(0))"/>
+                                    </xs:documentation>
+                                </xs:annotation>
+                                <xsl:call-template name="automation_driven.submodule.struct:ContentType">
+                                    <xsl:with-param name="base" select="automation_driven.submodule.struct:typeFix(normalize-space(regex-group(2)))"/>
+                                </xsl:call-template>
                                 <!--<xsl:attribute name="name0" select="normalize-space(regex-group(0))"/>-->
                             </xs:complexType>
                         </xsl:when>
                         <xsl:otherwise>
-                            <OTHER>
-                                <xsl:attribute name="name0" select="normalize-space(regex-group(0))"/>
-                            </OTHER>
+                            <xs:annotation>
+                                <xs:documentation> #87 
+                                    <xsl:value-of select="normalize-space(regex-group(0))"/>
+                                </xs:documentation>
+                            </xs:annotation>
                         </xsl:otherwise>
                     </xsl:choose>
                     <!--<xsl:element name="{normalize-space(regex-group(1))}">
@@ -71,29 +286,43 @@
                 </xsl:matching-substring>
             </xsl:analyze-string>
             
-            <xsl:analyze-string select="$vText" regex="const(.+) (.+)=(.+)(.*);(.*)">
+            <xsl:analyze-string select="$vText" regex="\s*const\s+(\S+)\s+(\S+)\s*=\s*(\d+)\s*;.*">
                 <xsl:matching-substring>
                     <xsl:choose>
                         <xsl:when test="matches(regex-group(1),'unsigned')">
-                            <xs:element>
-                                <xsl:attribute name="name" select="normalize-space(regex-group(2))"/>
-                                <xsl:attribute name="type" select="normalize-space(regex-group(1))"/>
+                            <xs:element name="{normalize-space(regex-group(2))}" 
+                                type="{$vPrefix}:{normalize-space(regex-group(1))}">
                                 <!--<xsl:attribute name="type" select="tokenize(regex-group(1),' ')[1 to 2]"/>-->
                                 <!--<xsl:attribute name="name0" select="normalize-space(regex-group(0))"/>-->
+                                <xs:annotation>
+                                    <xs:documentation> #276
+                                        <xsl:value-of select="normalize-space(regex-group(0))"/>
+                                    </xs:documentation>
+                                </xs:annotation>
                             </xs:element>
                         </xsl:when>
                         <xsl:when test="string-length(normalize-space(regex-group(1))) &gt; 0">
-                            <xs:element>
-                                
-                                <xsl:attribute name="name" select="normalize-space(regex-group(2))"/>
-                                <xsl:attribute name="type" select="normalize-space(regex-group(1))"/>
+                            <xs:element  name="{normalize-space(regex-group(2))}" 
+                                type="{$vPrefix}:{normalize-space(regex-group(1))}"
+                                fixed="{normalize-space(regex-group(3))}"
+                                >
                                 <!--<xsl:attribute name="name0" select="normalize-space(regex-group(0))"/>-->
+                                <xs:annotation>
+                                    <xs:documentation>#283 
+                                       0: <xsl:value-of select="normalize-space(regex-group(0))"/>
+                                        1: <xsl:value-of select="normalize-space(regex-group(1))"/>
+                                        2: <xsl:value-of select="normalize-space(regex-group(2))"/>
+                                        3: <xsl:value-of select="normalize-space(regex-group(3))"/>
+                                    </xs:documentation>
+                                </xs:annotation>
                             </xs:element>
                         </xsl:when>
                         <xsl:otherwise>
-                            <OTHERelement>
-                                <xsl:attribute name="name0" select="normalize-space(regex-group(0))"/>
-                            </OTHERelement>
+                            <xs:annotation>
+                                <xs:documentation>#128 
+                                    <xsl:value-of select="normalize-space(regex-group(0))"/>
+                                </xs:documentation>
+                            </xs:annotation>
                         </xsl:otherwise>
                     </xsl:choose>
                     <!--<xsl:element name="{normalize-space(regex-group(1))}">
@@ -103,7 +332,7 @@
             </xsl:analyze-string>
             
             
-        </automation_driven.submodule.struct:read.xml>
+        </xs:schema>
     </xsl:template>
     
     

+ 1 - 0
SE/stuff/P5_Automation_can-dev-res-working-1930/___SUBMODULES___/testing_pwm_amp/testing_pwm_amp.ino

@@ -18,6 +18,7 @@
 //#include <vector>
 //#include <iterator>
 
+#include "___P5_LIB/p5__struct__simpleTypes.h"
 #include "___P5_LIB/p5__struct.h"
 #include "___P5_LIB/p5__progmem.h"