Collection of methods for writing parsers
Methods
- A
- G
- P
- R
- S
- T
- U
Instance Public methods
add_token_listener(obj) Link
Adds a token listener obj
, but you should probably use token_listener
get_tk() Link
Fetches the next token from the scanner
# File ruby/lib/rdoc/parser/ruby_tools.rb, line 18 def get_tk tk = nil if @tokens.empty? then if @scanner_point >= @scanner.size return nil else tk = @scanner[@scanner_point] @scanner_point += 1 @read.push tk[:text] end else @read.push @unget_read.shift tk = @tokens.shift end if tk == nil || :on___end__ == tk[:kind] tk = nil end return nil unless tk # inform any listeners of our shiny new token @token_listeners.each do |obj| obj.add_token(tk) end if @token_listeners tk end
get_tk_until(*tokens) Link
Reads and returns all tokens up to one of tokens
. Leaves the matched token in the token list.
peek_read() Link
Peek equivalent for get_tkread
peek_tk() Link
Peek at the next token, but don’t remove it from the stream
remove_token_listener(obj) Link
Removes the token listener obj
reset() Link
Resets the tools
skip_tkspace() Link
Skips whitespace tokens including newlines
skip_tkspace_without_nl() Link
Skips whitespace tokens excluding newlines
token_listener(obj) Link
Has obj
listen to tokens
unget_tk(tk) Link
Returns tk
to the scanner