Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 15
- Log:
Attempt to update Typo to a Typo SVN HEAD release from around the
time the prototype installation was set up on the RISC OS Open Limited
web site. Timestamps place this at 04-Jul so a revision from 05-Jul or
earlier was pulled and copied over the 2.6.0 tarball stable code.
- Author:
- adh
- Date:
- Sat Jul 22 23:27:35 +0100 2006
- Size:
- 27996 Bytes
1 | <?xml version="1.0" encoding="iso-8859-1"?> |
2 | <!DOCTYPE html |
3 | PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
4 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
5 | <html> |
6 | <head> |
7 | <title>Class: Syntax::Ruby</title> |
8 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> |
9 | <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" /> |
10 | |
11 | <script language="JavaScript" type="text/javascript"> |
12 | // <![CDATA[ |
13 | |
14 | function toggleSource( id ) |
15 | { |
16 | var elem |
17 | var link |
18 | |
19 | if( document.getElementById ) |
20 | { |
21 | elem = document.getElementById( id ) |
22 | link = document.getElementById( "l_" + id ) |
23 | } |
24 | else if ( document.all ) |
25 | { |
26 | elem = eval( "document.all." + id ) |
27 | link = eval( "document.all.l_" + id ) |
28 | } |
29 | else |
30 | return false; |
31 | |
32 | if( elem.style.display == "block" ) |
33 | { |
34 | elem.style.display = "none" |
35 | link.innerHTML = "show source" |
36 | } |
37 | else |
38 | { |
39 | elem.style.display = "block" |
40 | link.innerHTML = "hide source" |
41 | } |
42 | } |
43 | |
44 | function openCode( url ) |
45 | { |
46 | window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" ) |
47 | } |
48 | // ]]> |
49 | </script> |
50 | </head> |
51 | |
52 | <body> |
53 | <table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr> |
54 | <td class="file-title"><span class="file-title-prefix">Class</span><br />Syntax::Ruby</td> |
55 | <td align="right"> |
56 | <table cellspacing=0 cellpadding=2> |
57 | <tr valign="top"> |
58 | <td>In:</td> |
59 | <td> |
60 | <a href="../../files/lib/syntax/lang/ruby_rb.html">lib/syntax/lang/ruby.rb</a> |
61 | </td> |
62 | </tr> |
63 | <tr> |
64 | <td>Parent:</td> |
65 | <td> |
66 | <a href="Tokenizer.html"> |
67 | Tokenizer |
68 | </a> |
69 | </td> |
70 | </tr> |
71 | </table> |
72 | </td> |
73 | </tr> |
74 | </table> |
75 | <!-- banner header --> |
76 | |
77 | <div id="bodyContent"> |
78 | <div id="content"> |
79 | |
80 | <div class="description"><p> |
81 | A tokenizer for the <a href="Ruby.html">Ruby</a> language. It recognizes |
82 | all common syntax (and some less common syntax) but because it is not a |
83 | true lexer, it will make mistakes on some ambiguous cases. |
84 | </p> |
85 | </div> |
86 | |
87 | |
88 | |
89 | <div class="sectiontitle">Methods</div> |
90 | <ul> |
91 | <li><a href="#M000008">setup</a></li> |
92 | <li><a href="#M000009">step</a></li> |
93 | </ul> |
94 | |
95 | |
96 | |
97 | |
98 | <div class="sectiontitle">Constants</div> |
99 | <table border='0' cellpadding='5'> |
100 | <tr valign='top'> |
101 | <td class="attr-name">KEYWORDS</td> |
102 | <td>=</td> |
103 | <td class="attr-value">%w{if then elsif else end begin do rescue ensure while for class module def yield raise until unless and or not when case super undef break next redo retry in return alias defined?}</td> |
104 | </tr> |
105 | <tr valign='top'> |
106 | <td> </td> |
107 | <td colspan="2" class="attr-desc"> |
108 | The list of all identifiers recognized as keywords. |
109 | |
110 | </td> |
111 | </tr> |
112 | </table> |
113 | |
114 | |
115 | <div class="sectiontitle">Public Instance methods</div> |
116 | <div class="method"> |
117 | <div class="title"> |
118 | <a name="M000008"></a><b>setup</b>() |
119 | </div> |
120 | <div class="description"> |
121 | <p> |
122 | Perform ruby-specific setup |
123 | </p> |
124 | </div> |
125 | <div class="sourcecode"> |
126 | <p class="source-link">[ <a href="javascript:toggleSource('M000008_source')" id="l_M000008_source">show source</a> ]</p> |
127 | <div id="M000008_source" class="dyn-source"> |
128 | <pre> |
129 | <span class="ruby-comment cmt"># File lib/syntax/lang/ruby.rb, line 18</span> |
130 | 18: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setup</span> |
131 | 19: <span class="ruby-ivar">@selector</span> = <span class="ruby-keyword kw">false</span> |
132 | 20: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">false</span> |
133 | 21: <span class="ruby-ivar">@heredocs</span> = [] |
134 | 22: <span class="ruby-keyword kw">end</span> |
135 | </pre> |
136 | </div> |
137 | </div> |
138 | </div> |
139 | <div class="method"> |
140 | <div class="title"> |
141 | <a name="M000009"></a><b>step</b>() |
142 | </div> |
143 | <div class="description"> |
144 | <p> |
145 | Step through a single iteration of the tokenization process. |
146 | </p> |
147 | </div> |
148 | <div class="sourcecode"> |
149 | <p class="source-link">[ <a href="javascript:toggleSource('M000009_source')" id="l_M000009_source">show source</a> ]</p> |
150 | <div id="M000009_source" class="dyn-source"> |
151 | <pre> |
152 | <span class="ruby-comment cmt"># File lib/syntax/lang/ruby.rb, line 25</span> |
153 | 25: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">step</span> |
154 | 26: <span class="ruby-keyword kw">case</span> |
155 | 27: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">bol?</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">check</span>( <span class="ruby-regexp re">/=begin/</span> ) |
156 | 28: <span class="ruby-identifier">start_group</span>( <span class="ruby-identifier">:comment</span>, <span class="ruby-identifier">scan_until</span>( <span class="ruby-node">/^=end#{EOL}/</span> ) ) |
157 | 29: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">bol?</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">check</span>( <span class="ruby-node">/__END__#{EOL}/</span> ) |
158 | 30: <span class="ruby-identifier">start_group</span>( <span class="ruby-identifier">:comment</span>, <span class="ruby-identifier">scan_until</span>( <span class="ruby-regexp re">/\Z/</span> ) ) |
159 | 31: <span class="ruby-keyword kw">else</span> |
160 | 32: <span class="ruby-keyword kw">case</span> |
161 | 33: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">check</span>( <span class="ruby-regexp re">/def\s+/</span> ) |
162 | 34: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:keyword</span>, <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/def\s+/</span> ) |
163 | 35: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:method</span>, <span class="ruby-identifier">scan_until</span>( <span class="ruby-node">/(?=[;(\s]|#{EOL})/</span> ) |
164 | 36: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">check</span>( <span class="ruby-regexp re">/class\s+/</span> ) |
165 | 37: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:keyword</span>, <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/class\s+/</span> ) |
166 | 38: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:class</span>, <span class="ruby-identifier">scan_until</span>( <span class="ruby-node">/(?=[;\s<]|#{EOL})/</span> ) |
167 | 39: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">check</span>( <span class="ruby-regexp re">/module\s+/</span> ) |
168 | 40: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:keyword</span>, <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/module\s+/</span> ) |
169 | 41: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:module</span>, <span class="ruby-identifier">scan_until</span>( <span class="ruby-node">/(?=[;\s]|#{EOL})/</span> ) |
170 | 42: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">check</span>( <span class="ruby-regexp re">/::/</span> ) |
171 | 43: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:punct</span>, <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/::/</span>) |
172 | 44: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">check</span>( <span class="ruby-regexp re">/:"/</span> ) |
173 | 45: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:symbol</span>, <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/:/</span>) |
174 | 46: <span class="ruby-identifier">scan_delimited_region</span> <span class="ruby-identifier">:symbol</span>, <span class="ruby-identifier">:symbol</span>, <span class="ruby-value str">""</span>, <span class="ruby-keyword kw">true</span> |
175 | 47: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
176 | 48: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">check</span>( <span class="ruby-regexp re">/:'/</span> ) |
177 | 49: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:symbol</span>, <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/:/</span>) |
178 | 50: <span class="ruby-identifier">scan_delimited_region</span> <span class="ruby-identifier">:symbol</span>, <span class="ruby-identifier">:symbol</span>, <span class="ruby-value str">""</span>, <span class="ruby-keyword kw">false</span> |
179 | 51: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
180 | 52: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/:[_a-zA-Z@$][$@\w]*[=!?]?/</span> ) |
181 | 53: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:symbol</span>, <span class="ruby-identifier">matched</span> |
182 | 54: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
183 | 55: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/\?(\\[^\n\r]|[^\\\n\r\s])/</span> ) |
184 | 56: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:char</span>, <span class="ruby-identifier">matched</span> |
185 | 57: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
186 | 58: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">check</span>( <span class="ruby-regexp re">/(__FILE__|__LINE__|true|false|nil|self)[?!]?/</span> ) |
187 | 59: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@selector</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">matched</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">??</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">matched</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?!</span> |
188 | 60: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:ident</span>, |
189 | 61: <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/(__FILE__|__LINE__|true|false|nil|self)[?!]?/</span>) |
190 | 62: <span class="ruby-keyword kw">else</span> |
191 | 63: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:constant</span>, |
192 | 64: <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/(__FILE__|__LINE__|true|false|nil|self)/</span>) |
193 | 65: <span class="ruby-keyword kw">end</span> |
194 | 66: <span class="ruby-ivar">@selector</span> = <span class="ruby-keyword kw">false</span> |
195 | 67: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
196 | 68: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/0([bB][01]+|[oO][0-7]+|[dD][0-9]+|[xX][0-9a-fA-F]+)/</span>) |
197 | 69: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:number</span>, <span class="ruby-identifier">matched</span> |
198 | 70: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
199 | 71: <span class="ruby-keyword kw">else</span> |
200 | 72: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">peek</span>(<span class="ruby-value">2</span>) |
201 | 73: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"%r"</span> |
202 | 74: <span class="ruby-identifier">scan_delimited_region</span> <span class="ruby-identifier">:punct</span>, <span class="ruby-identifier">:regex</span>, <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/../</span> ), <span class="ruby-keyword kw">true</span> |
203 | 75: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
204 | 76: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"%w"</span>, <span class="ruby-value str">"%q"</span> |
205 | 77: <span class="ruby-identifier">scan_delimited_region</span> <span class="ruby-identifier">:punct</span>, <span class="ruby-identifier">:string</span>, <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/../</span> ), <span class="ruby-keyword kw">false</span> |
206 | 78: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
207 | 79: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"%s"</span> |
208 | 80: <span class="ruby-identifier">scan_delimited_region</span> <span class="ruby-identifier">:punct</span>, <span class="ruby-identifier">:symbol</span>, <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/../</span> ), <span class="ruby-keyword kw">false</span> |
209 | 81: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
210 | 82: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"%W"</span>, <span class="ruby-value str">"%Q"</span>, <span class="ruby-value str">"%x"</span> |
211 | 83: <span class="ruby-identifier">scan_delimited_region</span> <span class="ruby-identifier">:punct</span>, <span class="ruby-identifier">:string</span>, <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/../</span> ), <span class="ruby-keyword kw">true</span> |
212 | 84: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
213 | 85: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/%[^\sa-zA-Z0-9]/</span> |
214 | 86: <span class="ruby-identifier">scan_delimited_region</span> <span class="ruby-identifier">:punct</span>, <span class="ruby-identifier">:string</span>, <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/./</span> ), <span class="ruby-keyword kw">true</span> |
215 | 87: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
216 | 88: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"<<"</span> |
217 | 89: <span class="ruby-identifier">saw_word</span> = ( <span class="ruby-identifier">chunk</span>[<span class="ruby-value">-1</span>,<span class="ruby-value">1</span>] <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/[\w!?]/</span> ) |
218 | 90: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:punct</span>, <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/<</</span> ) |
219 | 91: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">saw_word</span> |
220 | 92: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">false</span> |
221 | 93: <span class="ruby-keyword kw">return</span> |
222 | 94: <span class="ruby-keyword kw">end</span> |
223 | 95: |
224 | 96: <span class="ruby-identifier">float_right</span> = <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/-/</span> ) |
225 | 97: <span class="ruby-identifier">append</span> <span class="ruby-value str">"-"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">float_right</span> |
226 | 98: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">type</span> = <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/['"]/</span> ) ) |
227 | 99: <span class="ruby-identifier">append</span> <span class="ruby-identifier">type</span> |
228 | 100: <span class="ruby-identifier">delim</span> = <span class="ruby-identifier">scan_until</span>( <span class="ruby-node">/(?=#{type})/</span> ) |
229 | 101: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">delim</span>.<span class="ruby-identifier">nil?</span> |
230 | 102: <span class="ruby-identifier">append</span> <span class="ruby-identifier">scan_until</span>( <span class="ruby-regexp re">/\Z/</span> ) |
231 | 103: <span class="ruby-keyword kw">return</span> |
232 | 104: <span class="ruby-keyword kw">end</span> |
233 | 105: <span class="ruby-keyword kw">else</span> |
234 | 106: <span class="ruby-identifier">delim</span> = <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/\w+/</span> ) <span class="ruby-keyword kw">or</span> <span class="ruby-keyword kw">return</span> |
235 | 107: <span class="ruby-keyword kw">end</span> |
236 | 108: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:constant</span>, <span class="ruby-identifier">delim</span> |
237 | 109: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:punct</span>, <span class="ruby-identifier">scan</span>( <span class="ruby-node">/#{type}/</span> ) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">type</span> |
238 | 110: <span class="ruby-ivar">@heredocs</span> <span class="ruby-operator"><<</span> [ <span class="ruby-identifier">float_right</span>, <span class="ruby-identifier">type</span>, <span class="ruby-identifier">delim</span> ] |
239 | 111: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
240 | 112: <span class="ruby-keyword kw">else</span> |
241 | 113: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">peek</span>(<span class="ruby-value">1</span>) |
242 | 114: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/[\n\r]/</span> |
243 | 115: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@heredocs</span>.<span class="ruby-identifier">empty?</span> |
244 | 116: <span class="ruby-identifier">scan_heredoc</span>(<span class="ruby-operator">*</span><span class="ruby-ivar">@heredocs</span>.<span class="ruby-identifier">shift</span>) |
245 | 117: <span class="ruby-keyword kw">else</span> |
246 | 118: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:normal</span>, <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/\s+/</span> ) |
247 | 119: <span class="ruby-keyword kw">end</span> |
248 | 120: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">false</span> |
249 | 121: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/\s/</span> |
250 | 122: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:normal</span>, <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/\s+/</span> ) |
251 | 123: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"#"</span> |
252 | 124: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:comment</span>, <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/#[^\n\r]*/</span> ) |
253 | 125: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/[A-Z]/</span> |
254 | 126: <span class="ruby-identifier">start_group</span> <span class="ruby-ivar">@selector</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">:ident</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">:constant</span>, <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/\w+/</span> ) |
255 | 127: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
256 | 128: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/[a-z_]/</span> |
257 | 129: <span class="ruby-identifier">word</span> = <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/\w+[?!]?/</span> ) |
258 | 130: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@selector</span> <span class="ruby-operator">&&</span> <span class="ruby-constant">KEYWORDS</span>.<span class="ruby-identifier">include?</span>( <span class="ruby-identifier">word</span> ) |
259 | 131: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:keyword</span>, <span class="ruby-identifier">word</span> |
260 | 132: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">false</span> |
261 | 133: <span class="ruby-keyword kw">elsif</span> |
262 | 134: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:ident</span>, <span class="ruby-identifier">word</span> |
263 | 135: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
264 | 136: <span class="ruby-keyword kw">end</span> |
265 | 137: <span class="ruby-ivar">@selector</span> = <span class="ruby-keyword kw">false</span> |
266 | 138: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/\d/</span> |
267 | 139: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:number</span>, |
268 | 140: <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/[\d_]+(\.[\d_]+)?([eE][\d_]+)?/</span> ) |
269 | 141: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
270 | 142: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'"'</span> |
271 | 143: <span class="ruby-identifier">scan_delimited_region</span> <span class="ruby-identifier">:punct</span>, <span class="ruby-identifier">:string</span>, <span class="ruby-value str">""</span>, <span class="ruby-keyword kw">true</span> |
272 | 144: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
273 | 145: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'/'</span> |
274 | 146: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@allow_operator</span> |
275 | 147: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:punct</span>, <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">%r{/}</span>) |
276 | 148: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">false</span> |
277 | 149: <span class="ruby-keyword kw">else</span> |
278 | 150: <span class="ruby-identifier">scan_delimited_region</span> <span class="ruby-identifier">:punct</span>, <span class="ruby-identifier">:regex</span>, <span class="ruby-value str">""</span>, <span class="ruby-keyword kw">true</span> |
279 | 151: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
280 | 152: <span class="ruby-keyword kw">end</span> |
281 | 153: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"'"</span> |
282 | 154: <span class="ruby-identifier">scan_delimited_region</span> <span class="ruby-identifier">:punct</span>, <span class="ruby-identifier">:string</span>, <span class="ruby-value str">""</span>, <span class="ruby-keyword kw">false</span> |
283 | 155: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
284 | 156: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"."</span> |
285 | 157: <span class="ruby-identifier">dots</span> = <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/\.{1,3}/</span> ) |
286 | 158: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:punct</span>, <span class="ruby-identifier">dots</span> |
287 | 159: <span class="ruby-ivar">@selector</span> = ( <span class="ruby-identifier">dots</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> ) |
288 | 160: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/[@]/</span> |
289 | 161: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:attribute</span>, <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/@{1,2}\w*/</span> ) |
290 | 162: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
291 | 163: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/[$]/</span> |
292 | 164: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:global</span>, <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/\$/</span>) |
293 | 165: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:global</span>, <span class="ruby-identifier">scan</span>( <span class="ruby-regexp re">/\w+|./</span> ) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">check</span>(<span class="ruby-regexp re">/./</span>) |
294 | 166: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
295 | 167: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/[-!?*\/+=<>(\[\{}:;,&|%]/</span> |
296 | 168: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:punct</span>, <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/./</span>) |
297 | 169: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">false</span> |
298 | 170: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/[)\]]/</span> |
299 | 171: <span class="ruby-identifier">start_group</span> <span class="ruby-identifier">:punct</span>, <span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/./</span>) |
300 | 172: <span class="ruby-ivar">@allow_operator</span> = <span class="ruby-keyword kw">true</span> |
301 | 173: <span class="ruby-keyword kw">else</span> |
302 | 174: <span class="ruby-comment cmt"># all else just falls through this, to prevent</span> |
303 | 175: <span class="ruby-comment cmt"># infinite loops...</span> |
304 | 176: <span class="ruby-identifier">append</span> <span class="ruby-identifier">getch</span> |
305 | 177: <span class="ruby-keyword kw">end</span> |
306 | 178: <span class="ruby-keyword kw">end</span> |
307 | 179: <span class="ruby-keyword kw">end</span> |
308 | 180: <span class="ruby-keyword kw">end</span> |
309 | 181: <span class="ruby-keyword kw">end</span> |
310 | </pre> |
311 | </div> |
312 | </div> |
313 | </div> |
314 | </div> |
315 | |
316 | </div> |
317 | |
318 | </body> |
319 | </html> |