Class: ParseDef
- Inherits:
-
EndableParseState
- Object
- ParseState
- EndableParseState
- ParseDef
- Defined in:
- lib/metric_fu/saikuro/saikuro.rb
Instance Attribute Summary
Attributes inherited from ParseState
#children, #complexity, #lines, #name, #parent
Instance Method Summary collapse
- #compute_state(formater) ⇒ Object
-
#create_def_name(token) ⇒ Object
This way I don’t need to list all possible overload tokens.
-
#initialize(lexer, parent = nil) ⇒ ParseDef
constructor
A new instance of ParseDef.
- #parse_token(token) ⇒ Object
Methods inherited from EndableParseState
Methods inherited from ParseState
#calc_complexity, #calc_lines, #compute_state_for_global, #count_tokens?, #do_begin_token, #do_block_token, #do_case_token, #do_class_token, #do_comment_token, #do_conditional_do_control_token, #do_conditional_token, #do_constant_token, #do_def_token, #do_else_token, #do_end_token, #do_identifier_token, #do_module_token, #do_one_line_conditional_token, #do_right_brace_token, #do_symbol_token, #end_debug, get_token_counter, #lexer=, #lexer_loop?, #make_state, make_top_state, #parse, set_token_counter, #top_state?
Constructor Details
#initialize(lexer, parent = nil) ⇒ ParseDef
Returns a new instance of ParseDef.
516 517 518 519 520 521 |
# File 'lib/metric_fu/saikuro/saikuro.rb', line 516 def initialize(lexer,parent=nil) super(lexer,parent) @complexity = 1 @looking_for_name = true @first_space = true end |
Instance Method Details
#compute_state(formater) ⇒ Object
568 569 570 571 |
# File 'lib/metric_fu/saikuro/saikuro.rb', line 568 def compute_state(formater) formater.def_compute_state(@name, self.calc_complexity, self.calc_lines) super(formater) end |
#create_def_name(token) ⇒ Object
This way I don’t need to list all possible overload tokens.
525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 |
# File 'lib/metric_fu/saikuro/saikuro.rb', line 525 def create_def_name(token) case token when TkSPACE # mark first space so we can stop at next space if @first_space @first_space = false else @looking_for_name = false end when TkNL,TkLPAREN,TkfLPAREN,TkSEMICOLON # we can also stop at a new line or left parenthesis @looking_for_name = false when TkDOT @name<< "." when TkCOLON2 @name<< "::" when TkASSIGN @name<< "=" when TkfLBRACK @name<< "[" when TkRBRACK @name<< "]" else begin @name<< token.name.to_s rescue Exception => err #what is this? STDOUT.puts @@token_counter.current_file STDOUT.puts @name STDOUT.puts token.inspect STDOUT.puts err. exit 1 end end end |
#parse_token(token) ⇒ Object
561 562 563 564 565 566 |
# File 'lib/metric_fu/saikuro/saikuro.rb', line 561 def parse_token(token) if @looking_for_name create_def_name(token) end super(token) end |