Class: DeepConnect::MethodSpec::Tokener
- Defined in:
- lib/deep-connect/class-spec-space.rb
Instance Method Summary collapse
- #identify_identifier ⇒ Object
-
#initialize(src) ⇒ Tokener
constructor
A new instance of Tokener.
- #next ⇒ Object
- #peek ⇒ Object
- #unget(token) ⇒ Object
Constructor Details
#initialize(src) ⇒ Tokener
Returns a new instance of Tokener.
593 594 595 596 |
# File 'lib/deep-connect/class-spec-space.rb', line 593 def initialize(src) @src = src.split(//) @tokens = [] end |
Instance Method Details
#identify_identifier ⇒ Object
627 628 629 630 631 632 633 634 635 636 637 638 639 |
# File 'lib/deep-connect/class-spec-space.rb', line 627 def identify_identifier toks = [] while s = @src.shift if /[\w]/ =~ s toks.push s else @src.unshift s break end end reading = toks.join("") TkIdentifier.new(reading) end |
#next ⇒ Object
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 |
# File 'lib/deep-connect/class-spec-space.rb', line 598 def next return @tokens.shift unless @tokens.empty? while /\s/ =~ @src[0]; @src.shift; end case @src[0] when nil nil when ",", "(", ")", "{", "}", "*" reading = @src.shift when /\w/ identify_identifier else MethodSpec.Raise UnrecognizedError, @src.join("") end end |
#peek ⇒ Object
615 616 617 618 619 620 621 |
# File 'lib/deep-connect/class-spec-space.rb', line 615 def peek @tokens.first unless @tokens.empty? token = self.next @tokens.push(token) if token token end |
#unget(token) ⇒ Object
623 624 625 |
# File 'lib/deep-connect/class-spec-space.rb', line 623 def unget(token) @tokens.unshift token end |