⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xml.htm

📁 C-smile OOL is a scripting language with C++-like grammar. It has compiler, VM running bytecodes and
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<FONT color='gray'> 73| </FONT><FONT color='green'>//| always returns string</FONT>
<FONT color='gray'> 74| </FONT><FONT color='green'>//|</FONT>
<FONT color='gray'> 75| </FONT>    <FONT color='darkblue'><B>property</B></FONT> <FONT color='purple'>value</FONT><FONT color='dimgray'>(</FONT>v<FONT color='dimgray'>)</FONT> <FONT color='dimgray'>{</FONT>  
<FONT color='gray'> 76| </FONT>    <FONT color='green'>// read/write  </FONT>
<FONT color='gray'> 77| </FONT>      <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT><FONT color='dimgray'>!</FONT><FONT color='purple'>is_undefined</FONT><FONT color='dimgray'>(</FONT>v<FONT color='dimgray'>)</FONT><FONT color='dimgray'>)</FONT> _value <FONT color='dimgray'>=</FONT> v<FONT color='dimgray'>;</FONT>
<FONT color='gray'> 78| </FONT>      <FONT color='darkblue'><B>return</B></FONT> _value<FONT color='dimgray'>;</FONT>
<FONT color='gray'> 79| </FONT>    <FONT color='dimgray'>}</FONT>
<FONT color='gray'> 80| </FONT><FONT color='green'>//|    </FONT>
<FONT color='gray'> 81| </FONT><FONT color='green'>//| creates string representation of content</FONT>
<FONT color='gray'> 82| </FONT><FONT color='green'>//| always returns string</FONT>
<FONT color='gray'> 83| </FONT><FONT color='green'>//|</FONT>
<FONT color='gray'> 84| </FONT>    <FONT color='darkblue'><B>function</B></FONT> <FONT color='purple'>valueToString</FONT><FONT color='dimgray'>(</FONT><FONT color='dimgray'>)</FONT> <FONT color='dimgray'>{</FONT>  
<FONT color='gray'> 85| </FONT>      <FONT color='green'>//out.printf(&quot;DEBUG: (%s) valueToString\n&quot;,_name);</FONT>
<FONT color='gray'> 86| </FONT>      <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT>_value<FONT color='dimgray'>)</FONT> <FONT color='darkblue'><B>return</B></FONT> <FONT color='purple'>unescape</FONT><FONT color='dimgray'>(</FONT>_value<FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'> 87| </FONT>      <FONT color='darkblue'><B>return</B></FONT> <FONT color='maroon'>&quot;&quot;</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'> 88| </FONT>    <FONT color='dimgray'>}</FONT>
<FONT color='gray'> 89| </FONT>  
<FONT color='gray'> 90| </FONT>    <FONT color='darkblue'><B>function</B></FONT> <FONT color='purple'>toString</FONT><FONT color='dimgray'>(</FONT><FONT color='dimgray'>)</FONT> <FONT color='dimgray'>{</FONT>
<FONT color='gray'> 91| </FONT>      <FONT color='darkblue'><B>var</B></FONT> i<FONT color='dimgray'>;</FONT>
<FONT color='gray'> 92| </FONT>      <FONT color='darkblue'><B>var</B></FONT> s <FONT color='dimgray'>=</FONT> <FONT color='maroon'>&quot;&lt;&quot;</FONT> <FONT color='dimgray'>+</FONT> _name<FONT color='dimgray'>;</FONT>
<FONT color='gray'> 93| </FONT>      <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT>_attributes<FONT color='dimgray'>)</FONT> 
<FONT color='gray'> 94| </FONT>          <FONT color='darkblue'><B>for</B></FONT> <FONT color='purple'></FONT><FONT color='dimgray'>(</FONT>i <FONT color='dimgray'>=</FONT> <FONT color='red'>0</FONT><FONT color='dimgray'>;</FONT> i <FONT color='dimgray'>&lt;</FONT> _attributes<FONT color='dimgray'>.</FONT>length<FONT color='dimgray'>;</FONT> i<FONT color='dimgray'>++</FONT><FONT color='dimgray'>)</FONT> 
<FONT color='gray'> 95| </FONT>            s <FONT color='dimgray'>+=</FONT> string<FONT color='dimgray'>::</FONT><FONT color='purple'>printf</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>&quot; %s=\&quot;%s\&quot;&quot;</FONT><FONT color='dimgray'>,</FONT>_attributes<FONT color='dimgray'>.</FONT><FONT color='purple'>key</FONT><FONT color='dimgray'>(</FONT>i<FONT color='dimgray'>)</FONT><FONT color='dimgray'>,</FONT><FONT color='purple'>unescape</FONT><FONT color='dimgray'>(</FONT>_attributes<FONT color='dimgray'>.</FONT><FONT color='purple'>value</FONT><FONT color='dimgray'>(</FONT>i<FONT color='dimgray'>)</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'> 96| </FONT>      <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT>_value<FONT color='dimgray'>)</FONT>
<FONT color='gray'> 97| </FONT>        s <FONT color='dimgray'>+=</FONT> <FONT color='purple'></FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>&quot; &gt;&quot;</FONT> <FONT color='dimgray'>+</FONT> <FONT color='purple'>valueToString</FONT><FONT color='dimgray'>(</FONT><FONT color='dimgray'>)</FONT> <FONT color='dimgray'>+</FONT> string<FONT color='dimgray'>::</FONT><FONT color='purple'>printf</FONT><FONT color='dimgray'>(</FONT><FONT color='maroon'>&quot;&lt;/%s&gt;&quot;</FONT><FONT color='dimgray'>,</FONT> _name<FONT color='dimgray'>)</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'> 98| </FONT>      <FONT color='darkblue'><B>else</B></FONT> 
<FONT color='gray'> 99| </FONT>        s <FONT color='dimgray'>+=</FONT> <FONT color='maroon'>&quot; /&gt;&quot;</FONT><FONT color='dimgray'>;</FONT>  
<FONT color='gray'>100| </FONT>      <FONT color='darkblue'><B>return</B></FONT> s<FONT color='dimgray'>;</FONT>
<FONT color='gray'>101| </FONT>    <FONT color='dimgray'>}</FONT>
<FONT color='gray'>102| </FONT><FONT color='dimgray'>}</FONT>
<FONT color='gray'>103| </FONT>
<FONT color='gray'>104| </FONT><FONT color='green'>//|    </FONT>
<FONT color='gray'>105| </FONT><FONT color='green'>//| element has text value(s) and/or children </FONT>
<FONT color='gray'>106| </FONT><FONT color='green'>//|</FONT>
<FONT color='gray'>107| </FONT><FONT color='darkblue'><B>class</B></FONT> element<FONT color='dimgray'>:</FONT> simple_element 
<FONT color='gray'>108| </FONT><FONT color='dimgray'>{</FONT>
<FONT color='gray'>109| </FONT>  
<FONT color='gray'>110| </FONT>    <FONT color='darkblue'><B>function</B></FONT> <FONT color='purple'>element</FONT><FONT color='dimgray'>(</FONT>name<FONT color='dimgray'>,</FONT>atts<FONT color='dimgray'>,</FONT>content<FONT color='dimgray'>)</FONT> <FONT color='dimgray'>{</FONT> <FONT color='purple'>simple_element</FONT><FONT color='dimgray'>(</FONT>name<FONT color='dimgray'>,</FONT>atts<FONT color='dimgray'>,</FONT>content<FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT> <FONT color='dimgray'>}</FONT>
<FONT color='gray'>111| </FONT><FONT color='green'>//|    </FONT>
<FONT color='gray'>112| </FONT><FONT color='green'>//| value here is just all text children</FONT>
<FONT color='gray'>113| </FONT><FONT color='green'>//| always returns string</FONT>
<FONT color='gray'>114| </FONT><FONT color='green'>//|</FONT>
<FONT color='gray'>115| </FONT>    <FONT color='darkblue'><B>property</B></FONT> <FONT color='purple'>value</FONT><FONT color='dimgray'>(</FONT><FONT color='dimgray'>)</FONT> <FONT color='dimgray'>{</FONT>  
<FONT color='gray'>116| </FONT>      <FONT color='green'>// read only </FONT>
<FONT color='gray'>117| </FONT>      <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT><FONT color='dimgray'>!</FONT>_value<FONT color='dimgray'>)</FONT> <FONT color='darkblue'><B>return</B></FONT> <FONT color='maroon'>&quot;&quot;</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>118| </FONT>      <FONT color='darkblue'><B>var</B></FONT> i<FONT color='dimgray'>,</FONT>v <FONT color='dimgray'>=</FONT> <FONT color='maroon'>&quot;&quot;</FONT><FONT color='dimgray'>;</FONT> 
<FONT color='gray'>119| </FONT>      <FONT color='darkblue'><B>for</B></FONT><FONT color='dimgray'>(</FONT>i <FONT color='dimgray'>=</FONT> <FONT color='red'>0</FONT><FONT color='dimgray'>;</FONT> i <FONT color='dimgray'>&lt;</FONT> _value<FONT color='dimgray'>.</FONT>length<FONT color='dimgray'>;</FONT> i<FONT color='dimgray'>++</FONT><FONT color='dimgray'>)</FONT> <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT><FONT color='purple'>is_string</FONT><FONT color='dimgray'>(</FONT>_value<FONT color='dimgray'>[</FONT>i<FONT color='dimgray'>]</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>)</FONT> v <FONT color='dimgray'>+=</FONT> _value<FONT color='dimgray'>[</FONT>i<FONT color='dimgray'>]</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>120| </FONT>      <FONT color='darkblue'><B>return</B></FONT> v<FONT color='dimgray'>;</FONT>
<FONT color='gray'>121| </FONT>    <FONT color='dimgray'>}</FONT>
<FONT color='gray'>122| </FONT><FONT color='green'>//|    </FONT>
<FONT color='gray'>123| </FONT><FONT color='green'>//| returns first element with the given tag_name</FONT>
<FONT color='gray'>124| </FONT><FONT color='green'>//|</FONT>
<FONT color='gray'>125| </FONT>    <FONT color='darkblue'><B>function</B></FONT> <FONT color='purple'>child</FONT><FONT color='dimgray'>(</FONT>tag_name<FONT color='dimgray'>)</FONT>
<FONT color='gray'>126| </FONT>    <FONT color='dimgray'>{</FONT>
<FONT color='gray'>127| </FONT>      <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT>_value<FONT color='dimgray'>)</FONT> <FONT color='dimgray'>{</FONT>
<FONT color='gray'>128| </FONT>        <FONT color='darkblue'><B>var</B></FONT> i<FONT color='dimgray'>;</FONT> 
<FONT color='gray'>129| </FONT>        <FONT color='darkblue'><B>for</B></FONT><FONT color='dimgray'>(</FONT>i <FONT color='dimgray'>=</FONT> <FONT color='red'>0</FONT><FONT color='dimgray'>;</FONT> i <FONT color='dimgray'>&lt;</FONT> _value<FONT color='dimgray'>.</FONT>length<FONT color='dimgray'>;</FONT> i<FONT color='dimgray'>++</FONT><FONT color='dimgray'>)</FONT> 
<FONT color='gray'>130| </FONT>          <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT> <FONT color='purple'></FONT><FONT color='dimgray'>(</FONT>_value<FONT color='dimgray'>[</FONT>i<FONT color='dimgray'>]</FONT> instanceof xml<FONT color='dimgray'>::</FONT>simple_element<FONT color='dimgray'>)</FONT> <FONT color='dimgray'>&amp;&amp;</FONT> 
<FONT color='gray'>131| </FONT>              <FONT color='purple'></FONT><FONT color='dimgray'>(</FONT>_value<FONT color='dimgray'>[</FONT>i<FONT color='dimgray'>]</FONT><FONT color='dimgray'>.</FONT>_name <FONT color='dimgray'>==</FONT> tag_name<FONT color='dimgray'>)</FONT> <FONT color='dimgray'>)</FONT> <FONT color='darkblue'><B>return</B></FONT> _value<FONT color='dimgray'>[</FONT>i<FONT color='dimgray'>]</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>132| </FONT>      <FONT color='dimgray'>}</FONT>
<FONT color='gray'>133| </FONT>      <FONT color='darkblue'><B>return</B></FONT> <FONT color='darkblue'><B>null</B></FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>134| </FONT>    <FONT color='dimgray'>}</FONT>
<FONT color='gray'>135| </FONT><FONT color='green'>//|    </FONT>
<FONT color='gray'>136| </FONT><FONT color='green'>//| tag_name here is template of tag name.</FONT>
<FONT color='gray'>137| </FONT><FONT color='green'>//| returns 1) array of subelements with the given tag_name</FONT>
<FONT color='gray'>138| </FONT><FONT color='green'>//|      or 2) map of subelements with the given tag_name and having attribute att_name.</FONT>
<FONT color='gray'>139| </FONT><FONT color='green'>//|            key of the map is value of att_name (these values supposed to be unique</FONT>
<FONT color='gray'>140| </FONT><FONT color='green'>//|            among all children of given element)</FONT>
<FONT color='gray'>141| </FONT><FONT color='green'>//|</FONT>
<FONT color='gray'>142| </FONT>    <FONT color='darkblue'><B>function</B></FONT> <FONT color='purple'>elements</FONT><FONT color='dimgray'>(</FONT>tag_name<FONT color='dimgray'>,</FONT>att_name<FONT color='dimgray'>)</FONT>
<FONT color='gray'>143| </FONT>    <FONT color='dimgray'>{</FONT>
<FONT color='gray'>144| </FONT>      <FONT color='darkblue'><B>var</B></FONT> r<FONT color='dimgray'>;</FONT>
<FONT color='gray'>145| </FONT>      <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT>att_name<FONT color='dimgray'>)</FONT> <FONT color='green'>// map</FONT>
<FONT color='gray'>146| </FONT>      <FONT color='dimgray'>{</FONT> 
<FONT color='gray'>147| </FONT>        r <FONT color='dimgray'>=</FONT> <FONT color='darkblue'><B>new</B></FONT> <FONT color='purple'>map</FONT><FONT color='dimgray'>(</FONT><FONT color='dimgray'>)</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>148| </FONT>        <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT><FONT color='dimgray'>!</FONT>_value<FONT color='dimgray'>)</FONT> <FONT color='darkblue'><B>return</B></FONT> r<FONT color='dimgray'>;</FONT> 
<FONT color='gray'>149| </FONT>        <FONT color='darkblue'><B>var</B></FONT> i<FONT color='dimgray'>;</FONT> 
<FONT color='gray'>150| </FONT>        <FONT color='darkblue'><B>for</B></FONT><FONT color='dimgray'>(</FONT>i <FONT color='dimgray'>=</FONT> <FONT color='red'>0</FONT><FONT color='dimgray'>;</FONT> i <FONT color='dimgray'>&lt;</FONT> _value<FONT color='dimgray'>.</FONT>length<FONT color='dimgray'>;</FONT> i<FONT color='dimgray'>++</FONT><FONT color='dimgray'>)</FONT> 
<FONT color='gray'>151| </FONT>        <FONT color='dimgray'>{</FONT>
<FONT color='gray'>152| </FONT>           <FONT color='darkblue'><B>var</B></FONT> el <FONT color='dimgray'>=</FONT> _value<FONT color='dimgray'>[</FONT>i<FONT color='dimgray'>]</FONT><FONT color='dimgray'>;</FONT>
<FONT color='gray'>153| </FONT>           <FONT color='darkblue'><B>if</B></FONT><FONT color='dimgray'>(</FONT> el instanceof xml<FONT color='dimgray'>::</FONT>simple_element <FONT color='dimgray'>&amp;&amp;</FONT> el<FONT color='dimgray'>.</FONT>_name<FONT color='dimgray'>.</FONT><FONT color='purple'>like</FONT><FONT color='dimgray'>(</FONT>tag_name<FONT color='dimgray'>)</FONT><FONT color='dimgray'>)</FONT> 
<FONT color='gray'>154| </FONT>           <FONT color='dimgray'>{</FONT>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -