README.markdown in cast-0.2.1 vs README.markdown in cast-0.3.0

- old
+ new

@@ -38,162 +38,118 @@ ## Nodes `C.parse` returns a tree of `Node` objects. Here's the class hierarchy: -<div class="node_classes"> - <style scoped="scoped"> - div.node_classes .node_class_abstract { - font-weight: bold; - } - div.node_classes .column { - line-height: 120%; - float: left; - color: #222; - } - div.node_classes .spacer { - display: float; - clear: both; - } - </style> - <ul class="column"> - <li class="node_class"><span class="node_class_abstract">Node</span><ul> - <li class="node_class"><span class="node_class_concrete">TranslationUnit</span></li> - <li class="node_class"><span class="node_class_concrete">Comment</span></li> - <li class="node_class"><span class="node_class_concrete">Declaration</span></li> - <li class="node_class"><span class="node_class_concrete">Declarator</span></li> - <li class="node_class"><span class="node_class_concrete">FunctionDef</span></li> - <li class="node_class"><span class="node_class_concrete">Parameter</span></li> - <li class="node_class"><span class="node_class_concrete">Enumerator</span></li> - <li class="node_class"><span class="node_class_concrete">MemberInit</span></li> - <li class="node_class"><span class="node_class_concrete">Member</span></li> - <li class="node_class"><span class="node_class_abstract">Statement</span><ul> - <li class="node_class"><span class="node_class_concrete">Block</span></li> - <li class="node_class"><span class="node_class_concrete">If</span></li> - <li class="node_class"><span class="node_class_concrete">Switch</span></li> - <li class="node_class"><span class="node_class_concrete">While</span></li> - <li class="node_class"><span class="node_class_concrete">For</span></li> - <li class="node_class"><span class="node_class_concrete">Goto</span></li> - <li class="node_class"><span class="node_class_concrete">Continue</span></li> - <li class="node_class"><span class="node_class_concrete">Break</span></li> - <li class="node_class"><span class="node_class_concrete">Return</span></li> - <li class="node_class"><span class="node_class_concrete">ExpressionStatement</span></li> - </ul></li> - <li class="node_class"><span class="node_class_abstract">Label</span><ul> - <li class="node_class"><span class="node_class_concrete">PlainLabel</span></li> - <li class="node_class"><span class="node_class_concrete">Default</span></li> - <li class="node_class"><span class="node_class_concrete">Case</span></li> - </ul></li> - <li class="node_class"><span class="node_class_abstract">Type</span><ul> - <li class="node_class"><span class="node_class_abstract">IndirectType</span><ul> - <li class="node_class"><span class="node_class_concrete">Pointer</span></li> - <li class="node_class"><span class="node_class_concrete">Array</span></li> - <li class="node_class"><span class="node_class_concrete">Function</span></li> - </ul></li> - <li class="node_class"><span class="node_class_abstract">DirectType</span><ul> - <li class="node_class"><span class="node_class_concrete">Struct</span></li> - <li class="node_class"><span class="node_class_concrete">Union</span></li> - <li class="node_class"><span class="node_class_concrete">Enum</span></li> - <li class="node_class"><span class="node_class_concrete">CustomType</span></li> - <li class="node_class"><span class="node_class_abstract">PrimitiveType</span><ul> - <li class="node_class"><span class="node_class_concrete">Void</span></li> - <li class="node_class"><span class="node_class_concrete">Int</span></li> - <li class="node_class"><span class="node_class_concrete">Float</span></li> - <li class="node_class"><span class="node_class_concrete">Char</span></li> - <li class="node_class"><span class="node_class_concrete">Bool</span></li> - <li class="node_class"><span class="node_class_concrete">Complex</span></li> - <li class="node_class"><span class="node_class_concrete">Imaginary</span></li> - </ul></li> - </ul></li> - </ul></li> - </ul></li> - </ul> - <ul class="column"> - <li class="node_class"><span class="node_class_abstract">Node</span><ul> - <li class="node_class"><span class="node_class_abstract">Expression</span><ul> - <li class="node_class"><span class="node_class_concrete">Comma</span></li> - <li class="node_class"><span class="node_class_concrete">Conditional</span></li> - <li class="node_class"><span class="node_class_concrete">Variable</span></li> - <li class="node_class"><span class="node_class_abstract">UnaryExpression</span><ul> - <li class="node_class"><span class="node_class_abstract">PostfixExpression</span><ul> - <li class="node_class"><span class="node_class_concrete">Index</span></li> - <li class="node_class"><span class="node_class_concrete">Call</span></li> - <li class="node_class"><span class="node_class_concrete">Dot</span></li> - <li class="node_class"><span class="node_class_concrete">Arrow</span></li> - <li class="node_class"><span class="node_class_concrete">PostInc</span></li> - <li class="node_class"><span class="node_class_concrete">PostDec</span></li> - </ul></li> - <li class="node_class"><span class="node_class_abstract">PrefixExpression</span><ul> - <li class="node_class"><span class="node_class_concrete">Cast</span></li> - <li class="node_class"><span class="node_class_concrete">Address</span></li> - <li class="node_class"><span class="node_class_concrete">Dereference</span></li> - <li class="node_class"><span class="node_class_concrete">Sizeof</span></li> - <li class="node_class"><span class="node_class_concrete">Plus</span></li> - <li class="node_class"><span class="node_class_concrete">Minus</span></li> - <li class="node_class"><span class="node_class_concrete">PreInc</span></li> - <li class="node_class"><span class="node_class_concrete">PreDec</span></li> - <li class="node_class"><span class="node_class_concrete">BitNot</span></li> - <li class="node_class"><span class="node_class_concrete">Not</span></li> - </ul></li> - </ul></li> - <li class="node_class"><span class="node_class_abstract">BinaryExpression</span><ul> - <li class="node_class"><span class="node_class_concrete">Add</span></li> - <li class="node_class"><span class="node_class_concrete">Subtract</span></li> - <li class="node_class"><span class="node_class_concrete">Multiply</span></li> - <li class="node_class"><span class="node_class_concrete">Divide</span></li> - <li class="node_class"><span class="node_class_concrete">Mod</span></li> - <li class="node_class"><span class="node_class_concrete">Equal</span></li> - <li class="node_class"><span class="node_class_concrete">NotEqual</span></li> - <li class="node_class"><span class="node_class_concrete">Less</span></li> - <li class="node_class"><span class="node_class_concrete">More</span></li> - <li class="node_class"><span class="node_class_concrete">LessOrEqual</span></li> - <li class="node_class"><span class="node_class_concrete">MoreOrEqual</span></li> - <li class="node_class"><span class="node_class_concrete">BitAnd</span></li> - <li class="node_class"><span class="node_class_concrete">BitOr</span></li> - <li class="node_class"><span class="node_class_concrete">BitXor</span></li> - <li class="node_class"><span class="node_class_concrete">ShiftLeft</span></li> - <li class="node_class"><span class="node_class_concrete">ShiftRight</span></li> - <li class="node_class"><span class="node_class_concrete">And</span></li> - <li class="node_class"><span class="node_class_concrete">Or</span></li> - </ul></li> - </ul></li> - </ul></li> - </ul> - <ul class="column"> - <li class="node_class"><span class="node_class_abstract">Node</span><ul> - <li class="node_class"><span class="node_class_abstract">Expression</span><ul> - <li class="node_class"><span class="node_class_abstract">AssignmentExpression</span><ul> - <li class="node_class"><span class="node_class_concrete">Assign</span></li> - <li class="node_class"><span class="node_class_concrete">MultiplyAssign</span></li> - <li class="node_class"><span class="node_class_concrete">DivideAssign</span></li> - <li class="node_class"><span class="node_class_concrete">ModAssign</span></li> - <li class="node_class"><span class="node_class_concrete">AddAssign</span></li> - <li class="node_class"><span class="node_class_concrete">SubtractAssign</span></li> - <li class="node_class"><span class="node_class_concrete">ShiftLeftAssign</span></li> - <li class="node_class"><span class="node_class_concrete">ShiftRightAssign</span></li> - <li class="node_class"><span class="node_class_concrete">BitAndAssign</span></li> - <li class="node_class"><span class="node_class_concrete">BitXorAssign</span></li> - <li class="node_class"><span class="node_class_concrete">BitOrAssign</span></li> - </ul></li> - <li class="node_class"><span class="node_class_abstract">Literal</span><ul> - <li class="node_class"><span class="node_class_concrete">StringLiteral</span></li> - <li class="node_class"><span class="node_class_concrete">CharLiteral</span></li> - <li class="node_class"><span class="node_class_concrete">CompoundLiteral</span></li> - <li class="node_class"><span class="node_class_concrete">IntLiteral</span></li> - <li class="node_class"><span class="node_class_concrete">FloatLiteral</span></li> - </ul></li> - </ul></li> - <li class="node_class"><span class="node_class_abstract">NodeList</span><ul> - <li class="node_class"><span class="node_class_concrete">NodeArray</span></li> - <li class="node_class"><span class="node_class_concrete">NodeChain</span></li> - </ul></li> - </ul></li> - </ul> - <div class="spacer"></div> -</div> +* **Node** + * TranslationUnit + * Comment + * Declaration + * Declarator + * FunctionDef + * Parameter + * Enumerator + * MemberInit + * Member + * **Statement** + * Block + * If + * Switch + * While + * For + * Goto + * Continue + * Break + * Return + * ExpressionStatement + * **Label** + * PlainLabel + * Default + * Case + * **Type** + * **IndirectType** + * Pointer + * Array + * Function + * **DirectType** + * Struct + * Union + * Enum + * CustomType + * **PrimitiveType** + * Void + * Int + * Float + * Char + * Bool + * Complex + * Imaginary + * **Expression** + * Comma + * Conditional + * Variable + * **UnaryExpression** + * **PostfixExpression** + * Index + * Call + * Dot + * Arrow + * PostInc + * PostDec + * **PrefixExpression** + * Cast + * Address + * Dereference + * Sizeof + * Plus + * Minus + * PreInc + * PreDec + * BitNot + * Not + * **BinaryExpression** + * Add + * Subtract + * Multiply + * Divide + * Mod + * Equal + * NotEqual + * Less + * More + * LessOrEqual + * MoreOrEqual + * BitAnd + * BitOr + * BitXor + * ShiftLeft + * ShiftRight + * And + * Or + * **AssignmentExpression** + * Assign + * MultiplyAssign + * DivideAssign + * ModAssign + * AddAssign + * SubtractAssign + * ShiftLeftAssign + * ShiftRightAssign + * BitAndAssign + * BitXorAssign + * BitOrAssign + * **Literal** + * StringLiteral + * CharLiteral + * CompoundLiteral + * IntLiteral + * FloatLiteral + * **NodeList** + * NodeArray + * NodeChain -The <span class="node_class_abstract">highlighted</span> ones are abstract. +The **bold** ones are abstract. The last 2 (`NodeList`s) represent lists of `Node`s. They quack like standard ruby `Arrays`. `NodeChain` is a doubly linked list; `NodeArray` is an array. @@ -289,11 +245,11 @@ } table.node_desc tr.first_field table td { border: none; } - + table.node_desc td { padding: 3px; vertical-align: top; { @@ -361,11 +317,11 @@ What's a "declarator?" Consider "<tt>int i, *ip;</tt>". This is a <tt>Declaration</tt> with two <tt>Declarator</tt>s: <pre> Declaration type: Int - declarators: + declarators: - Declarator name: "i" - Declarator indirect_type: Pointer name: "ip" @@ -1370,22 +1326,22 @@ <pre>(struct S){1, .x = 2, .y [3] .z = 4}</pre> <p>parses as:</p> <pre>CompoundLiteral type: Struct name: "S" - member_inits: + member_inits: - MemberInit init: IntLiteral val: 1 - MemberInit - member: + member: - Member name: "x" init: IntLiteral val: 2 - MemberInit - member: + member: - Member name: "y" - IntLiteral val: 3 - Member @@ -1399,35 +1355,55 @@ <td class="nd_values"><tt>NodeList</tt> of <tt>MemberInit</tt></td> <td class="nd_default"><tt>NodeArray[]</tt></td> </tr> <tr class="first_field"> - <td class="nd_class" rowspan="2"><tt>IntLiteral</tt></td> - <td class="nd_field"><tt>val</tt></td> - <td class="nd_values"><tt>Integer</tt></td> - <td class="nd_default"></td> - <td class="nd_comments" rowspan="2"> + <td class="nd_class" rowspan="3"><tt>IntLiteral</tt></td> + <td class="nd_field"><tt>format</tt></td> + <td class="nd_values"><tt>:dec</tt>, <tt>:hex</tt>, <tt>:oct</tt></td> + <td class="nd_default"><tt>:dec</tt></td> + <td class="nd_comments" rowspan="3"> <p>Also:</p> <ul> <li><tt>#dec?</tt> -- return true iff <tt>format == :dec</tt></li> <li><tt>#hex?</tt> -- return true iff <tt>format == :hex</tt></li> <li><tt>#oct?</tt> -- return true iff <tt>format == :oct</tt></li> </ul> </td> </tr> <tr> - <td class="nd_field"><tt>format</tt></td> - <td class="nd_values"><tt>:dec</tt>, <tt>:hex</tt>, <tt>:oct</tt></td> - <td class="nd_default"><tt>:dec</tt></td> + <td class="nd_field"><tt>val</tt></td> + <td class="nd_values"><tt>Integer</tt></td> + <td class="nd_default"></td> </tr> + <tr> + <td class="nd_field"><tt>suffix</tt></td> + <td class="nd_values"><tt>String</tt></td> + <td class="nd_default"></td> + </tr> <tr class="first_field"> - <td class="nd_class" rowspan="1"><tt>FloatLiteral</tt></td> + <td class="nd_class" rowspan="4"><tt>FloatLiteral</tt></td> + <td class="nd_field"><tt>format</tt></td> + <td class="nd_values"><tt>:dec</tt>, <tt>:hex</tt></td> + <td class="nd_default"><tt>:dec</tt></td> + <td class="nd_comments" rowspan="4"> + </td> + </tr> + <tr> <td class="nd_field"><tt>val</tt></td> <td class="nd_values"><tt>Float</tt></td> <td class="nd_default"></td> - <td class="nd_comments" rowspan="1"> - </td> + </tr> + <tr> + <td class="nd_field"><tt>exponent</tt></td> + <td class="nd_values"><tt>Integer</tt></td> + <td class="nd_default"></td> + </tr> + <tr> + <td class="nd_field"><tt>suffix</tt></td> + <td class="nd_values"><tt>String</tt></td> + <td class="nd_default"></td> </tr> <tr class="first_field"> <td class="nd_class" rowspan="4"><tt>Pointer</tt></td> <td class="nd_field"><tt>const?</tt></td>