Class: BELParser::Parsers::Common::Function::Parser
- Inherits:
-
Object
- Object
- BELParser::Parsers::Common::Function::Parser
- Defined in:
- lib/bel_parser/parsers/common/function.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(content) ⇒ Parser
constructor
A new instance of Parser.
Methods included from Tracer
Methods included from AST::Sexp
#annotation_definition, #argument, #blank_line, build, #comment, #comment_line, #document_property, #domain, #function, #identifier, #keyword, #list, #list_item, #multi_identifier, #name, #namespace_definition, #nested_statement, #object, #observed_term, #parameter, #pattern, #prefix, #relationship, #set, #simple_statement, #statement, #string, #subject, #term, #unset, #uri, #url, #value
Methods included from Buffer
Constructor Details
#initialize(content) ⇒ Parser
Returns a new instance of Parser.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/bel_parser/parsers/common/function.rb', line 40 def initialize(content) @content = content # begin: ragel class << self attr_accessor :_bel_trans_keys private :_bel_trans_keys, :_bel_trans_keys= end self._bel_trans_keys = [ 0, 0, 33, 126, 10, 126, 0, 0, 0 ] class << self attr_accessor :_bel_key_spans private :_bel_key_spans, :_bel_key_spans= end self._bel_key_spans = [ 0, 94, 117, 0 ] class << self attr_accessor :_bel_index_offsets private :_bel_index_offsets, :_bel_index_offsets= end self._bel_index_offsets = [ 0, 0, 95, 213 ] class << self attr_accessor :_bel_indicies private :_bel_indicies, :_bel_indicies= end self._bel_indicies = [ 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 3, 3, 3, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 4, 0 ] class << self attr_accessor :_bel_trans_targs private :_bel_trans_targs, :_bel_trans_targs= end self._bel_trans_targs = [ 0, 2, 3, 2, 0 ] class << self attr_accessor :_bel_trans_actions private :_bel_trans_actions, :_bel_trans_actions= end self._bel_trans_actions = [ 1, 2, 4, 0, 0 ] class << self attr_accessor :_bel_eof_actions private :_bel_eof_actions, :_bel_eof_actions= end self._bel_eof_actions = [ 0, 1, 3, 5 ] class << self attr_accessor :bel_start end self.bel_start = 1; class << self attr_accessor :bel_first_final end self.bel_first_final = 2; class << self attr_accessor :bel_error end self.bel_error = 0; class << self attr_accessor :bel_en_function_node end self.bel_en_function_node = 1; # end: ragel end |
Instance Method Details
#each ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/bel_parser/parsers/common/function.rb', line 149 def each @buffers = {} @incomplete = {} data = @content.unpack('C*') p = 0 p_start = 0 p_end = 0 pe = data.length eof = data.length @function_started = false # begin: ragel begin p ||= 0 pe ||= data.length cs = bel_start end begin testEof = false _slen, _trans, _keys, _inds, _acts, _nacts = nil _goto_level = 0 _resume = 10 _eof_trans = 15 _again = 20 _test_eof = 30 _out = 40 while true if _goto_level <= 0 if p == pe _goto_level = _test_eof next end if cs == 0 _goto_level = _out next end end if _goto_level <= _resume _keys = cs << 1 _inds = _bel_index_offsets[cs] _slen = _bel_key_spans[cs] _wide = data[p].ord _trans = if ( _slen > 0 && _bel_trans_keys[_keys] <= _wide && _wide <= _bel_trans_keys[_keys + 1] ) then _bel_indicies[ _inds + _wide - _bel_trans_keys[_keys] ] else _bel_indicies[ _inds + _slen ] end cs = _bel_trans_targs[_trans] if _bel_trans_actions[_trans] != 0 case _bel_trans_actions[_trans] when 2 then begin trace('FUNCTION start_function') @function_started = true p_start = p; end when 4 then begin trace('FUNCTION end_function') p_end = p chars = data[p_start...p_end] completed = !chars.empty? ident_node = identifier(utf8_string(chars), complete: completed, character_range: [p_start, p_end]) fx_node = function(ident_node, complete: ident_node.complete, character_range: ident_node.character_range) @buffers[:function] = fx_node end when 1 then begin trace('FUNCTION function_node_err') if @function_started # hit invalid char, include it in the identifier that results p_end = p + 1 chars = data[p_start...p_end] completed = !chars.empty? ident_node = identifier(utf8_string(chars), complete: completed, character_range: [p_start, p_end]) fx_node = function(ident_node, complete: false, character_range: ident_node.character_range) @buffers[:function] = fx_node yield @buffers[:function] end end end end end if _goto_level <= _again if cs == 0 _goto_level = _out next end p += 1 if p != pe _goto_level = _resume next end end if _goto_level <= _test_eof if p == eof case _bel_eof_actions[cs] when 1 then begin trace('FUNCTION function_node_err') if @function_started # hit invalid char, include it in the identifier that results p_end = p + 1 chars = data[p_start...p_end] completed = !chars.empty? ident_node = identifier(utf8_string(chars), complete: completed, character_range: [p_start, p_end]) fx_node = function(ident_node, complete: false, character_range: ident_node.character_range) @buffers[:function] = fx_node yield @buffers[:function] end end when 5 then begin trace('FUNCTION yield_function') yield @buffers[:function] end when 3 then begin trace('FUNCTION end_function') p_end = p chars = data[p_start...p_end] completed = !chars.empty? ident_node = identifier(utf8_string(chars), complete: completed, character_range: [p_start, p_end]) fx_node = function(ident_node, complete: ident_node.complete, character_range: ident_node.character_range) @buffers[:function] = fx_node end begin trace('FUNCTION yield_function') yield @buffers[:function] end end end end if _goto_level <= _out break end end end # end: ragel end |