| 1 | <?xml version="1.0"?> |
|---|
| 2 | <!DOCTYPE article |
|---|
| 3 | PUBLIC "-//OASIS//DTD DocBook V4.2//EN" |
|---|
| 4 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> |
|---|
| 5 | |
|---|
| 6 | <article> |
|---|
| 7 | <articleinfo> |
|---|
| 8 | <title> |
|---|
| 9 | Integer Language-Independent Type for |
|---|
| 10 | <trademark>YAML</trademark> Version 1.1 |
|---|
| 11 | </title> |
|---|
| 12 | |
|---|
| 13 | <subtitle> |
|---|
| 14 | Working Draft 2005-02-11 |
|---|
| 15 | </subtitle> |
|---|
| 16 | |
|---|
| 17 | <authorgroup> |
|---|
| 18 | <author> |
|---|
| 19 | <firstname>Oren</firstname> |
|---|
| 20 | <surname>Ben-Kiki</surname> |
|---|
| 21 | <email>oren@ben-kiki.org</email> |
|---|
| 22 | </author> |
|---|
| 23 | |
|---|
| 24 | <author> |
|---|
| 25 | <firstname>Clark</firstname> |
|---|
| 26 | <surname>Evans</surname> |
|---|
| 27 | <email>cce+yaml@clarkevans.com</email> |
|---|
| 28 | </author> |
|---|
| 29 | |
|---|
| 30 | <author> |
|---|
| 31 | <firstname>Brian</firstname> |
|---|
| 32 | <surname>Ingerson</surname> |
|---|
| 33 | <email>ingy@ttul.org</email> |
|---|
| 34 | </author> |
|---|
| 35 | </authorgroup> |
|---|
| 36 | |
|---|
| 37 | <copyright> |
|---|
| 38 | <year>2001-2005</year> |
|---|
| 39 | <holder>Oren Ben-Kiki<fo>, </fo></holder> |
|---|
| 40 | <holder>Clark Evans<fo>, </fo></holder> |
|---|
| 41 | <holder>Brian Ingerson</holder> |
|---|
| 42 | </copyright> |
|---|
| 43 | |
|---|
| 44 | <legalnotice> |
|---|
| 45 | This document may be freely copied provided it is not modified. |
|---|
| 46 | </legalnotice> |
|---|
| 47 | |
|---|
| 48 | <abstract> |
|---|
| 49 | <title>Status</title> |
|---|
| 50 | |
|---|
| 51 | <para> |
|---|
| 52 | This specification is a draft reflecting consensus reached by members of |
|---|
| 53 | the <ulink |
|---|
| 54 | url="http://lists.sourceforge.net/lists/listinfo/yaml-core">yaml-core |
|---|
| 55 | mailing list</ulink>. Any questions regarding this draft should be |
|---|
| 56 | raised on this list. |
|---|
| 57 | </para> |
|---|
| 58 | </abstract> |
|---|
| 59 | </articleinfo> |
|---|
| 60 | |
|---|
| 61 | <section> |
|---|
| 62 | <variablelist> |
|---|
| 63 | <varlistentry> |
|---|
| 64 | <term> |
|---|
| 65 | <para> |
|---|
| 66 | URI: |
|---|
| 67 | </para> |
|---|
| 68 | </term> |
|---|
| 69 | |
|---|
| 70 | <listitem> |
|---|
| 71 | <para> |
|---|
| 72 | <userinput>tag:yaml.org,2002:int</userinput> |
|---|
| 73 | </para> |
|---|
| 74 | </listitem> |
|---|
| 75 | </varlistentry> |
|---|
| 76 | |
|---|
| 77 | <varlistentry> |
|---|
| 78 | <term> |
|---|
| 79 | <para> |
|---|
| 80 | Shorthand: |
|---|
| 81 | </para> |
|---|
| 82 | </term> |
|---|
| 83 | |
|---|
| 84 | <listitem> |
|---|
| 85 | <para> |
|---|
| 86 | <userinput>!!int</userinput> |
|---|
| 87 | </para> |
|---|
| 88 | </listitem> |
|---|
| 89 | </varlistentry> |
|---|
| 90 | |
|---|
| 91 | <varlistentry> |
|---|
| 92 | <term> |
|---|
| 93 | <para> |
|---|
| 94 | Kind: |
|---|
| 95 | </para> |
|---|
| 96 | </term> |
|---|
| 97 | |
|---|
| 98 | <listitem> |
|---|
| 99 | <para> |
|---|
| 100 | Scalar. |
|---|
| 101 | </para> |
|---|
| 102 | </listitem> |
|---|
| 103 | </varlistentry> |
|---|
| 104 | |
|---|
| 105 | <varlistentry> |
|---|
| 106 | <term> |
|---|
| 107 | <para> |
|---|
| 108 | Definition: |
|---|
| 109 | </para> |
|---|
| 110 | </term> |
|---|
| 111 | |
|---|
| 112 | <listitem> |
|---|
| 113 | <para> |
|---|
| 114 | Mathematical integers. |
|---|
| 115 | </para> |
|---|
| 116 | |
|---|
| 117 | <para> |
|---|
| 118 | Integers represent arbitrarily sized finite mathematical integers. |
|---|
| 119 | Integers can be formatted using the familiar decimal notation, may |
|---|
| 120 | have a leading <quote><userinput>0x</userinput></quote> to signal |
|---|
| 121 | hexadecimal, a leading <quote><userinput>0b</userinput></quote> to |
|---|
| 122 | indicate binary bits (base 2), or have leading |
|---|
| 123 | <quote><userinput>0</userinput></quote> to signal an octal base. |
|---|
| 124 | Using <quote><userinput>:</userinput></quote> allows expressing |
|---|
| 125 | integers in base 60, which is convenient for time and angle values. |
|---|
| 126 | Any <quote><userinput>_</userinput></quote> characters in the |
|---|
| 127 | number are ignored, allowing a readable representation of large |
|---|
| 128 | values. |
|---|
| 129 | </para> |
|---|
| 130 | |
|---|
| 131 | <para> |
|---|
| 132 | Scalars of this type should be represented by a native integer data |
|---|
| 133 | type, if possible. However, there are cases where an integer |
|---|
| 134 | provided may overflow the native type’s storage capability. |
|---|
| 135 | In this case, the processor should find some manner to round-trip |
|---|
| 136 | the integer, perhaps using a string based representation. In |
|---|
| 137 | general, integers representable using 32 binary digits should |
|---|
| 138 | safely round-trip through most systems. |
|---|
| 139 | </para> |
|---|
| 140 | </listitem> |
|---|
| 141 | </varlistentry> |
|---|
| 142 | |
|---|
| 143 | <varlistentry> |
|---|
| 144 | <term> |
|---|
| 145 | <para> |
|---|
| 146 | Canonical Format: |
|---|
| 147 | </para> |
|---|
| 148 | </term> |
|---|
| 149 | |
|---|
| 150 | <listitem> |
|---|
| 151 | <para> |
|---|
| 152 | <userinput>0|-?[1-9]&[0-9]* <lineannotation># (base |
|---|
| 153 | 10)</lineannotation></userinput> |
|---|
| 154 | </para> |
|---|
| 155 | </listitem> |
|---|
| 156 | </varlistentry> |
|---|
| 157 | |
|---|
| 158 | <varlistentry> |
|---|
| 159 | <term> |
|---|
| 160 | <para> |
|---|
| 161 | Resolution and Validation: |
|---|
| 162 | </para> |
|---|
| 163 | </term> |
|---|
| 164 | |
|---|
| 165 | <listitem> |
|---|
| 166 | <para> |
|---|
| 167 | Valid values must match the following regular expression, |
|---|
| 168 | which may also be used for implicit tag resolution: |
|---|
| 169 | </para> |
|---|
| 170 | |
|---|
| 171 | <screen> |
|---|
| 172 | [-+]?0b[0-1_]+ <lineannotation># (base 2)</lineannotation> |
|---|
| 173 | |[-+]?0[0-7_]+ <lineannotation># (base 8)</lineannotation> |
|---|
| 174 | |[-+]?(0|[1-9][0-9_]*) <lineannotation># (base 10)</lineannotation> |
|---|
| 175 | |[-+]?0x[0-9a-fA-F_]+ <lineannotation># (base 16)</lineannotation> |
|---|
| 176 | |[-+]?[1-9][0-9_]*(:[0-5]?[0-9])+ <lineannotation># (base 60)</lineannotation> |
|---|
| 177 | </screen> |
|---|
| 178 | </listitem> |
|---|
| 179 | </varlistentry> |
|---|
| 180 | </variablelist> |
|---|
| 181 | |
|---|
| 182 | <example> |
|---|
| 183 | <title><userinput>!!int</userinput> Examples</title> |
|---|
| 184 | <programlisting> |
|---|
| 185 | canonical: 685230 |
|---|
| 186 | decimal: +685_230 |
|---|
| 187 | octal: 02472256 |
|---|
| 188 | hexadecimal: 0x_0A_74_AE |
|---|
| 189 | binary: 0b1010_0111_0100_1010_1110 |
|---|
| 190 | sexagesimal: 190:20:30 |
|---|
| 191 | </programlisting> |
|---|
| 192 | </example> |
|---|
| 193 | </section> |
|---|
| 194 | </article> |
|---|