doc/classes/SDL4R/Parser.html in sdl4r-0.9.6 vs doc/classes/SDL4R/Parser.html in sdl4r-0.9.7

- old
+ new

@@ -1,314 +1,190 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - <title>Class: SDL4R::Parser</title> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <meta http-equiv="Content-Script-Type" content="text/javascript" /> - <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" /> - <script type="text/javascript"> - // <![CDATA[ - - function popupCode( url ) { - window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") - } - - function toggleCode( id ) { - if ( document.getElementById ) - elem = document.getElementById( id ); - else if ( document.all ) - elem = eval( "document.all." + id ); - else - return false; - - elemStyle = elem.style; - - if ( elemStyle.display != "block" ) { - elemStyle.display = "block" - } else { - elemStyle.display = "none" - } - - return true; - } - - // Make codeblocks hidden by default - document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" ) - - // ]]> - </script> - -</head> -<body> - - - - <div id="classHeader"> - <table class="header-table"> - <tr class="top-aligned-row"> - <td><strong>Class</strong></td> - <td class="class-name-in-header">SDL4R::Parser</td> - </tr> - <tr class="top-aligned-row"> - <td><strong>In:</strong></td> - <td> - <a href="../../files/lib/sdl4r/parser_rb.html"> - lib/sdl4r/parser.rb - </a> - <br /> - <a href="../../files/lib/sdl4r/parser/reader_rb.html"> - lib/sdl4r/parser/reader.rb - </a> - <br /> - <a href="../../files/lib/sdl4r/parser/tokenizer_rb.html"> - lib/sdl4r/parser/tokenizer.rb - </a> - <br /> - <a href="../../files/lib/sdl4r/parser/token_rb.html"> - lib/sdl4r/parser/token.rb - </a> - <br /> - <a href="../../files/lib/sdl4r/parser/time_span_with_zone_rb.html"> - lib/sdl4r/parser/time_span_with_zone.rb - </a> - <br /> - </td> - </tr> - - <tr class="top-aligned-row"> - <td><strong>Parent:</strong></td> - <td> - Object - </td> - </tr> - </table> - </div> - <!-- banner header --> - - <div id="bodyContent"> - - - - <div id="contextContent"> - - <div id="description"> - <p> -The SDL parser. -</p> -<p> -In Ruby 1.8, in order to enable UTF-8 support, you may have to declare the -following lines: -</p> -<pre> - $KCODE = 'u' - require 'jcode' -</pre> -<p> -This will give you correct input and output and correct UTF-8 -&quot;general&quot; sorting. Alternatively you can use the following -options when launching the Ruby interpreter: -</p> -<pre> - /path/to/ruby -Ku -rjcode -</pre> -<h2>Authors</h2> -<p> -Daniel Leuck, Philippe Vosges -</p> - - </div> - - - </div> - - <div id="method-list"> - <h3 class="section-bar">Methods</h3> - - <div class="name-list"> - <a href="#M000010">new</a>&nbsp;&nbsp; - <a href="#M000012">new_date_time</a>&nbsp;&nbsp; - <a href="#M000011">parse</a>&nbsp;&nbsp; - </div> - </div> - - </div> - - - <!-- if includes --> - - <div id="section"> - - - <div id="constants-list"> - <h3 class="section-bar">Constants</h3> - - <div class="name-list"> - <table summary="Constants"> - <tr class="top-aligned-row context-row"> - <td class="context-item-name">UNKNOWN_POSITION</td> - <td>=</td> - <td class="context-item-value">-2</td> - <td width="3em">&nbsp;</td> - <td class="context-item-desc"> -Passed to parse_error() in order to specify an error that occured on no -specific position (column). - -</td> - </tr> - </table> - </div> - </div> - - - - - - - <!-- if method_list --> - <div id="methods"> - <h3 class="section-bar">Public Class methods</h3> - - <div id="method-M000010" class="method-detail"> - <a name="M000010"></a> - - <div class="method-heading"> - <a href="#M000010" class="method-signature"> - <span class="method-name">new</span><span class="method-args">(io)</span> - </a> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html lang='en'> + <head> + <title>: SDL4R::Parser [RDoc: Simple Declarative Language for Ruby]</title> + <meta content='text/html; charset=utf-8' http-equiv='Content-Type'> + <link href='../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'> + <script type='text/javascript'> + //<![CDATA[ + function popupCode(url) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode(id) { + var code = document.getElementById(id) + + code.style.display = code.style.display != 'block' ? 'block' : 'none' + return true + } + + // Make codeblocks hidden by default + document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>') + //]]> + </script> + </head> + <body class='page'> + <div class='class' id='wrapper'> + <div class='header'> + <h1 class='name'> + <span class='type'>Class</span> + SDL4R::Parser + </h1> + <ol class='paths'> + <li> + <a href="../../files/lib/sdl4r/parser_rb.html">lib/sdl4r/parser.rb</a> + </li> + <li class='other'> + <a href="../../files/lib/sdl4r/parser/reader_rb.html">lib/sdl4r/parser/reader.rb</a> + </li> + <li class='other'> + <a href="../../files/lib/sdl4r/parser/tokenizer_rb.html">lib/sdl4r/parser/tokenizer.rb</a> + </li> + <li class='other'> + <a href="../../files/lib/sdl4r/parser/token_rb.html">lib/sdl4r/parser/token.rb</a> + </li> + <li class='other'> + <a href="../../files/lib/sdl4r/parser/time_span_with_zone_rb.html">lib/sdl4r/parser/time_span_with_zone.rb</a> + </li> + <li> + <a class='show' href='#' onclick='this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false'>show all</a> + </li> + </ol> + <div class='parent'> + Parent: + <strong>Object</strong> </div> - - <div class="method-description"> - <p> -Creates an SDL parser on the specified <tt>IO</tt>. -</p> -<pre> - IO.open(&quot;path/to/sdl_file&quot;) { |io| - parser = SDL4R::Parser.new(io) - tags = parser.parse() - } -</pre> - <p><a class="source-toggle" href="#" - onclick="toggleCode('M000010-source');return false;">[Source]</a></p> - <div class="method-source-code" id="M000010-source"> -<pre> -<span class="ruby-comment cmt"># File lib/sdl4r/parser.rb, line 59</span> - <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">io</span>) - <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">&quot;io == nil&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">io</span>.<span class="ruby-identifier">nil?</span> - - <span class="ruby-ivar">@tokenizer</span> = <span class="ruby-constant">Tokenizer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">io</span>) - <span class="ruby-keyword kw">end</span> -</pre> - </div> - </div> </div> - - <h3 class="section-bar">Public Instance methods</h3> - - <div id="method-M000012" class="method-detail"> - <a name="M000012"></a> - - <div class="method-heading"> - <a href="#M000012" class="method-signature"> - <span class="method-name">new_date_time</span><span class="method-args">(year, month, day, hour, min, sec, time_zone_offset)</span> - </a> - </div> - - <div class="method-description"> - <p> -Creates and returns the object representing a datetime (DateTime in the -default implementation). Can be overriden. -</p> -<pre> - def new_date_time(year, month, day, hour, min, sec, time_zone_offset) - Time.utc(year, month, day, hour, min, sec) - end -</pre> - <p><a class="source-toggle" href="#" - onclick="toggleCode('M000012-source');return false;">[Source]</a></p> - <div class="method-source-code" id="M000012-source"> -<pre> -<span class="ruby-comment cmt"># File lib/sdl4r/parser.rb, line 105</span> - <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">new_date_time</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>, <span class="ruby-identifier">time_zone_offset</span>) - <span class="ruby-constant">SDL4R</span><span class="ruby-operator">::</span><span class="ruby-identifier">new_date_time</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>, <span class="ruby-identifier">time_zone_offset</span>) - <span class="ruby-keyword kw">end</span> -</pre> + <div id='content'> + <div id='text'> + <div id='description'> + <p> + The SDL parser. + </p> + <p> + In Ruby 1.8, in order to enable UTF-8 support, you may have to declare the + following lines: + </p> + <pre>$KCODE = 'u'&#x000A;require 'jcode'</pre> + <p> + This will give you correct input and output and correct UTF-8 + &#8220;general&#8221; sorting. Alternatively you can use the following + options when launching the Ruby interpreter: + </p> + <pre>/path/to/ruby -Ku -rjcode</pre> + <h2>Authors</h2> + <p> + Daniel Leuck, Philippe Vosges + </p> </div> - </div> - </div> - - <div id="method-M000011" class="method-detail"> - <a name="M000011"></a> - - <div class="method-heading"> - <a href="#M000011" class="method-signature"> - <span class="method-name">parse</span><span class="method-args">()</span> - </a> - </div> - - <div class="method-description"> - <p> -Parses the underlying <tt>IO</tt> and returns an <tt>Array</tt> of <tt><a -href="Tag.html">Tag</a></tt>. -</p> -<h2>Errors</h2> -<dl> -<dt>IOError</dt><dd>If a problem is encountered with the IO - -</dd> -<dt><a href="SdlParseError.html">SdlParseError</a></dt><dd>If the document is malformed - -</dd> -</dl> - <p><a class="source-toggle" href="#" - onclick="toggleCode('M000011-source');return false;">[Source]</a></p> - <div class="method-source-code" id="M000011-source"> -<pre> -<span class="ruby-comment cmt"># File lib/sdl4r/parser.rb, line 70</span> - <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse</span> - <span class="ruby-identifier">tags</span> = [] - - <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">tokens</span> = <span class="ruby-ivar">@tokenizer</span>.<span class="ruby-identifier">read_line_tokens</span>() - <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">tokens</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:START_BLOCK</span> - <span class="ruby-comment cmt"># tag with a block</span> - <span class="ruby-identifier">tag</span> = <span class="ruby-identifier">construct_tag</span>(<span class="ruby-identifier">tokens</span>[<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>]) - <span class="ruby-identifier">add_children</span>(<span class="ruby-identifier">tag</span>) - <span class="ruby-identifier">tags</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">tag</span> - - <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">tokens</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:END_BLOCK</span> - <span class="ruby-comment cmt"># we found an block end token that should have been consumed by</span> - <span class="ruby-comment cmt"># add_children() normally</span> - <span class="ruby-identifier">parse_error</span>( - <span class="ruby-value str">&quot;No opening block ({) for close block (}).&quot;</span>, - <span class="ruby-identifier">tokens</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">line</span>, - <span class="ruby-identifier">tokens</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">position</span>) - <span class="ruby-keyword kw">else</span> - <span class="ruby-comment cmt"># tag without block</span> - <span class="ruby-identifier">tags</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">construct_tag</span>(<span class="ruby-identifier">tokens</span>) - <span class="ruby-keyword kw">end</span> - <span class="ruby-keyword kw">end</span> - - <span class="ruby-ivar">@tokenizer</span>.<span class="ruby-identifier">close</span>() - - <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">tags</span> - <span class="ruby-keyword kw">end</span> -</pre> + <div id='method-list'> + <h2>Methods</h2> + <h3>public class</h3> + <ol> + <li><a href="#M000081">new</a></li> + </ol> + <h3>public instance</h3> + <ol> + <li><a href="#M000083">new_date_time</a></li> + <li><a href="#M000082">parse</a></li> + </ol> </div> + <div id='section'> + <div id='constants-list'> + <h2>Constants</h2> + <div class='name-list'> + <table summary='Constants'> + <tr class='top-aligned-row context-row'> + <td class='context-item-name'>UNKNOWN_POSITION</td> + <td>=</td> + <td class='context-item-value'>-2</td> + <td>&nbsp;</td> + <td class='context-item-desc'> + + Passed to parse_error() in order to specify an error that occured on no + specific position (column). + </td> + </tr> + </table> + </div> + </div> + <div id='methods'> + <h2>Public class methods</h2> + <div class='method public-class' id='method-M000081'> + <a name='M000081'></a> + <div class='synopsis'> + <span class='name'>new</span> + <span class='arguments'>(io)</span> + </div> + <div class='description'> + <p> + Creates an SDL parser on the specified <tt>IO</tt>. + </p> + <pre>IO.open(&quot;path/to/sdl_file&quot;) { |io|&#x000A; parser = SDL4R::Parser.new(io)&#x000A; tags = parser.parse()&#x000A;}</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000081-source'); return false"> + [show source] + </a> + <pre id='M000081-source'> <span class="ruby-comment cmt"># File lib/sdl4r/parser.rb, line 59</span>&#x000A;59: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">io</span>)&#x000A;60: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">&quot;io == nil&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">io</span>.<span class="ruby-identifier">nil?</span>&#x000A;61: &#x000A;62: <span class="ruby-ivar">@tokenizer</span> = <span class="ruby-constant">Tokenizer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">io</span>)&#x000A;63: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <h2>Public instance methods</h2> + <div class='method public-instance' id='method-M000083'> + <a name='M000083'></a> + <div class='synopsis'> + <span class='name'>new_date_time</span> + <span class='arguments'>(year, month, day, hour, min, sec, time_zone_offset)</span> + </div> + <div class='description'> + <p> + Creates and returns the object representing a datetime (DateTime in the + default implementation). Can be overriden. + </p> + <pre>def new_date_time(year, month, day, hour, min, sec, time_zone_offset)&#x000A; Time.utc(year, month, day, hour, min, sec)&#x000A;end</pre> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000083-source'); return false"> + [show source] + </a> + <pre id='M000083-source'> <span class="ruby-comment cmt"># File lib/sdl4r/parser.rb, line 105</span>&#x000A;105: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">new_date_time</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>, <span class="ruby-identifier">time_zone_offset</span>)&#x000A;106: <span class="ruby-constant">SDL4R</span><span class="ruby-operator">::</span><span class="ruby-identifier">new_date_time</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>, <span class="ruby-identifier">time_zone_offset</span>)&#x000A;107: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + <div class='method public-instance' id='method-M000082'> + <a name='M000082'></a> + <div class='synopsis'> + <span class='name'>parse</span> + <span class='arguments'>()</span> + </div> + <div class='description'> + <p> + Parses the underlying <tt>IO</tt> and returns an <tt>Array</tt> of + <tt>Tag</tt>. + </p> + <h2>Errors</h2> + <dl> + <dt>IOError</dt><dd>If a problem is encountered with the IO + + </dd> + <dt><a href="SdlParseError.html">SdlParseError</a></dt><dd>If the document is malformed + + </dd> + </dl> + </div> + <div class='source'> + <a class='source-toggle' href='#' onclick="toggleCode('M000082-source'); return false"> + [show source] + </a> + <pre id='M000082-source'> <span class="ruby-comment cmt"># File lib/sdl4r/parser.rb, line 70</span>&#x000A;70: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse</span>&#x000A;71: <span class="ruby-identifier">tags</span> = []&#x000A;72: &#x000A;73: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">tokens</span> = <span class="ruby-ivar">@tokenizer</span>.<span class="ruby-identifier">read_line_tokens</span>()&#x000A;74: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">tokens</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:START_BLOCK</span>&#x000A;75: <span class="ruby-comment cmt"># tag with a block</span>&#x000A;76: <span class="ruby-identifier">tag</span> = <span class="ruby-identifier">construct_tag</span>(<span class="ruby-identifier">tokens</span>[<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>])&#x000A;77: <span class="ruby-identifier">add_children</span>(<span class="ruby-identifier">tag</span>)&#x000A;78: <span class="ruby-identifier">tags</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">tag</span>&#x000A;79: &#x000A;80: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">tokens</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:END_BLOCK</span>&#x000A;81: <span class="ruby-comment cmt"># we found an block end token that should have been consumed by</span>&#x000A;82: <span class="ruby-comment cmt"># add_children() normally</span>&#x000A;83: <span class="ruby-identifier">parse_error</span>(&#x000A;84: <span class="ruby-value str">&quot;No opening block ({) for close block (}).&quot;</span>,&#x000A;85: <span class="ruby-identifier">tokens</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">line</span>,&#x000A;86: <span class="ruby-identifier">tokens</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">position</span>)&#x000A;87: <span class="ruby-keyword kw">else</span>&#x000A;88: <span class="ruby-comment cmt"># tag without block</span>&#x000A;89: <span class="ruby-identifier">tags</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">construct_tag</span>(<span class="ruby-identifier">tokens</span>)&#x000A;90: <span class="ruby-keyword kw">end</span>&#x000A;91: <span class="ruby-keyword kw">end</span>&#x000A;92: &#x000A;93: <span class="ruby-ivar">@tokenizer</span>.<span class="ruby-identifier">close</span>()&#x000A;94: &#x000A;95: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">tags</span>&#x000A;96: <span class="ruby-keyword kw">end</span></pre> + </div> + </div> + </div> + </div> </div> </div> - - + <div id='footer-push'></div> </div> - - - </div> - - -<div id="validator-badges"> - <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> -</div> - -</body> -</html> \ No newline at end of file + <div id='footer'> + <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a> + </div> + </body> +</html>