class CodeRay::Encoders::Lint
See also: Encoders::DebugLint
It will raise an InvalidTokenStream exception when any of the above occurs.
- incorrect nesting
- empty tokens
Checks for:
= Lint Encoder
def begin_group kind
def begin_group kind @opened << kind end
def begin_line kind
def begin_line kind @opened << kind end
def end_group kind
def end_group kind raise IncorrectTokenGroupNesting, 'We are inside %s, not %p (end_group)' % [@opened.reverse.map(&:inspect).join(' < '), kind] if @opened.last != kind @opened.pop end
def end_line kind
def end_line kind raise IncorrectTokenGroupNesting, 'We are inside %s, not %p (end_line)' % [@opened.reverse.map(&:inspect).join(' < '), kind] if @opened.last != kind @opened.pop end
def finish options
def finish options raise 'Some tokens still open at end of token stream: %p' % [@opened] unless @opened.empty? end
def setup options
def setup options @opened = [] end
def text_token text, kind
def text_token text, kind raise EmptyToken, 'empty token for %p' % [kind] if text.empty? raise UnknownTokenKind, 'unknown token kind %p (text was %p)' % [kind, text] unless TokenKinds.has_key? kind end