diff options
Diffstat (limited to 'tests/lexers/rb')
| -rw-r--r-- | tests/lexers/rb/example.txt | 73 | ||||
| -rw-r--r-- | tests/lexers/rb/example2.txt | 12162 | ||||
| -rw-r--r-- | tests/lexers/rb/example3.txt | 473 | ||||
| -rw-r--r-- | tests/lexers/rb/example4.txt | 161 | ||||
| -rw-r--r-- | tests/lexers/rb/example5.txt | 10683 | ||||
| -rw-r--r-- | tests/lexers/rb/example6.txt | 373 | ||||
| -rw-r--r-- | tests/lexers/rb/example7.txt | 86 | ||||
| -rw-r--r-- | tests/lexers/rb/example8.txt | 1375 |
8 files changed, 25386 insertions, 0 deletions
diff --git a/tests/lexers/rb/example.txt b/tests/lexers/rb/example.txt new file mode 100644 index 00000000..7566ba44 --- /dev/null +++ b/tests/lexers/rb/example.txt @@ -0,0 +1,73 @@ +---input--- +{ :old_syntax => 'ok' } +{ 'stings as key' => 'should be ok' } +{ new_syntax: 'broken until now' } +{ withoutunderscore: 'should be ok' } +{ _underscoreinfront: 'might be ok, if I understand the pygments code correct' } + +---tokens--- +'{' Punctuation +' ' Text +':old_syntax' Literal.String.Symbol +' ' Text +'=' Operator +'>' Operator +' ' Text +"'" Literal.String.Single +'ok' Literal.String.Single +"'" Literal.String.Single +' ' Text +'}' Punctuation +'\n' Text + +'{' Punctuation +' ' Text +"'" Literal.String.Single +'stings as key' Literal.String.Single +"'" Literal.String.Single +' ' Text +'=' Operator +'>' Operator +' ' Text +"'" Literal.String.Single +'should be ok' Literal.String.Single +"'" Literal.String.Single +' ' Text +'}' Punctuation +'\n' Text + +'{' Punctuation +' ' Text +'new_syntax' Literal.String.Symbol +':' Punctuation +' ' Text +"'" Literal.String.Single +'broken until now' Literal.String.Single +"'" Literal.String.Single +' ' Text +'}' Punctuation +'\n' Text + +'{' Punctuation +' ' Text +'withoutunderscore' Literal.String.Symbol +':' Punctuation +' ' Text +"'" Literal.String.Single +'should be ok' Literal.String.Single +"'" Literal.String.Single +' ' Text +'}' Punctuation +'\n' Text + +'{' Punctuation +' ' Text +'_underscoreinfront' Literal.String.Symbol +':' Punctuation +' ' Text +"'" Literal.String.Single +'might be ok, if I understand the pygments code correct' Literal.String.Single +"'" Literal.String.Single +' ' Text +'}' Punctuation +'\n' Text diff --git a/tests/lexers/rb/example2.txt b/tests/lexers/rb/example2.txt new file mode 100644 index 00000000..8e8d0241 --- /dev/null +++ b/tests/lexers/rb/example2.txt @@ -0,0 +1,12162 @@ +---input--- +module CodeRay + module Scanners + +class Ruby < Scanner + + RESERVED_WORDS = [ + 'and', 'def', 'end', 'in', 'or', 'unless', 'begin', + 'defined?', 'ensure', 'module', 'redo', 'super', 'until', + 'BEGIN', 'break', 'do', 'next', 'rescue', 'then', + 'when', 'END', 'case', 'else', 'for', 'retry', + 'while', 'alias', 'class', 'elsif', 'if', 'not', 'return', + 'undef', 'yield', + ] + + DEF_KEYWORDS = ['def'] + MODULE_KEYWORDS = ['class', 'module'] + DEF_NEW_STATE = WordList.new(:initial). + add(DEF_KEYWORDS, :def_expected). + add(MODULE_KEYWORDS, :module_expected) + + WORDS_ALLOWING_REGEXP = [ + 'and', 'or', 'not', 'while', 'until', 'unless', 'if', 'elsif', 'when' + ] + REGEXP_ALLOWED = WordList.new(false). + add(WORDS_ALLOWING_REGEXP, :set) + + PREDEFINED_CONSTANTS = [ + 'nil', 'true', 'false', 'self', + 'DATA', 'ARGV', 'ARGF', '__FILE__', '__LINE__', + ] + + IDENT_KIND = WordList.new(:ident). + add(RESERVED_WORDS, :reserved). + add(PREDEFINED_CONSTANTS, :pre_constant) + + METHOD_NAME = / #{IDENT} [?!]? /xo + METHOD_NAME_EX = / + #{METHOD_NAME} # common methods: split, foo=, empty?, gsub! + | \*\*? # multiplication and power + | [-+~]@? # plus, minus + | [\/%&|^`] # division, modulo or format strings, &and, |or, ^xor, `system` + | \[\]=? # array getter and setter + | <=?>? | >=? # comparison, rocket operator + | << | >> # append or shift left, shift right + | ===? # simple equality and case equality + /ox + GLOBAL_VARIABLE = / \$ (?: #{IDENT} | \d+ | [~&+`'=\/,;_.<>!@0$?*":F\\] | -[a-zA-Z_0-9] ) /ox + + DOUBLEQ = / " [^"\#\\]* (?: (?: \#\{.*?\} | \#(?:$")? | \\. ) [^"\#\\]* )* "? /ox + SINGLEQ = / ' [^'\\]* (?: \\. [^'\\]* )* '? /ox + STRING = / #{SINGLEQ} | #{DOUBLEQ} /ox + SHELL = / ` [^`\#\\]* (?: (?: \#\{.*?\} | \#(?:$`)? | \\. ) [^`\#\\]* )* `? /ox + REGEXP = / \/ [^\/\#\\]* (?: (?: \#\{.*?\} | \#(?:$\/)? | \\. ) [^\/\#\\]* )* \/? /ox + + DECIMAL = /\d+(?:_\d+)*/ # doesn't recognize 09 as octal error + OCTAL = /0_?[0-7]+(?:_[0-7]+)*/ + HEXADECIMAL = /0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/ + BINARY = /0b[01]+(?:_[01]+)*/ + + EXPONENT = / [eE] [+-]? #{DECIMAL} /ox + FLOAT = / #{DECIMAL} (?: #{EXPONENT} | \. #{DECIMAL} #{EXPONENT}? ) / + INTEGER = /#{OCTAL}|#{HEXADECIMAL}|#{BINARY}|#{DECIMAL}/ + + def reset + super + @regexp_allowed = false + end + + def next_token + return if @scanner.eos? + + kind = :error + if @scanner.scan(/\s+/) # in every state + kind = :space + @regexp_allowed = :set if @regexp_allowed or @scanner.matched.index(?\n) # delayed flag setting + + elsif @state == :def_expected + if @scanner.scan(/ (?: (?:#{IDENT}(?:\.|::))* | (?:@@?|$)? #{IDENT}(?:\.|::) ) #{METHOD_NAME_EX} /ox) + kind = :method + @state = :initial + else + @scanner.getch + end + @state = :initial + + elsif @state == :module_expected + if @scanner.scan(/<</) + kind = :operator + else + if @scanner.scan(/ (?: #{IDENT} (?:\.|::))* #{IDENT} /ox) + kind = :method + else + @scanner.getch + end + @state = :initial + end + + elsif # state == :initial + # IDENTIFIERS, KEYWORDS + if @scanner.scan(GLOBAL_VARIABLE) + kind = :global_variable + elsif @scanner.scan(/ @@ #{IDENT} /ox) + kind = :class_variable + elsif @scanner.scan(/ @ #{IDENT} /ox) + kind = :instance_variable + elsif @scanner.scan(/ __END__\n ( (?!\#CODE\#) .* )? | \#[^\n]* | =begin(?=\s).*? \n=end(?=\s|\z)(?:[^\n]*)? /mx) + kind = :comment + elsif @scanner.scan(METHOD_NAME) + if @last_token_dot + kind = :ident + else + matched = @scanner.matched + kind = IDENT_KIND[matched] + if kind == :ident and matched =~ /^[A-Z]/ + kind = :constant + elsif kind == :reserved + @state = DEF_NEW_STATE[matched] + @regexp_allowed = REGEXP_ALLOWED[matched] + end + end + + elsif @scanner.scan(STRING) + kind = :string + elsif @scanner.scan(SHELL) + kind = :shell + elsif @scanner.scan(/<< + (?: + ([a-zA-Z_0-9]+) + (?: .*? ^\1$ | .* ) + | + -([a-zA-Z_0-9]+) + (?: .*? ^\s*\2$ | .* ) + | + (["\'`]) (.+?) \3 + (?: .*? ^\4$ | .* ) + | + - (["\'`]) (.+?) \5 + (?: .*? ^\s*\6$ | .* ) + ) + /mxo) + kind = :string + elsif @scanner.scan(/\//) and @regexp_allowed + @scanner.unscan + @scanner.scan(REGEXP) + kind = :regexp +/%(?:[Qqxrw](?:\([^)#\\\\]*(?:(?:#\{.*?\}|#|\\\\.)[^)#\\\\]*)*\)?|\[[^\]#\\\\]*(?:(?:#\{.*?\}|#|\\\\.)[^\]#\\\\]*)*\]?|\{[^}#\\\\]*(?:(?:#\{.*?\}|#|\\\\.)[^}#\\\\]*)*\}?|<[^>#\\\\]*(?:(?:#\{.*?\}|#|\\\\.)[^>#\\\\]*)*>?|([^a-zA-Z\\\\])(?:(?!\1)[^#\\\\])*(?:(?:#\{.*?\}|#|\\\\.)(?:(?!\1)[^#\\\\])*)*\1?)|\([^)#\\\\]*(?:(?:#\{.*?\}|#|\\\\.)[^)#\\\\]*)*\)?|\[[^\]#\\\\]*(?:(?:#\{.*?\}|#|\\\\.)[^\]#\\\\]*)*\]?|\{[^}#\\\\]*(?:(?:#\{.*?\}|#|\\\\.)[^}#\\\\]*)*\}?|<[^>#\\\\]*(?:(?:#\{.*?\}|#|\\\\.)[^>#\\\\]*)*>?|([^a-zA-Z\s\\\\])(?:(?!\2)[^#\\\\])*(?:(?:#\{.*?\}|#|\\\\.)(?:(?!\2)[^#\\\\])*)*\2?|\\\\[^#\\\\]*(?:(?:#\{.*?\}|#)[^#\\\\]*)*\\\\?)/ + elsif @scanner.scan(/:(?:#{GLOBAL_VARIABLE}|#{METHOD_NAME_EX}|#{STRING})/ox) + kind = :symbol + elsif @scanner.scan(/ + \? (?: + [^\s\\] + | + \\ (?:M-\\C-|C-\\M-|M-\\c|c\\M-|c|C-|M-))? (?: \\ (?: . | [0-7]{3} | x[0-9A-Fa-f][0-9A-Fa-f] ) + ) + /mox) + kind = :integer + + elsif @scanner.scan(/ [-+*\/%=<>;,|&!()\[\]{}~?] | \.\.?\.? | ::? /x) + kind = :operator + @regexp_allowed = :set if @scanner.matched[-1,1] =~ /[~=!<>|&^,\(\[+\-\/\*%]\z/ + elsif @scanner.scan(FLOAT) + kind = :float + elsif @scanner.scan(INTEGER) + kind = :integer + else + @scanner.getch + end + end + + token = Token.new @scanner.matched, kind + + if kind == :regexp + token.text << @scanner.scan(/[eimnosux]*/) + end + + @regexp_allowed = (@regexp_allowed == :set) # delayed flag setting + + token + end +end + +register Ruby, 'ruby', 'rb' + + end +end +class Set + include Enumerable + + # Creates a new set containing the given objects. + def self.[](*ary) + new(ary) + end + + # Creates a new set containing the elements of the given enumerable + # object. + # + # If a block is given, the elements of enum are preprocessed by the + # given block. + def initialize(enum = nil, &block) # :yields: o + @hash ||= Hash.new + + enum.nil? and return + + if block + enum.each { |o| add(block[o]) } + else + merge(enum) + end + end + + # Copy internal hash. + def initialize_copy(orig) + @hash = orig.instance_eval{@hash}.dup + end + + # Returns the number of elements. + def size + @hash.size + end + alias length size + + # Returns true if the set contains no elements. + def empty? + @hash.empty? + end + + # Removes all elements and returns self. + def clear + @hash.clear + self + end + + # Replaces the contents of the set with the contents of the given + # enumerable object and returns self. + def replace(enum) + if enum.class == self.class + @hash.replace(enum.instance_eval { @hash }) + else + enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" + clear + enum.each { |o| add(o) } + end + + self + end + + # Converts the set to an array. The order of elements is uncertain. + def to_a + @hash.keys + end + + def flatten_merge(set, seen = Set.new) + set.each { |e| + if e.is_a?(Set) + if seen.include?(e_id = e.object_id) + raise ArgumentError, "tried to flatten recursive Set" + end + + seen.add(e_id) + flatten_merge(e, seen) + seen.delete(e_id) + else + add(e) + end + } + + self + end + protected :flatten_merge + + # Returns a new set that is a copy of the set, flattening each + # containing set recursively. + def flatten + self.class.new.flatten_merge(self) + end + + # Equivalent to Set#flatten, but replaces the receiver with the + # result in place. Returns nil if no modifications were made. + def flatten! + if detect { |e| e.is_a?(Set) } + replace(flatten()) + else + nil + end + end + + # Returns true if the set contains the given object. + def include?(o) + @hash.include?(o) + end + alias member? include? + + # Returns true if the set is a superset of the given set. + def superset?(set) + set.is_a?(Set) or raise ArgumentError, "value must be a set" + return false if size < set.size + set.all? { |o| include?(o) } + end + + # Returns true if the set is a proper superset of the given set. + def proper_superset?(set) + set.is_a?(Set) or raise ArgumentError, "value must be a set" + return false if size <= set.size + set.all? { |o| include?(o) } + end + + # Returns true if the set is a subset of the given set. + def subset?(set) + set.is_a?(Set) or raise ArgumentError, "value must be a set" + return false if set.size < size + all? { |o| set.include?(o) } + end + + # Returns true if the set is a proper subset of the given set. + def proper_subset?(set) + set.is_a?(Set) or raise ArgumentError, "value must be a set" + return false if set.size <= size + all? { |o| set.include?(o) } + end + + # Calls the given block once for each element in the set, passing + # the element as parameter. + def each + @hash.each_key { |o| yield(o) } + self + end + + # Adds the given object to the set and returns self. Use +merge+ to + # add several elements at once. + def add(o) + @hash[o] = true + self + end + alias << add + + # Adds the given object to the set and returns self. If the + # object is already in the set, returns nil. + def add?(o) + if include?(o) + nil + else + add(o) + end + end + + # Deletes the given object from the set and returns self. Use +subtract+ to + # delete several items at once. + def delete(o) + @hash.delete(o) + self + end + + # Deletes the given object from the set and returns self. If the + # object is not in the set, returns nil. + def delete?(o) + if include?(o) + delete(o) + else + nil + end + end + + # Deletes every element of the set for which block evaluates to + # true, and returns self. + def delete_if + @hash.delete_if { |o,| yield(o) } + self + end + + # Do collect() destructively. + def collect! + set = self.class.new + each { |o| set << yield(o) } + replace(set) + end + alias map! collect! + + # Equivalent to Set#delete_if, but returns nil if no changes were + # made. + def reject! + n = size + delete_if { |o| yield(o) } + size == n ? nil : self + end + + # Merges the elements of the given enumerable object to the set and + # returns self. + def merge(enum) + if enum.is_a?(Set) + @hash.update(enum.instance_eval { @hash }) + else + enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" + enum.each { |o| add(o) } + end + + self + end + + # Deletes every element that appears in the given enumerable object + # and returns self. + def subtract(enum) + enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" + enum.each { |o| delete(o) } + self + end + + # Returns a new set built by merging the set and the elements of the + # given enumerable object. + def |(enum) + enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" + dup.merge(enum) + end + alias + | ## + alias union | ## + + # Returns a new set built by duplicating the set, removing every + # element that appears in the given enumerable object. + def -(enum) + enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" + dup.subtract(enum) + end + alias difference - ## + + # Returns a new array containing elements common to the set and the + # given enumerable object. + def &(enum) + enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" + n = self.class.new + enum.each { |o| n.add(o) if include?(o) } + n + end + alias intersection & ## + + # Returns a new array containing elements exclusive between the set + # and the given enumerable object. (set ^ enum) is equivalent to + # ((set | enum) - (set & enum)). + def ^(enum) + enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" + n = dup + enum.each { |o| if n.include?(o) then n.delete(o) else n.add(o) end } + n + end + + # Returns true if two sets are equal. The equality of each couple + # of elements is defined according to Object#eql?. + def ==(set) + equal?(set) and return true + + set.is_a?(Set) && size == set.size or return false + + hash = @hash.dup + set.all? { |o| hash.include?(o) } + end + + def hash # :nodoc: + @hash.hash + end + + def eql?(o) # :nodoc: + return false unless o.is_a?(Set) + @hash.eql?(o.instance_eval{@hash}) + end + + # Classifies the set by the return value of the given block and + # returns a hash of {value => set of elements} pairs. The block is + # called once for each element of the set, passing the element as + # parameter. + # + # e.g.: + # + # require 'set' + # files = Set.new(Dir.glob("*.rb")) + # hash = files.classify { |f| File.mtime(f).year } + # p hash # => {2000=>#<Set: {"a.rb", "b.rb"}>, + # # 2001=>#<Set: {"c.rb", "d.rb", "e.rb"}>, + # # 2002=>#<Set: {"f.rb"}>} + def classify # :yields: o + h = {} + + each { |i| + x = yield(i) + (h[x] ||= self.class.new).add(i) + } + + h + end + + # Divides the set into a set of subsets according to the commonality + # defined by the given block. + # + # If the arity of the block is 2, elements o1 and o2 are in common + # if block.call(o1, o2) is true. Otherwise, elements o1 and o2 are + # in common if block.call(o1) == block.call(o2). + # + # e.g.: + # + # require 'set' + # numbers = Set[1, 3, 4, 6, 9, 10, 11] + # set = numbers.divide { |i,j| (i - j).abs == 1 } + # p set # => #<Set: {#<Set: {1}>, + # # #<Set: {11, 9, 10}>, + # # #<Set: {3, 4}>, + # # #<Set: {6}>}> + def divide(&func) + if func.arity == 2 + require 'tsort' + + class << dig = {} # :nodoc: + include TSort + + alias tsort_each_node each_key + def tsort_each_child(node, &block) + fetch(node).each(&block) + end + end + + each { |u| + dig[u] = a = [] + each{ |v| func.call(u, v) and a << v } + } + + set = Set.new() + dig.each_strongly_connected_component { |css| + set.add(self.class.new(css)) + } + set + else + Set.new(classify(&func).values) + end + end + + InspectKey = :__inspect_key__ # :nodoc: + + # Returns a string containing a human-readable representation of the + # set. ("#<Set: {element1, element2, ...}>") + def inspect + ids = (Thread.current[InspectKey] ||= []) + + if ids.include?(object_id) + return sprintf('#<%s: {...}>', self.class.name) + end + + begin + ids << object_id + return sprintf('#<%s: {%s}>', self.class, to_a.inspect[1..-2]) + ensure + ids.pop + end + end + + def pretty_print(pp) # :nodoc: + pp.text sprintf('#<%s: {', self.class.name) + pp.nest(1) { + pp.seplist(self) { |o| + pp.pp o + } + } + pp.text "}>" + end + + def pretty_print_cycle(pp) # :nodoc: + pp.text sprintf('#<%s: {%s}>', self.class.name, empty? ? '' : '...') + end +end + +# SortedSet implements a set which elements are sorted in order. See Set. +class SortedSet < Set + @@setup = false + + class << self + def [](*ary) # :nodoc: + new(ary) + end + + def setup # :nodoc: + @@setup and return + + begin + require 'rbtree' + + module_eval %{ + def initialize(*args, &block) + @hash = RBTree.new + super + end + } + rescue LoadError + module_eval %{ + def initialize(*args, &block) + @keys = nil + super + end + + def clear + @keys = nil + super + end + + def replace(enum) + @keys = nil + super + end + + def add(o) + @keys = nil + @hash[o] = true + self + end + alias << add + + def delete(o) + @keys = nil + @hash.delete(o) + self + end + + def delete_if + n = @hash.size + @hash.delete_if { |o,| yield(o) } + @keys = nil if @hash.size != n + self + end + + def merge(enum) + @keys = nil + super + end + + def each + to_a.each { |o| yield(o) } + end + + def to_a + (@keys = @hash.keys).sort! unless @keys + @keys + end + } + end + + @@setup = true + end + end + + def initialize(*args, &block) # :nodoc: + SortedSet.setup + initialize(*args, &block) + end +end + +module Enumerable + # Makes a set from the enumerable object with given arguments. + def to_set(klass = Set, *args, &block) + klass.new(self, *args, &block) + end +end + +# =begin +# == RestricedSet class +# RestricedSet implements a set with restrictions defined by a given +# block. +# +# === Super class +# Set +# +# === Class Methods +# --- RestricedSet::new(enum = nil) { |o| ... } +# --- RestricedSet::new(enum = nil) { |rset, o| ... } +# Creates a new restricted set containing the elements of the given +# enumerable object. Restrictions are defined by the given block. +# +# If the block's arity is 2, it is called with the RestrictedSet +# itself and an object to see if the object is allowed to be put in +# the set. +# +# Otherwise, the block is called with an object to see if the object +# is allowed to be put in the set. +# +# === Instance Methods +# --- restriction_proc +# Returns the restriction procedure of the set. +# +# =end +# +# class RestricedSet < Set +# def initialize(*args, &block) +# @proc = block or raise ArgumentError, "missing a block" +# +# if @proc.arity == 2 +# instance_eval %{ +# def add(o) +# @hash[o] = true if @proc.call(self, o) +# self +# end +# alias << add +# +# def add?(o) +# if include?(o) || !@proc.call(self, o) +# nil +# else +# @hash[o] = true +# self +# end +# end +# +# def replace(enum) +# enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" +# clear +# enum.each { |o| add(o) } +# +# self +# end +# +# def merge(enum) +# enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" +# enum.each { |o| add(o) } +# +# self +# end +# } +# else +# instance_eval %{ +# def add(o) +# if @proc.call(o) +# @hash[o] = true +# end +# self +# end +# alias << add +# +# def add?(o) +# if include?(o) || !@proc.call(o) +# nil +# else +# @hash[o] = true +# self +# end +# end +# } +# end +# +# super(*args) +# end +# +# def restriction_proc +# @proc +# end +# end + +if $0 == __FILE__ + eval DATA.read, nil, $0, __LINE__+4 +end + +# = rweb - CGI Support Library +# +# Author:: Johannes Barre (mailto:rweb@igels.net) +# Copyright:: Copyright (c) 2003, 04 by Johannes Barre +# License:: GNU Lesser General Public License (COPYING, http://www.gnu.org/copyleft/lesser.html) +# Version:: 0.1.0 +# CVS-ID:: $Id: example.rb 39 2005-11-05 03:33:55Z murphy $ +# +# == What is Rweb? +# Rweb is a replacement for the cgi class included in the ruby distribution. +# +# == How to use +# +# === Basics +# +# This class is made to be as easy as possible to use. An example: +# +# require "rweb" +# +# web = Rweb.new +# web.out do +# web.puts "Hello world!" +# end +# +# The visitor will get a simple "Hello World!" in his browser. Please notice, +# that won't set html-tags for you, so you should better do something like this: +# +# require "rweb" +# +# web = Rweb.new +# web.out do +# web.puts "<html><body>Hello world!</body></html>" +# end +# +# === Set headers +# Of course, it's also possible to tell the browser, that the content of this +# page is plain text instead of html code: +# +# require "rweb" +# +# web = Rweb.new +# web.out do +# web.header("content-type: text/plain") +# web.puts "Hello plain world!" +# end +# +# Please remember, headers can't be set after the page content has been send. +# You have to set all nessessary headers before the first puts oder print. It's +# possible to cache the content until everything is complete. Doing it this +# way, you can set headers everywhere. +# +# If you set a header twice, the second header will replace the first one. The +# header name is not casesensitive, it will allways converted in to the +# capitalised form suggested by the w3c (http://w3.org) +# +# === Set cookies +# Setting cookies is quite easy: +# include 'rweb' +# +# web = Rweb.new +# Cookie.new("Visits", web.cookies['visits'].to_i +1) +# web.out do +# web.puts "Welcome back! You visited this page #{web.cookies['visits'].to_i +1} times" +# end +# +# See the class Cookie for more details. +# +# === Get form and cookie values +# There are four ways to submit data from the browser to the server and your +# ruby script: via GET, POST, cookies and file upload. Rweb doesn't support +# file upload by now. +# +# include 'rweb' +# +# web = Rweb.new +# web.out do +# web.print "action: #{web.get['action']} " +# web.puts "The value of the cookie 'visits' is #{web.cookies['visits']}" +# web.puts "The post parameter 'test['x']' is #{web.post['test']['x']}" +# end + +RWEB_VERSION = "0.1.0" +RWEB = "rweb/#{RWEB_VERSION}" + +#require 'rwebcookie' -> edit by bunny :-) + +class Rweb + # All parameter submitted via the GET method are available in attribute + # get. This is Hash, where every parameter is available as a key-value + # pair. + # + # If your input tag has a name like this one, it's value will be available + # as web.get["fieldname"] + # <input name="fieldname"> + # You can submit values as a Hash + # <input name="text['index']"> + # <input name="text['index2']"> + # will be available as + # web.get["text"]["index"] + # web.get["text"]["index2"] + # Integers are also possible + # <input name="int[2]"> + # <input name="int[3]['hi']> + # will be available as + # web.get["int"][2] + # web.get["int"][3]["hi"] + # If you specify no index, the lowest unused index will be used: + # <input name="int[]"><!-- First Field --> + # <input name="int[]"><!-- Second one --> + # will be available as + # web.get["int"][0] # First Field + # web.get["int"][1] # Second one + # Please notice, this doesn'd work like you might expect: + # <input name="text[index]"> + # It will not be available as web.get["text"]["index"] but + # web.get["text[index]"] + attr_reader :get + + # All parameters submitted via POST are available in the attribute post. It + # works like the get attribute. + # <input name="text[0]"> + # will be available as + # web.post["text"][0] + attr_reader :post + + # All cookies submitted by the browser are available in cookies. This is a + # Hash, where every cookie is a key-value pair. + attr_reader :cookies + + # The name of the browser identification is submitted as USER_AGENT and + # available in this attribute. + attr_reader :user_agent + + # The IP address of the client. + attr_reader :remote_addr + + # Creates a new Rweb object. This should only done once. You can set various + # options via the settings hash. + # + # "cache" => true: Everything you script send to the client will be cached + # until the end of the out block or until flush is called. This way, you + # can modify headers and cookies even after printing something to the client. + # + # "safe" => level: Changes the $SAFE attribute. By default, $SAFE will be set + # to 1. If $SAFE is already higher than this value, it won't be changed. + # + # "silend" => true: Normaly, Rweb adds automaticly a header like this + # "X-Powered-By: Rweb/x.x.x (Ruby/y.y.y)". With the silend option you can + # suppress this. + def initialize (settings = {}) + # {{{ + @header = {} + @cookies = {} + @get = {} + @post = {} + + # Internal attributes + @status = nil + @reasonPhrase = nil + @setcookies = [] + @output_started = false; + @output_allowed = false; + + @mod_ruby = false + @env = ENV.to_hash + + if defined?(MOD_RUBY) + @output_method = "mod_ruby" + @mod_ruby = true + elsif @env['SERVER_SOFTWARE'] =~ /^Microsoft-IIS/i + @output_method = "nph" + else + @output_method = "ph" + end + + unless settings.is_a?(Hash) + raise TypeError, "settings must be a Hash" + end + @settings = settings + + unless @settings.has_key?("safe") + @settings["safe"] = 1 + end + + if $SAFE < @settings["safe"] + $SAFE = @settings["safe"] + end + + unless @settings.has_key?("cache") + @settings["cache"] = false + end + + # mod_ruby sets no QUERY_STRING variable, if no GET-Parameters are given + unless @env.has_key?("QUERY_STRING") + @env["QUERY_STRING"] = "" + end + + # Now we split the QUERY_STRING by the seperators & and ; or, if + # specified, settings['get seperator'] + unless @settings.has_key?("get seperator") + get_args = @env['QUERY_STRING'].split(/[&;]/) + else + get_args = @env['QUERY_STRING'].split(@settings['get seperator']) + end + + get_args.each do | arg | + arg_key, arg_val = arg.split(/=/, 2) + arg_key = Rweb::unescape(arg_key) + arg_val = Rweb::unescape(arg_val) + + # Parse names like name[0], name['text'] or name[] + pattern = /^(.+)\[("[^\]]*"|'[^\]]*'|[0-9]*)\]$/ + keys = [] + while match = pattern.match(arg_key) + arg_key = match[1] + keys = [match[2]] + keys + end + keys = [arg_key] + keys + + akt = @get + last = nil + lastkey = nil + keys.each do |key| + if key == "" + # No key specified (like in "test[]"), so we use the + # lowerst unused Integer as key + key = 0 + while akt.has_key?(key) + key += 1 + end + elsif /^[0-9]*$/ =~ key + # If the index is numerical convert it to an Integer + key = key.to_i + elsif key[0].chr == "'" || key[0].chr == '"' + key = key[1, key.length() -2] + end + if !akt.has_key?(key) || !akt[key].class == Hash + # create an empty Hash if there isn't already one + akt[key] = {} + end + last = akt + lastkey = key + akt = akt[key] + end + last[lastkey] = arg_val + end + + if @env['REQUEST_METHOD'] == "POST" + if @env.has_key?("CONTENT_TYPE") && @env['CONTENT_TYPE'] == "application/x-www-form-urlencoded" && @env.has_key?('CONTENT_LENGTH') + unless @settings.has_key?("post seperator") + post_args = $stdin.read(@env['CONTENT_LENGTH'].to_i).split(/[&;]/) + else + post_args = $stdin.read(@env['CONTENT_LENGTH'].to_i).split(@settings['post seperator']) + end + post_args.each do | arg | + arg_key, arg_val = arg.split(/=/, 2) + arg_key = Rweb::unescape(arg_key) + arg_val = Rweb::unescape(arg_val) + + # Parse names like name[0], name['text'] or name[] + pattern = /^(.+)\[("[^\]]*"|'[^\]]*'|[0-9]*)\]$/ + keys = [] + while match = pattern.match(arg_key) + arg_key = match[1] + keys = [match[2]] + keys + end + keys = [arg_key] + keys + + akt = @post + last = nil + lastkey = nil + keys.each do |key| + if key == "" + # No key specified (like in "test[]"), so we use + # the lowerst unused Integer as key + key = 0 + while akt.has_key?(key) + key += 1 + end + elsif /^[0-9]*$/ =~ key + # If the index is numerical convert it to an Integer + key = key.to_i + elsif key[0].chr == "'" || key[0].chr == '"' + key = key[1, key.length() -2] + end + if !akt.has_key?(key) || !akt[key].class == Hash + # create an empty Hash if there isn't already one + akt[key] = {} + end + last = akt + lastkey = key + akt = akt[key] + end + last[lastkey] = arg_val + end + else + # Maybe we should print a warning here? + $stderr.print("Unidentified form data recived and discarded.") + end + end + + if @env.has_key?("HTTP_COOKIE") + cookie = @env['HTTP_COOKIE'].split(/; ?/) + cookie.each do | c | + cookie_key, cookie_val = c.split(/=/, 2) + + @cookies [Rweb::unescape(cookie_key)] = Rweb::unescape(cookie_val) + end + end + + if defined?(@env['HTTP_USER_AGENT']) + @user_agent = @env['HTTP_USER_AGENT'] + else + @user_agent = nil; + end + + if defined?(@env['REMOTE_ADDR']) + @remote_addr = @env['REMOTE_ADDR'] + else + @remote_addr = nil + end + # }}} + end + + # Prints a String to the client. If caching is enabled, the String will + # buffered until the end of the out block ends. + def print(str = "") + # {{{ + unless @output_allowed + raise "You just can write to output inside of a Rweb::out-block" + end + + if @settings["cache"] + @buffer += [str.to_s] + else + unless @output_started + sendHeaders + end + $stdout.print(str) + end + nil + # }}} + end + + # Prints a String to the client and adds a line break at the end. Please + # remember, that a line break is not visible in HTML, use the <br> HTML-Tag + # for this. If caching is enabled, the String will buffered until the end + # of the out block ends. + def puts(str = "") + # {{{ + self.print(str + "\n") + # }}} + end + + # Alias to print. + def write(str = "") + # {{{ + self.print(str) + # }}} + end + + # If caching is enabled, all cached data are send to the cliend and the + # cache emptied. + def flush + # {{{ + unless @output_allowed + raise "You can't use flush outside of a Rweb::out-block" + end + buffer = @buffer.join + + unless @output_started + sendHeaders + end + $stdout.print(buffer) + + @buffer = [] + # }}} + end + + # Sends one or more header to the client. All headers are cached just + # before body data are send to the client. If the same header are set + # twice, only the last value is send. + # + # Example: + # web.header("Last-Modified: Mon, 16 Feb 2004 20:15:41 GMT") + # web.header("Location: http://www.ruby-lang.org") + # + # You can specify more than one header at the time by doing something like + # this: + # web.header("Content-Type: text/plain\nContent-Length: 383") + # or + # web.header(["Content-Type: text/plain", "Content-Length: 383"]) + def header(str) + # {{{ + if @output_started + raise "HTTP-Headers are already send. You can't change them after output has started!" + end + unless @output_allowed + raise "You just can set headers inside of a Rweb::out-block" + end + if str.is_a?Array + str.each do | value | + self.header(value) + end + + elsif str.split(/\n/).length > 1 + str.split(/\n/).each do | value | + self.header(value) + end + + elsif str.is_a? String + str.gsub!(/\r/, "") + + if (str =~ /^HTTP\/1\.[01] [0-9]{3} ?.*$/) == 0 + pattern = /^HTTP\/1.[01] ([0-9]{3}) ?(.*)$/ + + result = pattern.match(str) + self.setstatus(result[0], result[1]) + elsif (str =~ /^status: [0-9]{3} ?.*$/i) == 0 + pattern = /^status: ([0-9]{3}) ?(.*)$/i + + result = pattern.match(str) + self.setstatus(result[0], result[1]) + else + a = str.split(/: ?/, 2) + + @header[a[0].downcase] = a[1] + end + end + # }}} + end + + # Changes the status of this page. There are several codes like "200 OK", + # "302 Found", "404 Not Found" or "500 Internal Server Error". A list of + # all codes is available at + # http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10 + # + # You can just send the code number, the reason phrase will be added + # automaticly with the recommendations from the w3c if not specified. If + # you set the status twice or more, only the last status will be send. + # Examples: + # web.status("401 Unauthorized") + # web.status("410 Sad but true, this lonely page is gone :(") + # web.status(206) + # web.status("400") + # + # The default status is "200 OK". If a "Location" header is set, the + # default status is "302 Found". + def status(str) + # {{{ + if @output_started + raise "HTTP-Headers are already send. You can't change them after output has started!" + end + unless @output_allowed + raise "You just can set headers inside of a Rweb::out-block" + end + if str.is_a?Integer + @status = str + elsif str.is_a?String + p1 = /^([0-9]{3}) ?(.*)$/ + p2 = /^HTTP\/1\.[01] ([0-9]{3}) ?(.*)$/ + p3 = /^status: ([0-9]{3}) ?(.*)$/i + + if (a = p1.match(str)) == nil + if (a = p2.match(str)) == nil + if (a = p3.match(str)) == nil + raise ArgumentError, "Invalid argument", caller + end + end + end + @status = a[1].to_i + if a[2] != "" + @reasonPhrase = a[2] + else + @reasonPhrase = getReasonPhrase(@status) + end + else + raise ArgumentError, "Argument of setstatus must be integer or string", caller + end + # }}} + end + + # Handles the output of your content and rescues all exceptions. Send all + # data in the block to this method. For example: + # web.out do + # web.header("Content-Type: text/plain") + # web.puts("Hello, plain world!") + # end + def out + # {{{ + @output_allowed = true + @buffer = []; # We use an array as buffer, because it's more performant :) + + begin + yield + rescue Exception => exception + $stderr.puts "Ruby exception rescued (#{exception.class}): #{exception.message}" + $stderr.puts exception.backtrace.join("\n") + + unless @output_started + self.setstatus(500) + @header = {} + end + + unless (@settings.has_key?("hide errors") and @settings["hide errors"] == true) + unless @output_started + self.header("Content-Type: text/html") + self.puts "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Strict//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">" + self.puts "<html>" + self.puts "<head>" + self.puts "<title>500 Internal Server Error</title>" + self.puts "</head>" + self.puts "<body>" + end + if @header.has_key?("content-type") and (@header["content-type"] =~ /^text\/html/i) == 0 + self.puts "<h1>Internal Server Error</h1>" + self.puts "<p>The server encountered an exception and was unable to complete your request.</p>" + self.puts "<p>The exception has provided the following information:</p>" + self.puts "<pre style=\"background: #FFCCCC; border: black solid 2px; margin-left: 2cm; margin-right: 2cm; padding: 2mm;\"><b>#{exception.class}</b>: #{exception.message} <b>on</b>" + self.puts + self.puts "#{exception.backtrace.join("\n")}</pre>" + self.puts "</body>" + self.puts "</html>" + else + self.puts "The server encountered an exception and was unable to complete your request" + self.puts "The exception has provided the following information:" + self.puts "#{exception.class}: #{exception.message}" + self.puts + self.puts exception.backtrace.join("\n") + end + end + end + + if @settings["cache"] + buffer = @buffer.join + + unless @output_started + unless @header.has_key?("content-length") + self.header("content-length: #{buffer.length}") + end + + sendHeaders + end + $stdout.print(buffer) + elsif !@output_started + sendHeaders + end + @output_allowed = false; + # }}} + end + + # Decodes URL encoded data, %20 for example stands for a space. + def Rweb.unescape(str) + # {{{ + if defined? str and str.is_a? String + str.gsub!(/\+/, " ") + str.gsub(/%.{2}/) do | s | + s[1,2].hex.chr + end + end + # }}} + end + + protected + def sendHeaders + # {{{ + + Cookie.disallow # no more cookies can be set or modified + if !(@settings.has_key?("silent") and @settings["silent"] == true) and !@header.has_key?("x-powered-by") + if @mod_ruby + header("x-powered-by: #{RWEB} (Ruby/#{RUBY_VERSION}, #{MOD_RUBY})"); + else + header("x-powered-by: #{RWEB} (Ruby/#{RUBY_VERSION})"); + end + end + + if @output_method == "ph" + if ((@status == nil or @status == 200) and !@header.has_key?("content-type") and !@header.has_key?("location")) + header("content-type: text/html") + end + + if @status != nil + $stdout.print "Status: #{@status} #{@reasonPhrase}\r\n" + end + + @header.each do |key, value| + key = key *1 # "unfreeze" key :) + key[0] = key[0,1].upcase![0] + + key = key.gsub(/-[a-z]/) do |char| + "-" + char[1,1].upcase + end + + $stdout.print "#{key}: #{value}\r\n" + end + cookies = Cookie.getHttpHeader # Get all cookies as an HTTP Header + if cookies + $stdout.print cookies + end + + $stdout.print "\r\n" + + elsif @output_method == "nph" + elsif @output_method == "mod_ruby" + r = Apache.request + + if ((@status == nil or @status == 200) and !@header.has_key?("content-type") and !@header.has_key?("location")) + header("text/html") + end + + if @status != nil + r.status_line = "#{@status} #{@reasonPhrase}" + end + + r.send_http_header + @header.each do |key, value| + key = key *1 # "unfreeze" key :) + + key[0] = key[0,1].upcase![0] + key = key.gsub(/-[a-z]/) do |char| + "-" + char[1,1].upcase + end + puts "#{key}: #{value.class}" + #r.headers_out[key] = value + end + end + @output_started = true + # }}} + end + + def getReasonPhrase (status) + # {{{ + if status == 100 + "Continue" + elsif status == 101 + "Switching Protocols" + elsif status == 200 + "OK" + elsif status == 201 + "Created" + elsif status == 202 + "Accepted" + elsif status == 203 + "Non-Authoritative Information" + elsif status == 204 + "No Content" + elsif status == 205 + "Reset Content" + elsif status == 206 + "Partial Content" + elsif status == 300 + "Multiple Choices" + elsif status == 301 + "Moved Permanently" + elsif status == 302 + "Found" + elsif status == 303 + "See Other" + elsif status == 304 + "Not Modified" + elsif status == 305 + "Use Proxy" + elsif status == 307 + "Temporary Redirect" + elsif status == 400 + "Bad Request" + elsif status == 401 + "Unauthorized" + elsif status == 402 + "Payment Required" + elsif status == 403 + "Forbidden" + elsif status == 404 + "Not Found" + elsif status == 405 + "Method Not Allowed" + elsif status == 406 + "Not Acceptable" + elsif status == 407 + "Proxy Authentication Required" + elsif status == 408 + "Request Time-out" + elsif status == 409 + "Conflict" + elsif status == 410 + "Gone" + elsif status == 411 + "Length Required" + elsif status == 412 + "Precondition Failed" + elsif status == 413 + "Request Entity Too Large" + elsif status == 414 + "Request-URI Too Large" + elsif status == 415 + "Unsupported Media Type" + elsif status == 416 + "Requested range not satisfiable" + elsif status == 417 + "Expectation Failed" + elsif status == 500 + "Internal Server Error" + elsif status == 501 + "Not Implemented" + elsif status == 502 + "Bad Gateway" + elsif status == 503 + "Service Unavailable" + elsif status == 504 + "Gateway Time-out" + elsif status == 505 + "HTTP Version not supported" + else + raise "Unknown Statuscode. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1 for more information." + end + # }}} + end +end + +class Cookie + attr_reader :name, :value, :maxage, :path, :domain, :secure, :comment + + # Sets a cookie. Please see below for details of the attributes. + def initialize (name, value = nil, maxage = nil, path = nil, domain = nil, secure = false) + # {{{ + # HTTP headers (Cookies are a HTTP header) can only set, while no content + # is send. So an exception will be raised, when @@allowed is set to false + # and a new cookie has set. + unless defined?(@@allowed) + @@allowed = true + end + unless @@allowed + raise "You can't set cookies after the HTTP headers are send." + end + + unless defined?(@@list) + @@list = [] + end + @@list += [self] + + unless defined?(@@type) + @@type = "netscape" + end + + unless name.class == String + raise TypeError, "The name of a cookie must be a string", caller + end + if value.class.superclass == Integer || value.class == Float + value = value.to_s + elsif value.class != String && value != nil + raise TypeError, "The value of a cookie must be a string, integer, float or nil", caller + end + if maxage.class == Time + maxage = maxage - Time.now + elsif !maxage.class.superclass == Integer || !maxage == nil + raise TypeError, "The maxage date of a cookie must be an Integer or Time object or nil.", caller + end + unless path.class == String || path == nil + raise TypeError, "The path of a cookie must be nil or a string", caller + end + unless domain.class == String || domain == nil + raise TypeError, "The value of a cookie must be nil or a string", caller + end + unless secure == true || secure == false + raise TypeError, "The secure field of a cookie must be true or false", caller + end + + @name, @value, @maxage, @path, @domain, @secure = name, value, maxage, path, domain, secure + @comment = nil + # }}} + end + + # Modifies the value of this cookie. The information you want to store. If the + # value is nil, the cookie will be deleted by the client. + # + # This attribute can be a String, Integer or Float object or nil. + def value=(value) + # {{{ + if value.class.superclass == Integer || value.class == Float + value = value.to_s + elsif value.class != String && value != nil + raise TypeError, "The value of a cookie must be a string, integer, float or nil", caller + end + @value = value + # }}} + end + + # Modifies the maxage of this cookie. This attribute defines the lifetime of + # the cookie, in seconds. A value of 0 means the cookie should be discarded + # imediatly. If it set to nil, the cookie will be deleted when the browser + # will be closed. + # + # Attention: This is different from other implementations like PHP, where you + # gives the seconds since 1/1/1970 0:00:00 GMT. + # + # This attribute must be an Integer or Time object or nil. + def maxage=(maxage) + # {{{ + if maxage.class == Time + maxage = maxage - Time.now + elsif maxage.class.superclass == Integer || !maxage == nil + raise TypeError, "The maxage of a cookie must be an Interger or Time object or nil.", caller + end + @maxage = maxage + # }}} + end + + # Modifies the path value of this cookie. The client will send this cookie + # only, if the requested document is this directory or a subdirectory of it. + # + # The value of the attribute must be a String object or nil. + def path=(path) + # {{{ + unless path.class == String || path == nil + raise TypeError, "The path of a cookie must be nil or a string", caller + end + @path = path + # }}} + end + + # Modifies the domain value of this cookie. The client will send this cookie + # only if it's connected with this domain (or a subdomain, if the first + # character is a dot like in ".ruby-lang.org") + # + # The value of this attribute must be a String or nil. + def domain=(domain) + # {{{ + unless domain.class == String || domain == nil + raise TypeError, "The domain of a cookie must be a String or nil.", caller + end + @domain = domain + # }}} + end + + # Modifies the secure flag of this cookie. If it's true, the client will only + # send this cookie if it is secured connected with us. + # + # The value od this attribute has to be true or false. + def secure=(secure) + # {{{ + unless secure == true || secure == false + raise TypeError, "The secure field of a cookie must be true or false", caller + end + @secure = secure + # }}} + end + + # Modifies the comment value of this cookie. The comment won't be send, if + # type is "netscape". + def comment=(comment) + # {{{ + unless comment.class == String || comment == nil + raise TypeError, "The comment of a cookie must be a string or nil", caller + end + @comment = comment + # }}} + end + + # Changes the type of all cookies. + # Allowed values are RFC2109 and netscape (default). + def Cookie.type=(type) + # {{{ + unless @@allowed + raise "The cookies are allready send, so you can't change the type anymore." + end + unless type.downcase == "rfc2109" && type.downcase == "netscape" + raise "The type of the cookies must be \"RFC2109\" or \"netscape\"." + end + @@type = type; + # }}} + end + + # After sending this message, no cookies can be set or modified. Use it, when + # HTTP-Headers are send. Rweb does this for you. + def Cookie.disallow + # {{{ + @@allowed = false + true + # }}} + end + + # Returns a HTTP header (type String) with all cookies. Rweb does this for + # you. + def Cookie.getHttpHeader + # {{{ + if defined?(@@list) + if @@type == "netscape" + str = "" + @@list.each do |cookie| + if cookie.value == nil + cookie.maxage = 0 + cookie.value = "" + end + # TODO: Name and value should be escaped! + str += "Set-Cookie: #{cookie.name}=#{cookie.value}" + unless cookie.maxage == nil + expire = Time.now + cookie.maxage + expire.gmtime + str += "; Expire=#{expire.strftime("%a, %d-%b-%Y %H:%M:%S %Z")}" + end + unless cookie.domain == nil + str += "; Domain=#{cookie.domain}" + end + unless cookie.path == nil + str += "; Path=#{cookie.path}" + end + if cookie.secure + str += "; Secure" + end + str += "\r\n" + end + return str + else # type == "RFC2109" + str = "Set-Cookie: " + comma = false; + + @@list.each do |cookie| + if cookie.value == nil + cookie.maxage = 0 + cookie.value = "" + end + if comma + str += "," + end + comma = true + + str += "#{cookie.name}=\"#{cookie.value}\"" + unless cookie.maxage == nil + str += "; Max-Age=\"#{cookie.maxage}\"" + end + unless cookie.domain == nil + str += "; Domain=\"#{cookie.domain}\"" + end + unless cookie.path == nil + str += "; Path=\"#{cookie.path}\"" + end + if cookie.secure + str += "; Secure" + end + unless cookie.comment == nil + str += "; Comment=\"#{cookie.comment}\"" + end + str += "; Version=\"1\"" + end + str + end + else + false + end + # }}} + end +end + +require 'strscan' + +module BBCode + DEBUG = true + + use 'encoder', 'tags', 'tagstack', 'smileys' + +=begin + The Parser class takes care of the encoding. + It scans the given BBCode (as plain text), finds tags + and smilies and also makes links of urls in text. + + Normal text is send directly to the encoder. + + If a tag was found, an instance of a Tag subclass is created + to handle the case. + + The @tagstack manages tag nesting and ensures valid HTML. +=end + + class Parser + class Attribute + # flatten and use only one empty_arg + def self.create attr + attr = flatten attr + return @@empty_attr if attr.empty? + new attr + end + + private_class_method :new + + # remove leading and trailing whitespace; concat lines + def self.flatten attr + attr.strip.gsub(/\n/, ' ') + # -> ^ and $ can only match at begin and end now + end + + ATTRIBUTE_SCAN = / + (?!$) # don't match at end + \s* + ( # $1 = key + [^=\s\]"\\]* + (?: + (?: \\. | "[^"\\]*(?:\\.[^"\\]*)*"? ) + [^=\s\]"\\]* + )* + ) + (?: + = + ( # $2 = value + [^\s\]"\\]* + (?: + (?: \\. | "[^"\\]*(?:\\.[^"\\]*)*"? ) + [^\s\]"\\]* + )* + )? + )? + \s* + /x + + def self.parse source + source = source.dup + # empty_tag: the tag looks like [... /] + # slice!: this deletes the \s*/] at the end + # \s+ because [url=http://rubybb.org/forum/] is NOT an empty tag. + # In RubyBBCode, you can use [url=http://rubybb.org/forum/ /], and this has to be + # interpreted correctly. + empty_tag = source.sub!(/^:/, '=') or source.slice!(/\/$/) + debug 'PARSE: ' + source.inspect + ' => ' + empty_tag.inspect + #-> we have now an attr that's EITHER empty OR begins and ends with non-whitespace. + + attr = Hash.new + attr[:flags] = [] + source.scan(ATTRIBUTE_SCAN) { |key, value| + if not value + attr[:flags] << unescape(key) + else + next if value.empty? and key.empty? + attr[unescape(key)] = unescape(value) + end + } + debug attr.inspect + + return empty_tag, attr + end + + def self.unescape_char esc + esc[1] + end + + def self.unquote qt + qt[1..-1].chomp('"').gsub(/\\./) { |esc| unescape_char esc } + end + + def self.unescape str + str.gsub(/ (\\.) | (" [^"\\]* (?:\\.[^"\\]*)* "?) /x) { + if $1 + unescape_char $1 + else + unquote $2 + end + } + end + + include Enumerable + def each &block + @args.each(&block) + end + + attr_reader :source, :args, :value + + def initialize source + @source = source + debug 'Attribute#new(%p)' % source + @empty_tag, @attr = Attribute.parse source + @value = @attr[''].to_s + end + + def empty? + self == @@empty_attr + end + + def empty_tag? + @empty_tag + end + + def [] *keys + res = @attr[*keys] + end + + def flags + attr[:flags] + end + + def to_s + @attr + end + + def inspect + 'ATTR[' + @attr.inspect + (@empty_tag ? ' | empty tag' : '') + ']' + end + end + class Attribute + @@empty_attr = new '' + end + end + + +---tokens--- +'module' Keyword +' ' Text +'CodeRay' Name.Namespace +'\n\t' Text +'module' Keyword +' ' Text +'Scanners' Name.Namespace +'\n\n' Text + +'class' Keyword +' ' Text +'Ruby' Name.Class +' ' Text +'<' Operator +' ' Text +'Scanner' Name.Constant +'\n\n\t' Text +'RESERVED_WORDS' Name.Constant +' ' Text +'=' Operator +' ' Text +'[' Operator +'\n\t\t' Text +"'" Literal.String.Single +'and' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'def' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'end' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'in' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'or' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'unless' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'begin' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +'\n\t\t' Text +"'" Literal.String.Single +'defined?' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'ensure' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'module' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'redo' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'super' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'until' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +'\n\t\t' Text +"'" Literal.String.Single +'BEGIN' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'break' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'do' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'next' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'rescue' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'then' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +'\n\t\t' Text +"'" Literal.String.Single +'when' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'END' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'case' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'else' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'for' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'retry' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +'\n\t\t' Text +"'" Literal.String.Single +'while' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'alias' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'class' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'elsif' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'if' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'not' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'return' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +'\n\t\t' Text +"'" Literal.String.Single +'undef' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'yield' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +'\n\t' Text +']' Operator +'\n\n\t' Text +'DEF_KEYWORDS' Name.Constant +' ' Text +'=' Operator +' ' Text +'[' Operator +"'" Literal.String.Single +'def' Literal.String.Single +"'" Literal.String.Single +']' Operator +'\n\t' Text +'MODULE_KEYWORDS' Name.Constant +' ' Text +'=' Operator +' ' Text +'[' Operator +"'" Literal.String.Single +'class' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'module' Literal.String.Single +"'" Literal.String.Single +']' Operator +'\n\t' Text +'DEF_NEW_STATE' Name.Constant +' ' Text +'=' Operator +' ' Text +'WordList' Name.Constant +'.' Operator +'new' Name +'(' Punctuation +':initial' Literal.String.Symbol +')' Punctuation +'.' Operator +'\n\t\t' Text +'add' Name +'(' Punctuation +'DEF_KEYWORDS' Name.Constant +',' Punctuation +' ' Text +':def_expected' Literal.String.Symbol +')' Punctuation +'.' Operator +'\n\t\t' Text +'add' Name +'(' Punctuation +'MODULE_KEYWORDS' Name.Constant +',' Punctuation +' ' Text +':module_expected' Literal.String.Symbol +')' Punctuation +'\n\n\t' Text +'WORDS_ALLOWING_REGEXP' Name.Constant +' ' Text +'=' Operator +' ' Text +'[' Operator +'\n\t\t' Text +"'" Literal.String.Single +'and' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'or' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'not' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'while' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'until' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'unless' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'if' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'elsif' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'when' Literal.String.Single +"'" Literal.String.Single +'\n\t' Text +']' Operator +'\n\t' Text +'REGEXP_ALLOWED' Name.Constant +' ' Text +'=' Operator +' ' Text +'WordList' Name.Constant +'.' Operator +'new' Name +'(' Punctuation +'false' Keyword.Pseudo +')' Punctuation +'.' Operator +'\n\t\t' Text +'add' Name +'(' Punctuation +'WORDS_ALLOWING_REGEXP' Name.Constant +',' Punctuation +' ' Text +':set' Literal.String.Symbol +')' Punctuation +'\n\n\t' Text +'PREDEFINED_CONSTANTS' Name.Constant +' ' Text +'=' Operator +' ' Text +'[' Operator +'\n\t\t' Text +"'" Literal.String.Single +'nil' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'true' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'false' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'self' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +'\n\t\t' Text +"'" Literal.String.Single +'DATA' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'ARGV' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'ARGF' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'__FILE__' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'__LINE__' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +'\n\t' Text +']' Operator +'\n\n\t' Text +'IDENT_KIND' Name.Constant +' ' Text +'=' Operator +' ' Text +'WordList' Name.Constant +'.' Operator +'new' Name +'(' Punctuation +':ident' Literal.String.Symbol +')' Punctuation +'.' Operator +'\n\t\t' Text +'add' Name +'(' Punctuation +'RESERVED_WORDS' Name.Constant +',' Punctuation +' ' Text +':reserved' Literal.String.Symbol +')' Punctuation +'.' Operator +'\n\t\t' Text +'add' Name +'(' Punctuation +'PREDEFINED_CONSTANTS' Name.Constant +',' Punctuation +' ' Text +':pre_constant' Literal.String.Symbol +')' Punctuation +'\n\n\t' Text +'METHOD_NAME' Name.Constant +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +' ' Literal.String.Regex +'#{' Literal.String.Interpol +'IDENT' Name.Constant +'}' Literal.String.Interpol +' [?!]? ' Literal.String.Regex +'/xo' Literal.String.Regex +'\n\t' Text +'METHOD_NAME_EX' Name.Constant +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'\n\t ' Literal.String.Regex +'#{' Literal.String.Interpol +'METHOD_NAME' Name.Constant +'}' Literal.String.Interpol +' ' Literal.String.Regex +'#' Literal.String.Regex +' common methods: split, foo=, empty?, gsub!\n\t | ' Literal.String.Regex +'\\' Literal.String.Regex +'*' Literal.String.Regex +'\\' Literal.String.Regex +'*? ' Literal.String.Regex +'#' Literal.String.Regex +' multiplication and power\n\t | [-+~]@? ' Literal.String.Regex +'#' Literal.String.Regex +' plus, minus\n\t | [' Literal.String.Regex +'\\/' Literal.String.Regex +'%&|^`] ' Literal.String.Regex +'#' Literal.String.Regex +' division, modulo or format strings, &and, |or, ^xor, `system`\n\t | ' Literal.String.Regex +'\\' Literal.String.Regex +'[' Literal.String.Regex +'\\' Literal.String.Regex +']=? ' Literal.String.Regex +'#' Literal.String.Regex +' array getter and setter\n\t | <=?>? | >=? ' Literal.String.Regex +'#' Literal.String.Regex +' comparison, rocket operator\n\t | << | >> ' Literal.String.Regex +'#' Literal.String.Regex +' append or shift left, shift right\n\t | ===? ' Literal.String.Regex +'#' Literal.String.Regex +' simple equality and case equality\n\t' Literal.String.Regex +'/ox' Literal.String.Regex +'\n\t' Text +'GLOBAL_VARIABLE' Name.Constant +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +' ' Literal.String.Regex +'\\' Literal.String.Regex +'$ (?: ' Literal.String.Regex +'#{' Literal.String.Interpol +'IDENT' Name.Constant +'}' Literal.String.Interpol +' | ' Literal.String.Regex +'\\' Literal.String.Regex +"d+ | [~&+`'=" Literal.String.Regex +'\\/' Literal.String.Regex +',;_.<>!@0$?*":F' Literal.String.Regex +'\\\\' Literal.String.Regex +'] | -[a-zA-Z_0-9] ) ' Literal.String.Regex +'/ox' Literal.String.Regex +'\n\n\t' Text +'DOUBLEQ' Name.Constant +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +' " [^"' Literal.String.Regex +'\\' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +']* (?: (?: ' Literal.String.Regex +'\\' Literal.String.Regex +'#' Literal.String.Regex +'\\' Literal.String.Regex +'{.*?' Literal.String.Regex +'\\' Literal.String.Regex +'} | ' Literal.String.Regex +'\\' Literal.String.Regex +'#' Literal.String.Regex +'(?:$")? | ' Literal.String.Regex +'\\\\' Literal.String.Regex +'. ) [^"' Literal.String.Regex +'\\' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +']* )* "? ' Literal.String.Regex +'/ox' Literal.String.Regex +'\n\t' Text +'SINGLEQ' Name.Constant +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +" ' [^'" Literal.String.Regex +'\\\\' Literal.String.Regex +']* (?: ' Literal.String.Regex +'\\\\' Literal.String.Regex +". [^'" Literal.String.Regex +'\\\\' Literal.String.Regex +"]* )* '? " Literal.String.Regex +'/ox' Literal.String.Regex +'\n\t' Text +'STRING' Name.Constant +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +' ' Literal.String.Regex +'#{' Literal.String.Interpol +'SINGLEQ' Name.Constant +'}' Literal.String.Interpol +' | ' Literal.String.Regex +'#{' Literal.String.Interpol +'DOUBLEQ' Name.Constant +'}' Literal.String.Interpol +' ' Literal.String.Regex +'/ox' Literal.String.Regex +'\n\t' Text +'SHELL' Name.Constant +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +' ` [^`' Literal.String.Regex +'\\' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +']* (?: (?: ' Literal.String.Regex +'\\' Literal.String.Regex +'#' Literal.String.Regex +'\\' Literal.String.Regex +'{.*?' Literal.String.Regex +'\\' Literal.String.Regex +'} | ' Literal.String.Regex +'\\' Literal.String.Regex +'#' Literal.String.Regex +'(?:$`)? | ' Literal.String.Regex +'\\\\' Literal.String.Regex +'. ) [^`' Literal.String.Regex +'\\' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +']* )* `? ' Literal.String.Regex +'/ox' Literal.String.Regex +'\n\t' Text +'REGEXP' Name.Constant +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +' ' Literal.String.Regex +'\\/' Literal.String.Regex +' [^' Literal.String.Regex +'\\/' Literal.String.Regex +'\\' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +']* (?: (?: ' Literal.String.Regex +'\\' Literal.String.Regex +'#' Literal.String.Regex +'\\' Literal.String.Regex +'{.*?' Literal.String.Regex +'\\' Literal.String.Regex +'} | ' Literal.String.Regex +'\\' Literal.String.Regex +'#' Literal.String.Regex +'(?:$' Literal.String.Regex +'\\/' Literal.String.Regex +')? | ' Literal.String.Regex +'\\\\' Literal.String.Regex +'. ) [^' Literal.String.Regex +'\\/' Literal.String.Regex +'\\' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +']* )* ' Literal.String.Regex +'\\/' Literal.String.Regex +'? ' Literal.String.Regex +'/ox' Literal.String.Regex +'\n\n\t' Text +'DECIMAL' Name.Constant +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'\\' Literal.String.Regex +'d+(?:_' Literal.String.Regex +'\\' Literal.String.Regex +'d+)*' Literal.String.Regex +'/' Literal.String.Regex +' ' Text +"# doesn't recognize 09 as octal error" Comment.Single +'\n\t' Text +'OCTAL' Name.Constant +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'0_?[0-7]+(?:_[0-7]+)*' Literal.String.Regex +'/' Literal.String.Regex +'\n\t' Text +'HEXADECIMAL' Name.Constant +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*' Literal.String.Regex +'/' Literal.String.Regex +'\n\t' Text +'BINARY' Name.Constant +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'0b[01]+(?:_[01]+)*' Literal.String.Regex +'/' Literal.String.Regex +'\n\n\t' Text +'EXPONENT' Name.Constant +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +' [eE] [+-]? ' Literal.String.Regex +'#{' Literal.String.Interpol +'DECIMAL' Name.Constant +'}' Literal.String.Interpol +' ' Literal.String.Regex +'/ox' Literal.String.Regex +'\n\t' Text +'FLOAT' Name.Constant +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +' ' Literal.String.Regex +'#{' Literal.String.Interpol +'DECIMAL' Name.Constant +'}' Literal.String.Interpol +' (?: ' Literal.String.Regex +'#{' Literal.String.Interpol +'EXPONENT' Name.Constant +'}' Literal.String.Interpol +' | ' Literal.String.Regex +'\\' Literal.String.Regex +'. ' Literal.String.Regex +'#{' Literal.String.Interpol +'DECIMAL' Name.Constant +'}' Literal.String.Interpol +' ' Literal.String.Regex +'#{' Literal.String.Interpol +'EXPONENT' Name.Constant +'}' Literal.String.Interpol +'? ) ' Literal.String.Regex +'/' Literal.String.Regex +'\n\t' Text +'INTEGER' Name.Constant +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'#{' Literal.String.Interpol +'OCTAL' Name.Constant +'}' Literal.String.Interpol +'|' Literal.String.Regex +'#{' Literal.String.Interpol +'HEXADECIMAL' Name.Constant +'}' Literal.String.Interpol +'|' Literal.String.Regex +'#{' Literal.String.Interpol +'BINARY' Name.Constant +'}' Literal.String.Interpol +'|' Literal.String.Regex +'#{' Literal.String.Interpol +'DECIMAL' Name.Constant +'}' Literal.String.Interpol +'/' Literal.String.Regex +'\n\n\t' Text +'def' Keyword +' ' Text +'reset' Name.Function +'\n\t\t' Text +'super' Keyword +'\n\t\t' Text +'@regexp_allowed' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'false' Keyword.Pseudo +'\n\t' Text +'end' Keyword +'\n\n\t' Text +'def' Keyword +' ' Text +'next_token' Name.Function +'\n\t\t' Text +'return' Keyword +' ' Text +'if' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'eos?' Name +'\n\n\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':error' Literal.String.Symbol +'\n\t\t' Text +'if' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'s+' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'# in every state' Comment.Single +'\n\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':space' Literal.String.Symbol +'\n\t\t\t' Text +'@regexp_allowed' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +':set' Literal.String.Symbol +' ' Text +'if' Keyword +' ' Text +'@regexp_allowed' Name.Variable.Instance +' ' Text +'or' Operator.Word +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'matched' Name +'.' Operator +'index' Name +'(' Punctuation +'?\\n' Literal.String.Char +')' Punctuation +' ' Text +'# delayed flag setting' Comment.Single +'\n\n\t\t' Text +'elsif' Keyword +' ' Text +'@state' Name.Variable.Instance +' ' Text +'==' Operator +' ' Text +':def_expected' Literal.String.Symbol +'\n\t\t\t' Text +'if' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +' (?: (?:' Literal.String.Regex +'#{' Literal.String.Interpol +'IDENT' Name.Constant +'}' Literal.String.Interpol +'(?:' Literal.String.Regex +'\\' Literal.String.Regex +'.|::))* | (?:@@?|$)? ' Literal.String.Regex +'#{' Literal.String.Interpol +'IDENT' Name.Constant +'}' Literal.String.Interpol +'(?:' Literal.String.Regex +'\\' Literal.String.Regex +'.|::) ) ' Literal.String.Regex +'#{' Literal.String.Interpol +'METHOD_NAME_EX' Name.Constant +'}' Literal.String.Interpol +' ' Literal.String.Regex +'/ox' Literal.String.Regex +')' Punctuation +'\n\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':method' Literal.String.Symbol +'\n\t\t\t\t' Text +'@state' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +':initial' Literal.String.Symbol +'\n\t\t\t' Text +'else' Keyword +'\n\t\t\t\t' Text +'@scanner' Name.Variable.Instance +'.' Operator +'getch' Name +'\n\t\t\t' Text +'end' Keyword +'\n\t\t\t' Text +'@state' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +':initial' Literal.String.Symbol +'\n\n\t\t' Text +'elsif' Keyword +' ' Text +'@state' Name.Variable.Instance +' ' Text +'==' Operator +' ' Text +':module_expected' Literal.String.Symbol +'\n\t\t\t' Text +'if' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +'<<' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'\n\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':operator' Literal.String.Symbol +'\n\t\t\t' Text +'else' Keyword +'\n\t\t\t\t' Text +'if' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +' (?: ' Literal.String.Regex +'#{' Literal.String.Interpol +'IDENT' Name.Constant +'}' Literal.String.Interpol +' (?:' Literal.String.Regex +'\\' Literal.String.Regex +'.|::))* ' Literal.String.Regex +'#{' Literal.String.Interpol +'IDENT' Name.Constant +'}' Literal.String.Interpol +' ' Literal.String.Regex +'/ox' Literal.String.Regex +')' Punctuation +'\n\t\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':method' Literal.String.Symbol +'\n\t\t\t\t' Text +'else' Keyword +'\n\t\t\t\t\t' Text +'@scanner' Name.Variable.Instance +'.' Operator +'getch' Name +'\n\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t' Text +'@state' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +':initial' Literal.String.Symbol +'\n\t\t\t' Text +'end' Keyword +'\n\n\t\t' Text +'elsif' Keyword +' ' Text +'# state == :initial' Comment.Single +'\n\t\t\t' Text +'# IDENTIFIERS, KEYWORDS' Comment.Single +'\n\t\t\t' Text +'if' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'GLOBAL_VARIABLE' Name.Constant +')' Punctuation +'\n\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':global_variable' Literal.String.Symbol +'\n\t\t\t' Text +'elsif' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +' @@ ' Literal.String.Regex +'#{' Literal.String.Interpol +'IDENT' Name.Constant +'}' Literal.String.Interpol +' ' Literal.String.Regex +'/ox' Literal.String.Regex +')' Punctuation +'\n\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':class_variable' Literal.String.Symbol +'\n\t\t\t' Text +'elsif' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +' @ ' Literal.String.Regex +'#{' Literal.String.Interpol +'IDENT' Name.Constant +'}' Literal.String.Interpol +' ' Literal.String.Regex +'/ox' Literal.String.Regex +')' Punctuation +'\n\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':instance_variable' Literal.String.Symbol +'\n\t\t\t' Text +'elsif' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +' __END__' Literal.String.Regex +'\\' Literal.String.Regex +'n ( (?!' Literal.String.Regex +'\\' Literal.String.Regex +'#' Literal.String.Regex +'CODE' Literal.String.Regex +'\\' Literal.String.Regex +'#' Literal.String.Regex +') .* )? | ' Literal.String.Regex +'\\' Literal.String.Regex +'#' Literal.String.Regex +'[^' Literal.String.Regex +'\\' Literal.String.Regex +'n]* | =begin(?=' Literal.String.Regex +'\\' Literal.String.Regex +'s).*? ' Literal.String.Regex +'\\' Literal.String.Regex +'n=end(?=' Literal.String.Regex +'\\' Literal.String.Regex +'s|' Literal.String.Regex +'\\' Literal.String.Regex +'z)(?:[^' Literal.String.Regex +'\\' Literal.String.Regex +'n]*)? ' Literal.String.Regex +'/mx' Literal.String.Regex +')' Punctuation +'\n\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':comment' Literal.String.Symbol +'\n\t\t\t' Text +'elsif' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'METHOD_NAME' Name.Constant +')' Punctuation +'\n\t\t\t\t' Text +'if' Keyword +' ' Text +'@last_token_dot' Name.Variable.Instance +'\n\t\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':ident' Literal.String.Symbol +'\n\t\t\t\t' Text +'else' Keyword +'\n\t\t\t\t\t' Text +'matched' Name +' ' Text +'=' Operator +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'matched' Name +'\n\t\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +'IDENT_KIND' Name.Constant +'[' Operator +'matched' Name +']' Operator +'\n\t\t\t\t\t' Text +'if' Keyword +' ' Text +'kind' Name +' ' Text +'==' Operator +' ' Text +':ident' Literal.String.Symbol +' ' Text +'and' Operator.Word +' ' Text +'matched' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^[A-Z]' Literal.String.Regex +'/' Literal.String.Regex +'\n\t\t\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':constant' Literal.String.Symbol +'\n\t\t\t\t\t' Text +'elsif' Keyword +' ' Text +'kind' Name +' ' Text +'==' Operator +' ' Text +':reserved' Literal.String.Symbol +'\n\t\t\t\t\t\t' Text +'@state' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'DEF_NEW_STATE' Name.Constant +'[' Operator +'matched' Name +']' Operator +'\n\t\t\t\t\t\t' Text +'@regexp_allowed' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'REGEXP_ALLOWED' Name.Constant +'[' Operator +'matched' Name +']' Operator +'\n\t\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t' Text +'end' Keyword +'\n\n\t\t\t' Text +'elsif' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'STRING' Name.Constant +')' Punctuation +'\n\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':string' Literal.String.Symbol +'\n\t\t\t' Text +'elsif' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'SHELL' Name.Constant +')' Punctuation +'\n\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':shell' Literal.String.Symbol +'\n\t\t\t' Text +'elsif' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +'<<\n\t\t\t\t(?:\n\t\t\t\t\t([a-zA-Z_0-9]+)\n\t\t\t\t\t\t(?: .*? ^' Literal.String.Regex +'\\' Literal.String.Regex +'1$ | .* )\n\t\t\t\t|\n\t\t\t\t\t-([a-zA-Z_0-9]+)\n\t\t\t\t\t\t(?: .*? ^' Literal.String.Regex +'\\' Literal.String.Regex +'s*' Literal.String.Regex +'\\' Literal.String.Regex +'2$ | .* )\n\t\t\t\t|\n\t\t\t\t\t(["' Literal.String.Regex +'\\' Literal.String.Regex +"'`]) (.+?) " Literal.String.Regex +'\\' Literal.String.Regex +'3\n\t\t\t\t\t\t(?: .*? ^' Literal.String.Regex +'\\' Literal.String.Regex +'4$ | .* )\n\t\t\t\t|\n\t\t\t\t\t- (["' Literal.String.Regex +'\\' Literal.String.Regex +"'`]) (.+?) " Literal.String.Regex +'\\' Literal.String.Regex +'5\n\t\t\t\t\t\t(?: .*? ^' Literal.String.Regex +'\\' Literal.String.Regex +'s*' Literal.String.Regex +'\\' Literal.String.Regex +'6$ | .* )\n\t\t\t\t)\n\t\t\t' Literal.String.Regex +'/mxo' Literal.String.Regex +')' Punctuation +'\n\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':string' Literal.String.Symbol +'\n\t\t\t' Text +'elsif' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +'\\/' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'and' Operator.Word +' ' Text +'@regexp_allowed' Name.Variable.Instance +'\n\t\t\t\t' Text +'@scanner' Name.Variable.Instance +'.' Operator +'unscan' Name +'\n\t\t\t\t' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'REGEXP' Name.Constant +')' Punctuation +'\n\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':regexp' Literal.String.Symbol +'\n' Text + +'/' Literal.String.Regex +'%(?:[Qqxrw](?:' Literal.String.Regex +'\\' Literal.String.Regex +'([^)' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*(?:(?:' Literal.String.Regex +'#' Literal.String.Regex +'\\' Literal.String.Regex +'{.*?' Literal.String.Regex +'\\' Literal.String.Regex +'}|' Literal.String.Regex +'#' Literal.String.Regex +'|' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'.)[^)' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*)*' Literal.String.Regex +'\\' Literal.String.Regex +')?|' Literal.String.Regex +'\\' Literal.String.Regex +'[[^' Literal.String.Regex +'\\' Literal.String.Regex +']' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*(?:(?:' Literal.String.Regex +'#' Literal.String.Regex +'\\' Literal.String.Regex +'{.*?' Literal.String.Regex +'\\' Literal.String.Regex +'}|' Literal.String.Regex +'#' Literal.String.Regex +'|' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'.)[^' Literal.String.Regex +'\\' Literal.String.Regex +']' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*)*' Literal.String.Regex +'\\' Literal.String.Regex +']?|' Literal.String.Regex +'\\' Literal.String.Regex +'{[^}' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*(?:(?:' Literal.String.Regex +'#' Literal.String.Regex +'\\' Literal.String.Regex +'{.*?' Literal.String.Regex +'\\' Literal.String.Regex +'}|' Literal.String.Regex +'#' Literal.String.Regex +'|' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'.)[^}' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*)*' Literal.String.Regex +'\\' Literal.String.Regex +'}?|<[^>' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*(?:(?:' Literal.String.Regex +'#' Literal.String.Regex +'\\' Literal.String.Regex +'{.*?' Literal.String.Regex +'\\' Literal.String.Regex +'}|' Literal.String.Regex +'#' Literal.String.Regex +'|' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'.)[^>' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*)*>?|([^a-zA-Z' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'])(?:(?!' Literal.String.Regex +'\\' Literal.String.Regex +'1)[^' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'])*(?:(?:' Literal.String.Regex +'#' Literal.String.Regex +'\\' Literal.String.Regex +'{.*?' Literal.String.Regex +'\\' Literal.String.Regex +'}|' Literal.String.Regex +'#' Literal.String.Regex +'|' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'.)(?:(?!' Literal.String.Regex +'\\' Literal.String.Regex +'1)[^' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'])*)*' Literal.String.Regex +'\\' Literal.String.Regex +'1?)|' Literal.String.Regex +'\\' Literal.String.Regex +'([^)' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*(?:(?:' Literal.String.Regex +'#' Literal.String.Regex +'\\' Literal.String.Regex +'{.*?' Literal.String.Regex +'\\' Literal.String.Regex +'}|' Literal.String.Regex +'#' Literal.String.Regex +'|' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'.)[^)' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*)*' Literal.String.Regex +'\\' Literal.String.Regex +')?|' Literal.String.Regex +'\\' Literal.String.Regex +'[[^' Literal.String.Regex +'\\' Literal.String.Regex +']' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*(?:(?:' Literal.String.Regex +'#' Literal.String.Regex +'\\' Literal.String.Regex +'{.*?' Literal.String.Regex +'\\' Literal.String.Regex +'}|' Literal.String.Regex +'#' Literal.String.Regex +'|' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'.)[^' Literal.String.Regex +'\\' Literal.String.Regex +']' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*)*' Literal.String.Regex +'\\' Literal.String.Regex +']?|' Literal.String.Regex +'\\' Literal.String.Regex +'{[^}' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*(?:(?:' Literal.String.Regex +'#' Literal.String.Regex +'\\' Literal.String.Regex +'{.*?' Literal.String.Regex +'\\' Literal.String.Regex +'}|' Literal.String.Regex +'#' Literal.String.Regex +'|' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'.)[^}' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*)*' Literal.String.Regex +'\\' Literal.String.Regex +'}?|<[^>' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*(?:(?:' Literal.String.Regex +'#' Literal.String.Regex +'\\' Literal.String.Regex +'{.*?' Literal.String.Regex +'\\' Literal.String.Regex +'}|' Literal.String.Regex +'#' Literal.String.Regex +'|' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'.)[^>' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*)*>?|([^a-zA-Z' Literal.String.Regex +'\\' Literal.String.Regex +'s' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'])(?:(?!' Literal.String.Regex +'\\' Literal.String.Regex +'2)[^' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'])*(?:(?:' Literal.String.Regex +'#' Literal.String.Regex +'\\' Literal.String.Regex +'{.*?' Literal.String.Regex +'\\' Literal.String.Regex +'}|' Literal.String.Regex +'#' Literal.String.Regex +'|' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'.)(?:(?!' Literal.String.Regex +'\\' Literal.String.Regex +'2)[^' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'])*)*' Literal.String.Regex +'\\' Literal.String.Regex +'2?|' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'[^' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*(?:(?:' Literal.String.Regex +'#' Literal.String.Regex +'\\' Literal.String.Regex +'{.*?' Literal.String.Regex +'\\' Literal.String.Regex +'}|' Literal.String.Regex +'#' Literal.String.Regex +')[^' Literal.String.Regex +'#' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +']*)*' Literal.String.Regex +'\\\\' Literal.String.Regex +'\\\\' Literal.String.Regex +'?)' Literal.String.Regex +'/' Literal.String.Regex +'\n\t\t\t' Text +'elsif' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +':(?:' Literal.String.Regex +'#{' Literal.String.Interpol +'GLOBAL_VARIABLE' Name.Constant +'}' Literal.String.Interpol +'|' Literal.String.Regex +'#{' Literal.String.Interpol +'METHOD_NAME_EX' Name.Constant +'}' Literal.String.Interpol +'|' Literal.String.Regex +'#{' Literal.String.Interpol +'STRING' Name.Constant +'}' Literal.String.Interpol +')' Literal.String.Regex +'/ox' Literal.String.Regex +')' Punctuation +'\n\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':symbol' Literal.String.Symbol +'\n\t\t\t' Text +'elsif' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +'\n\t\t\t\t' Literal.String.Regex +'\\' Literal.String.Regex +'? (?:\n\t\t\t\t\t[^' Literal.String.Regex +'\\' Literal.String.Regex +'s' Literal.String.Regex +'\\\\' Literal.String.Regex +']\n\t\t\t\t|\n\t\t\t\t\t' Literal.String.Regex +'\\\\' Literal.String.Regex +' (?:M-' Literal.String.Regex +'\\\\' Literal.String.Regex +'C-|C-' Literal.String.Regex +'\\\\' Literal.String.Regex +'M-|M-' Literal.String.Regex +'\\\\' Literal.String.Regex +'c|c' Literal.String.Regex +'\\\\' Literal.String.Regex +'M-|c|C-|M-))? (?: ' Literal.String.Regex +'\\\\' Literal.String.Regex +' (?: . | [0-7]{3} | x[0-9A-Fa-f][0-9A-Fa-f] )\n\t\t\t\t)\n\t\t\t' Literal.String.Regex +'/mox' Literal.String.Regex +')' Punctuation +'\n\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':integer' Literal.String.Symbol +'\n\n\t\t\t' Text +'elsif' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +' [-+*' Literal.String.Regex +'\\/' Literal.String.Regex +'%=<>;,|&!()' Literal.String.Regex +'\\' Literal.String.Regex +'[' Literal.String.Regex +'\\' Literal.String.Regex +']{}~?] | ' Literal.String.Regex +'\\' Literal.String.Regex +'.' Literal.String.Regex +'\\' Literal.String.Regex +'.?' Literal.String.Regex +'\\' Literal.String.Regex +'.? | ::? ' Literal.String.Regex +'/x' Literal.String.Regex +')' Punctuation +'\n\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':operator' Literal.String.Symbol +'\n\t\t\t\t' Text +'@regexp_allowed' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +':set' Literal.String.Symbol +' ' Text +'if' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'matched' Name +'[' Operator +'-' Operator +'1' Literal.Number.Integer +',' Punctuation +'1' Literal.Number.Integer +']' Operator +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'[~=!<>|&^,' Literal.String.Regex +'\\' Literal.String.Regex +'(' Literal.String.Regex +'\\' Literal.String.Regex +'[+' Literal.String.Regex +'\\' Literal.String.Regex +'-' Literal.String.Regex +'\\/' Literal.String.Regex +'\\' Literal.String.Regex +'*%]' Literal.String.Regex +'\\' Literal.String.Regex +'z' Literal.String.Regex +'/' Literal.String.Regex +'\n\t\t\t' Text +'elsif' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'FLOAT' Name.Constant +')' Punctuation +'\n\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':float' Literal.String.Symbol +'\n\t\t\t' Text +'elsif' Keyword +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'INTEGER' Name.Constant +')' Punctuation +'\n\t\t\t\t' Text +'kind' Name +' ' Text +'=' Operator +' ' Text +':integer' Literal.String.Symbol +'\n\t\t\t' Text +'else' Keyword +'\n\t\t\t\t' Text +'@scanner' Name.Variable.Instance +'.' Operator +'getch' Name +'\n\t\t\t' Text +'end' Keyword +'\n\t\t' Text +'end' Keyword +'\n\n\t\t' Text +'token' Name +' ' Text +'=' Operator +' ' Text +'Token' Name.Constant +'.' Operator +'new' Name +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'matched' Name +',' Punctuation +' ' Text +'kind' Name +'\n\n\t\t' Text +'if' Keyword +' ' Text +'kind' Name +' ' Text +'==' Operator +' ' Text +':regexp' Literal.String.Symbol +'\n\t\t\t' Text +'token' Name +'.' Operator +'text' Name +' ' Text +'<<' Operator +' ' Text +'@scanner' Name.Variable.Instance +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +'[eimnosux]*' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'\n\t\t' Text +'end' Keyword +'\n\n\t\t' Text +'@regexp_allowed' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'(' Punctuation +'@regexp_allowed' Name.Variable.Instance +' ' Text +'==' Operator +' ' Text +':set' Literal.String.Symbol +')' Punctuation +' ' Text +'# delayed flag setting' Comment.Single +'\n\n\t\t' Text +'token' Name +'\n\t' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'register' Name +' ' Text +'Ruby' Name.Constant +',' Punctuation +' ' Text +"'" Literal.String.Single +'ruby' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'rb' Literal.String.Single +"'" Literal.String.Single +'\n\n\t' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n' Text + +'class' Keyword +' ' Text +'Set' Name.Class +'\n ' Text +'include' Keyword.Pseudo +' ' Text +'Enumerable' Name.Constant +'\n\n ' Text +'# Creates a new set containing the given objects.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'self' Name.Class +'.' Operator +'[]' Name.Function +'(' Punctuation +'*' Operator +'ary' Name +')' Punctuation +'\n ' Text +'new' Keyword.Pseudo +'(' Punctuation +'ary' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Creates a new set containing the elements of the given enumerable' Comment.Single +'\n ' Text +'# object.' Comment.Single +'\n ' Text +'#' Comment.Single +'\n ' Text +'# If a block is given, the elements of enum are preprocessed by the' Comment.Single +'\n ' Text +'# given block.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'enum' Name +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Pseudo +',' Punctuation +' ' Text +'&' Operator +'block' Name +')' Punctuation +' ' Text +'# :yields: o' Comment.Single +'\n ' Text +'@hash' Name.Variable.Instance +' ' Text +'||' Operator +'=' Operator +' ' Text +'Hash' Name.Constant +'.' Operator +'new' Name +'\n\n ' Text +'enum' Name +'.' Operator +'nil?' Name +' ' Text +'and' Operator.Word +' ' Text +'return' Keyword +'\n\n ' Text +'if' Keyword +' ' Text +'block' Name +'\n ' Text +'enum' Name +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'o' Name +'|' Operator +' ' Text +'add' Name +'(' Punctuation +'block' Name +'[' Operator +'o' Name +']' Operator +')' Punctuation +' ' Text +'}' Punctuation +'\n ' Text +'else' Keyword +'\n ' Text +'merge' Name +'(' Punctuation +'enum' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Copy internal hash.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'initialize_copy' Name.Function +'(' Punctuation +'orig' Name +')' Punctuation +'\n ' Text +'@hash' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'orig' Name +'.' Operator +'instance_eval' Name +'{' Punctuation +'@hash' Name.Variable.Instance +'}' Punctuation +'.' Operator +'dup' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Returns the number of elements.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'size' Name.Function +'\n ' Text +'@hash' Name.Variable.Instance +'.' Operator +'size' Name +'\n ' Text +'end' Keyword +'\n ' Text +'alias' Keyword +' ' Text +'length' Name +' ' Text +'size' Name +'\n\n ' Text +'# Returns true if the set contains no elements.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'empty?' Name.Function +'\n ' Text +'@hash' Name.Variable.Instance +'.' Operator +'empty?' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Removes all elements and returns self.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'clear' Name.Function +'\n ' Text +'@hash' Name.Variable.Instance +'.' Operator +'clear' Name +'\n ' Text +'self' Name.Builtin +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Replaces the contents of the set with the contents of the given' Comment.Single +'\n ' Text +'# enumerable object and returns self.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'replace' Name.Function +'(' Punctuation +'enum' Name +')' Punctuation +'\n ' Text +'if' Keyword +' ' Text +'enum' Name +'.' Operator +'class' Name +' ' Text +'==' Operator +' ' Text +'self' Name.Builtin +'.' Operator +'class' Name +'\n ' Text +'@hash' Name.Variable.Instance +'.' Operator +'replace' Name +'(' Punctuation +'enum' Name +'.' Operator +'instance_eval' Name +' ' Text +'{' Punctuation +' ' Text +'@hash' Name.Variable.Instance +' ' Text +'}' Punctuation +')' Punctuation +'\n ' Text +'else' Keyword +'\n ' Text +'enum' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Enumerable' Name.Constant +')' Punctuation +' ' Text +'or' Operator.Word +' ' Text +'raise' Keyword +' ' Text +'ArgumentError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'value must be enumerable' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'clear' Name +'\n ' Text +'enum' Name +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'o' Name +'|' Operator +' ' Text +'add' Name +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'}' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'self' Name.Builtin +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Converts the set to an array. The order of elements is uncertain.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'to_a' Name.Function +'\n ' Text +'@hash' Name.Variable.Instance +'.' Operator +'keys' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'flatten_merge' Name.Function +'(' Punctuation +'set' Name +',' Punctuation +' ' Text +'seen' Name +' ' Text +'=' Operator +' ' Text +'Set' Name.Constant +'.' Operator +'new' Name +')' Punctuation +'\n ' Text +'set' Name +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +'\n ' Text +'if' Keyword +' ' Text +'e' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Set' Name.Constant +')' Punctuation +'\n\t' Text +'if' Keyword +' ' Text +'seen' Name +'.' Operator +'include?' Name +'(' Punctuation +'e_id' Name +' ' Text +'=' Operator +' ' Text +'e' Name +'.' Operator +'object_id' Name +')' Punctuation +'\n\t ' Text +'raise' Keyword +' ' Text +'ArgumentError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'tried to flatten recursive Set' Literal.String.Double +'"' Literal.String.Double +'\n\t' Text +'end' Keyword +'\n\n\t' Text +'seen' Name +'.' Operator +'add' Name +'(' Punctuation +'e_id' Name +')' Punctuation +'\n\t' Text +'flatten_merge' Name +'(' Punctuation +'e' Name +',' Punctuation +' ' Text +'seen' Name +')' Punctuation +'\n\t' Text +'seen' Name +'.' Operator +'delete' Name +'(' Punctuation +'e_id' Name +')' Punctuation +'\n ' Text +'else' Keyword +'\n\t' Text +'add' Name +'(' Punctuation +'e' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'}' Punctuation +'\n\n ' Text +'self' Name.Builtin +'\n ' Text +'end' Keyword +'\n ' Text +'protected' Keyword.Pseudo +' ' Text +':flatten_merge' Literal.String.Symbol +'\n\n ' Text +'# Returns a new set that is a copy of the set, flattening each' Comment.Single +'\n ' Text +'# containing set recursively.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'flatten' Name.Function +'\n ' Text +'self' Name.Builtin +'.' Operator +'class' Name +'.' Operator +'new' Name +'.' Operator +'flatten_merge' Name +'(' Punctuation +'self' Name.Builtin +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Equivalent to Set#flatten, but replaces the receiver with the' Comment.Single +'\n ' Text +'# result in place. Returns nil if no modifications were made.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'flatten!' Name.Function +'\n ' Text +'if' Keyword +' ' Text +'detect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'e' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Set' Name.Constant +')' Punctuation +' ' Text +'}' Punctuation +'\n ' Text +'replace' Name +'(' Punctuation +'flatten' Name +'(' Punctuation +')' Punctuation +')' Punctuation +'\n ' Text +'else' Keyword +'\n ' Text +'nil' Keyword.Pseudo +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Returns true if the set contains the given object.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'include?' Name.Function +'(' Punctuation +'o' Name +')' Punctuation +'\n ' Text +'@hash' Name.Variable.Instance +'.' Operator +'include?' Name +'(' Punctuation +'o' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'alias' Keyword +' ' Text +'member?' Name +' ' Text +'include' Keyword.Pseudo +'?' Punctuation +'\n\n ' Text +'# Returns true if the set is a superset of the given set.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'superset?' Name.Function +'(' Punctuation +'set' Name +')' Punctuation +'\n ' Text +'set' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Set' Name.Constant +')' Punctuation +' ' Text +'or' Operator.Word +' ' Text +'raise' Keyword +' ' Text +'ArgumentError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'value must be a set' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'return' Keyword +' ' Text +'false' Keyword.Pseudo +' ' Text +'if' Keyword +' ' Text +'size' Name +' ' Text +'<' Operator +' ' Text +'set' Name +'.' Operator +'size' Name +'\n ' Text +'set' Name +'.' Operator +'all?' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'o' Name +'|' Operator +' ' Text +'include' Keyword.Pseudo +'?' Punctuation +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'}' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Returns true if the set is a proper superset of the given set.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'proper_superset?' Name.Function +'(' Punctuation +'set' Name +')' Punctuation +'\n ' Text +'set' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Set' Name.Constant +')' Punctuation +' ' Text +'or' Operator.Word +' ' Text +'raise' Keyword +' ' Text +'ArgumentError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'value must be a set' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'return' Keyword +' ' Text +'false' Keyword.Pseudo +' ' Text +'if' Keyword +' ' Text +'size' Name +' ' Text +'<' Operator +'=' Operator +' ' Text +'set' Name +'.' Operator +'size' Name +'\n ' Text +'set' Name +'.' Operator +'all?' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'o' Name +'|' Operator +' ' Text +'include' Keyword.Pseudo +'?' Punctuation +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'}' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Returns true if the set is a subset of the given set.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'subset?' Name.Function +'(' Punctuation +'set' Name +')' Punctuation +'\n ' Text +'set' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Set' Name.Constant +')' Punctuation +' ' Text +'or' Operator.Word +' ' Text +'raise' Keyword +' ' Text +'ArgumentError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'value must be a set' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'return' Keyword +' ' Text +'false' Keyword.Pseudo +' ' Text +'if' Keyword +' ' Text +'set' Name +'.' Operator +'size' Name +' ' Text +'<' Operator +' ' Text +'size' Name +'\n ' Text +'all?' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'o' Name +'|' Operator +' ' Text +'set' Name +'.' Operator +'include?' Name +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'}' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Returns true if the set is a proper subset of the given set.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'proper_subset?' Name.Function +'(' Punctuation +'set' Name +')' Punctuation +'\n ' Text +'set' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Set' Name.Constant +')' Punctuation +' ' Text +'or' Operator.Word +' ' Text +'raise' Keyword +' ' Text +'ArgumentError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'value must be a set' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'return' Keyword +' ' Text +'false' Keyword.Pseudo +' ' Text +'if' Keyword +' ' Text +'set' Name +'.' Operator +'size' Name +' ' Text +'<' Operator +'=' Operator +' ' Text +'size' Name +'\n ' Text +'all?' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'o' Name +'|' Operator +' ' Text +'set' Name +'.' Operator +'include?' Name +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'}' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Calls the given block once for each element in the set, passing' Comment.Single +'\n ' Text +'# the element as parameter.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'each' Name.Function +'\n ' Text +'@hash' Name.Variable.Instance +'.' Operator +'each_key' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'o' Name +'|' Operator +' ' Text +'yield' Keyword +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'}' Punctuation +'\n ' Text +'self' Name.Builtin +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Adds the given object to the set and returns self. Use +merge+ to' Comment.Single +'\n ' Text +'# add several elements at once.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'add' Name.Function +'(' Punctuation +'o' Name +')' Punctuation +'\n ' Text +'@hash' Name.Variable.Instance +'[' Operator +'o' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'true' Keyword.Pseudo +'\n ' Text +'self' Name.Builtin +'\n ' Text +'end' Keyword +'\n ' Text +'alias' Keyword +' ' Text +'<<' Operator +' ' Text +'add' Name +'\n\n ' Text +'# Adds the given object to the set and returns self. If the' Comment.Single +'\n ' Text +'# object is already in the set, returns nil.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'add?' Name.Function +'(' Punctuation +'o' Name +')' Punctuation +'\n ' Text +'if' Keyword +' ' Text +'include' Keyword.Pseudo +'?' Punctuation +'(' Punctuation +'o' Name +')' Punctuation +'\n ' Text +'nil' Keyword.Pseudo +'\n ' Text +'else' Keyword +'\n ' Text +'add' Name +'(' Punctuation +'o' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Deletes the given object from the set and returns self. Use +subtract+ to' Comment.Single +'\n ' Text +'# delete several items at once.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'delete' Name.Function +'(' Punctuation +'o' Name +')' Punctuation +'\n ' Text +'@hash' Name.Variable.Instance +'.' Operator +'delete' Name +'(' Punctuation +'o' Name +')' Punctuation +'\n ' Text +'self' Name.Builtin +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Deletes the given object from the set and returns self. If the' Comment.Single +'\n ' Text +'# object is not in the set, returns nil.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'delete?' Name.Function +'(' Punctuation +'o' Name +')' Punctuation +'\n ' Text +'if' Keyword +' ' Text +'include' Keyword.Pseudo +'?' Punctuation +'(' Punctuation +'o' Name +')' Punctuation +'\n ' Text +'delete' Name +'(' Punctuation +'o' Name +')' Punctuation +'\n ' Text +'else' Keyword +'\n ' Text +'nil' Keyword.Pseudo +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Deletes every element of the set for which block evaluates to' Comment.Single +'\n ' Text +'# true, and returns self.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'delete_if' Name.Function +'\n ' Text +'@hash' Name.Variable.Instance +'.' Operator +'delete_if' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'o' Name +',' Punctuation +'|' Operator +' ' Text +'yield' Keyword +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'}' Punctuation +'\n ' Text +'self' Name.Builtin +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Do collect() destructively.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'collect!' Name.Function +'\n ' Text +'set' Name +' ' Text +'=' Operator +' ' Text +'self' Name.Builtin +'.' Operator +'class' Name +'.' Operator +'new' Name +'\n ' Text +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'o' Name +'|' Operator +' ' Text +'set' Name +' ' Text +'<<' Operator +' ' Text +'yield' Keyword +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'}' Punctuation +'\n ' Text +'replace' Name +'(' Punctuation +'set' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'alias' Keyword +' ' Text +'map!' Name +' ' Text +'collect!' Name +'\n\n ' Text +'# Equivalent to Set#delete_if, but returns nil if no changes were' Comment.Single +'\n ' Text +'# made.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'reject!' Name.Function +'\n ' Text +'n' Name +' ' Text +'=' Operator +' ' Text +'size' Name +'\n ' Text +'delete_if' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'o' Name +'|' Operator +' ' Text +'yield' Keyword +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'}' Punctuation +'\n ' Text +'size' Name +' ' Text +'==' Operator +' ' Text +'n' Name +' ' Text +'?' Punctuation +' ' Text +'nil' Keyword.Pseudo +' ' Text +':' Punctuation +' ' Text +'self' Name.Builtin +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Merges the elements of the given enumerable object to the set and' Comment.Single +'\n ' Text +'# returns self.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'merge' Name.Function +'(' Punctuation +'enum' Name +')' Punctuation +'\n ' Text +'if' Keyword +' ' Text +'enum' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Set' Name.Constant +')' Punctuation +'\n ' Text +'@hash' Name.Variable.Instance +'.' Operator +'update' Name +'(' Punctuation +'enum' Name +'.' Operator +'instance_eval' Name +' ' Text +'{' Punctuation +' ' Text +'@hash' Name.Variable.Instance +' ' Text +'}' Punctuation +')' Punctuation +'\n ' Text +'else' Keyword +'\n ' Text +'enum' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Enumerable' Name.Constant +')' Punctuation +' ' Text +'or' Operator.Word +' ' Text +'raise' Keyword +' ' Text +'ArgumentError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'value must be enumerable' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'enum' Name +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'o' Name +'|' Operator +' ' Text +'add' Name +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'}' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'self' Name.Builtin +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Deletes every element that appears in the given enumerable object' Comment.Single +'\n ' Text +'# and returns self.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'subtract' Name.Function +'(' Punctuation +'enum' Name +')' Punctuation +'\n ' Text +'enum' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Enumerable' Name.Constant +')' Punctuation +' ' Text +'or' Operator.Word +' ' Text +'raise' Keyword +' ' Text +'ArgumentError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'value must be enumerable' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'enum' Name +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'o' Name +'|' Operator +' ' Text +'delete' Name +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'}' Punctuation +'\n ' Text +'self' Name.Builtin +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Returns a new set built by merging the set and the elements of the' Comment.Single +'\n ' Text +'# given enumerable object.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'|' Name.Function +'(' Punctuation +'enum' Name +')' Punctuation +'\n ' Text +'enum' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Enumerable' Name.Constant +')' Punctuation +' ' Text +'or' Operator.Word +' ' Text +'raise' Keyword +' ' Text +'ArgumentError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'value must be enumerable' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'dup' Name.Builtin +'.' Operator +'merge' Name +'(' Punctuation +'enum' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'alias' Keyword +' ' Text +'+' Operator +' ' Text +'|' Operator +'\t\t' Text +'##' Comment.Single +'\n ' Text +'alias' Keyword +' ' Text +'union' Name +' ' Text +'|' Operator +'\t\t' Text +'##' Comment.Single +'\n\n ' Text +'# Returns a new set built by duplicating the set, removing every' Comment.Single +'\n ' Text +'# element that appears in the given enumerable object.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'-' Name.Function +'(' Punctuation +'enum' Name +')' Punctuation +'\n ' Text +'enum' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Enumerable' Name.Constant +')' Punctuation +' ' Text +'or' Operator.Word +' ' Text +'raise' Keyword +' ' Text +'ArgumentError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'value must be enumerable' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'dup' Name.Builtin +'.' Operator +'subtract' Name +'(' Punctuation +'enum' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'alias' Keyword +' ' Text +'difference' Name +' ' Text +'-' Operator +'\t' Text +'##' Comment.Single +'\n\n ' Text +'# Returns a new array containing elements common to the set and the' Comment.Single +'\n ' Text +'# given enumerable object.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'&' Name.Function +'(' Punctuation +'enum' Name +')' Punctuation +'\n ' Text +'enum' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Enumerable' Name.Constant +')' Punctuation +' ' Text +'or' Operator.Word +' ' Text +'raise' Keyword +' ' Text +'ArgumentError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'value must be enumerable' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'n' Name +' ' Text +'=' Operator +' ' Text +'self' Name.Builtin +'.' Operator +'class' Name +'.' Operator +'new' Name +'\n ' Text +'enum' Name +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'o' Name +'|' Operator +' ' Text +'n' Name +'.' Operator +'add' Name +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'if' Keyword +' ' Text +'include' Keyword.Pseudo +'?' Punctuation +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'}' Punctuation +'\n ' Text +'n' Name +'\n ' Text +'end' Keyword +'\n ' Text +'alias' Keyword +' ' Text +'intersection' Name +' ' Text +'&' Operator +'\t' Text +'##' Comment.Single +'\n\n ' Text +'# Returns a new array containing elements exclusive between the set' Comment.Single +'\n ' Text +'# and the given enumerable object. (set ^ enum) is equivalent to' Comment.Single +'\n ' Text +'# ((set | enum) - (set & enum)).' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'^' Name.Function +'(' Punctuation +'enum' Name +')' Punctuation +'\n ' Text +'enum' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Enumerable' Name.Constant +')' Punctuation +' ' Text +'or' Operator.Word +' ' Text +'raise' Keyword +' ' Text +'ArgumentError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'value must be enumerable' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'n' Name +' ' Text +'=' Operator +' ' Text +'dup' Name.Builtin +'\n ' Text +'enum' Name +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'o' Name +'|' Operator +' ' Text +'if' Keyword +' ' Text +'n' Name +'.' Operator +'include?' Name +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'then' Keyword +' ' Text +'n' Name +'.' Operator +'delete' Name +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'else' Keyword +' ' Text +'n' Name +'.' Operator +'add' Name +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'end' Keyword +' ' Text +'}' Punctuation +'\n ' Text +'n' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Returns true if two sets are equal. The equality of each couple' Comment.Single +'\n ' Text +'# of elements is defined according to Object#eql?.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'==' Name.Function +'(' Punctuation +'set' Name +')' Punctuation +'\n ' Text +'equal?' Name.Builtin +'(' Punctuation +'set' Name +')' Punctuation +' ' Text +'and' Operator.Word +' ' Text +'return' Keyword +' ' Text +'true' Keyword.Pseudo +'\n\n ' Text +'set' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Set' Name.Constant +')' Punctuation +' ' Text +'&&' Operator +' ' Text +'size' Name +' ' Text +'==' Operator +' ' Text +'set' Name +'.' Operator +'size' Name +' ' Text +'or' Operator.Word +' ' Text +'return' Keyword +' ' Text +'false' Keyword.Pseudo +'\n\n ' Text +'hash' Name.Builtin +' ' Text +'=' Operator +' ' Text +'@hash' Name.Variable.Instance +'.' Operator +'dup' Name +'\n ' Text +'set' Name +'.' Operator +'all?' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'o' Name +'|' Operator +' ' Text +'hash' Name.Builtin +'.' Operator +'include?' Name +'(' Punctuation +'o' Name +')' Punctuation +' ' Text +'}' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'hash' Name.Function +'\t' Text +'# :nodoc:' Comment.Single +'\n ' Text +'@hash' Name.Variable.Instance +'.' Operator +'hash' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'eql?' Name.Function +'(' Punctuation +'o' Name +')' Punctuation +'\t' Text +'# :nodoc:' Comment.Single +'\n ' Text +'return' Keyword +' ' Text +'false' Keyword.Pseudo +' ' Text +'unless' Keyword +' ' Text +'o' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Set' Name.Constant +')' Punctuation +'\n ' Text +'@hash' Name.Variable.Instance +'.' Operator +'eql?' Name +'(' Punctuation +'o' Name +'.' Operator +'instance_eval' Name +'{' Punctuation +'@hash' Name.Variable.Instance +'}' Punctuation +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Classifies the set by the return value of the given block and' Comment.Single +'\n ' Text +'# returns a hash of {value => set of elements} pairs. The block is' Comment.Single +'\n ' Text +'# called once for each element of the set, passing the element as' Comment.Single +'\n ' Text +'# parameter.' Comment.Single +'\n ' Text +'#' Comment.Single +'\n ' Text +'# e.g.:' Comment.Single +'\n ' Text +'#' Comment.Single +'\n ' Text +"# require 'set'" Comment.Single +'\n ' Text +'# files = Set.new(Dir.glob("*.rb"))' Comment.Single +'\n ' Text +'# hash = files.classify { |f| File.mtime(f).year }' Comment.Single +'\n ' Text +'# p hash # => {2000=>#<Set: {"a.rb", "b.rb"}>,' Comment.Single +'\n ' Text +'# # 2001=>#<Set: {"c.rb", "d.rb", "e.rb"}>,' Comment.Single +'\n ' Text +'# # 2002=>#<Set: {"f.rb"}>}' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'classify' Name.Function +' ' Text +'# :yields: o' Comment.Single +'\n ' Text +'h' Name +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'}' Punctuation +'\n\n ' Text +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'x' Name +' ' Text +'=' Operator +' ' Text +'yield' Keyword +'(' Punctuation +'i' Name +')' Punctuation +'\n ' Text +'(' Punctuation +'h' Name +'[' Operator +'x' Name +']' Operator +' ' Text +'||' Operator +'=' Operator +' ' Text +'self' Name.Builtin +'.' Operator +'class' Name +'.' Operator +'new' Name +')' Punctuation +'.' Operator +'add' Name +'(' Punctuation +'i' Name +')' Punctuation +'\n ' Text +'}' Punctuation +'\n\n ' Text +'h' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Divides the set into a set of subsets according to the commonality' Comment.Single +'\n ' Text +'# defined by the given block.' Comment.Single +'\n ' Text +'#' Comment.Single +'\n ' Text +'# If the arity of the block is 2, elements o1 and o2 are in common' Comment.Single +'\n ' Text +'# if block.call(o1, o2) is true. Otherwise, elements o1 and o2 are' Comment.Single +'\n ' Text +'# in common if block.call(o1) == block.call(o2).' Comment.Single +'\n ' Text +'#' Comment.Single +'\n ' Text +'# e.g.:' Comment.Single +'\n ' Text +'#' Comment.Single +'\n ' Text +"# require 'set'" Comment.Single +'\n ' Text +'# numbers = Set[1, 3, 4, 6, 9, 10, 11]' Comment.Single +'\n ' Text +'# set = numbers.divide { |i,j| (i - j).abs == 1 }' Comment.Single +'\n ' Text +'# p set # => #<Set: {#<Set: {1}>,' Comment.Single +'\n ' Text +'# # #<Set: {11, 9, 10}>,' Comment.Single +'\n ' Text +'# # #<Set: {3, 4}>,' Comment.Single +'\n ' Text +'# # #<Set: {6}>}>' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'divide' Name.Function +'(' Punctuation +'&' Operator +'func' Name +')' Punctuation +'\n ' Text +'if' Keyword +' ' Text +'func' Name +'.' Operator +'arity' Name +' ' Text +'==' Operator +' ' Text +'2' Literal.Number.Integer +'\n ' Text +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'tsort' Literal.String.Single +"'" Literal.String.Single +'\n\n ' Text +'class' Keyword +' ' Text +'<<' Operator +' ' Text +'dig' Name +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'}' Punctuation +'\t\t' Text +'# :nodoc:' Comment.Single +'\n\t' Text +'include' Keyword.Pseudo +' ' Text +'TSort' Name.Constant +'\n\n\t' Text +'alias' Keyword +' ' Text +'tsort_each_node' Name +' ' Text +'each_key' Name +'\n\t' Text +'def' Keyword +' ' Text +'tsort_each_child' Name.Function +'(' Punctuation +'node' Name +',' Punctuation +' ' Text +'&' Operator +'block' Name +')' Punctuation +'\n\t ' Text +'fetch' Name +'(' Punctuation +'node' Name +')' Punctuation +'.' Operator +'each' Name +'(' Punctuation +'&' Operator +'block' Name +')' Punctuation +'\n\t' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'u' Name +'|' Operator +'\n\t' Text +'dig' Name +'[' Operator +'u' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'a' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +'\n\t' Text +'each' Name +'{' Punctuation +' ' Text +'|' Operator +'v' Name +'|' Operator +' ' Text +'func' Name +'.' Operator +'call' Name +'(' Punctuation +'u' Name +',' Punctuation +' ' Text +'v' Name +')' Punctuation +' ' Text +'and' Operator.Word +' ' Text +'a' Name +' ' Text +'<<' Operator +' ' Text +'v' Name +' ' Text +'}' Punctuation +'\n ' Text +'}' Punctuation +'\n\n ' Text +'set' Name +' ' Text +'=' Operator +' ' Text +'Set' Name.Constant +'.' Operator +'new' Name +'(' Punctuation +')' Punctuation +'\n ' Text +'dig' Name +'.' Operator +'each_strongly_connected_component' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'css' Name +'|' Operator +'\n\t' Text +'set' Name +'.' Operator +'add' Name +'(' Punctuation +'self' Name.Builtin +'.' Operator +'class' Name +'.' Operator +'new' Name +'(' Punctuation +'css' Name +')' Punctuation +')' Punctuation +'\n ' Text +'}' Punctuation +'\n ' Text +'set' Name +'\n ' Text +'else' Keyword +'\n ' Text +'Set' Name.Constant +'.' Operator +'new' Name +'(' Punctuation +'classify' Name +'(' Punctuation +'&' Operator +'func' Name +')' Punctuation +'.' Operator +'values' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'InspectKey' Name.Constant +' ' Text +'=' Operator +' ' Text +':__inspect_key__' Literal.String.Symbol +' ' Text +'# :nodoc:' Comment.Single +'\n\n ' Text +'# Returns a string containing a human-readable representation of the' Comment.Single +'\n ' Text +'# set. ("#<Set: {element1, element2, ...}>")' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'inspect' Name.Function +'\n ' Text +'ids' Name +' ' Text +'=' Operator +' ' Text +'(' Punctuation +'Thread' Name.Constant +'.' Operator +'current' Name +'[' Operator +'InspectKey' Name.Constant +']' Operator +' ' Text +'||' Operator +'=' Operator +' ' Text +'[' Operator +']' Operator +')' Punctuation +'\n\n ' Text +'if' Keyword +' ' Text +'ids' Name +'.' Operator +'include?' Name +'(' Punctuation +'object_id' Name.Builtin +')' Punctuation +'\n ' Text +'return' Keyword +' ' Text +'sprintf' Name.Builtin +'(' Punctuation +"'" Literal.String.Single +'#' Literal.String.Single +'<%s: {...}>' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +'self' Name.Builtin +'.' Operator +'class' Name +'.' Operator +'name' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'begin' Keyword +'\n ' Text +'ids' Name +' ' Text +'<<' Operator +' ' Text +'object_id' Name.Builtin +'\n ' Text +'return' Keyword +' ' Text +'sprintf' Name.Builtin +'(' Punctuation +"'" Literal.String.Single +'#' Literal.String.Single +'<%s: {%s}>' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +'self' Name.Builtin +'.' Operator +'class' Name +',' Punctuation +' ' Text +'to_a' Name.Builtin +'.' Operator +'inspect' Name +'[' Operator +'1' Literal.Number.Integer +'..' Operator +'-' Operator +'2' Literal.Number.Integer +']' Operator +')' Punctuation +'\n ' Text +'ensure' Keyword +'\n ' Text +'ids' Name +'.' Operator +'pop' Name +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'pretty_print' Name.Function +'(' Punctuation +'pp' Name +')' Punctuation +'\t' Text +'# :nodoc:' Comment.Single +'\n ' Text +'pp' Name +'.' Operator +'text' Name +' ' Text +'sprintf' Name.Builtin +'(' Punctuation +"'" Literal.String.Single +'#' Literal.String.Single +'<%s: {' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +'self' Name.Builtin +'.' Operator +'class' Name +'.' Operator +'name' Name +')' Punctuation +'\n ' Text +'pp' Name +'.' Operator +'nest' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'{' Punctuation +'\n ' Text +'pp' Name +'.' Operator +'seplist' Name +'(' Punctuation +'self' Name.Builtin +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'o' Name +'|' Operator +'\n\t' Text +'pp' Name +'.' Operator +'pp' Name +' ' Text +'o' Name +'\n ' Text +'}' Punctuation +'\n ' Text +'}' Punctuation +'\n ' Text +'pp' Name +'.' Operator +'text' Name +' ' Text +'"' Literal.String.Double +'}>' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'pretty_print_cycle' Name.Function +'(' Punctuation +'pp' Name +')' Punctuation +'\t' Text +'# :nodoc:' Comment.Single +'\n ' Text +'pp' Name +'.' Operator +'text' Name +' ' Text +'sprintf' Name.Builtin +'(' Punctuation +"'" Literal.String.Single +'#' Literal.String.Single +'<%s: {%s}>' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +'self' Name.Builtin +'.' Operator +'class' Name +'.' Operator +'name' Name +',' Punctuation +' ' Text +'empty?' Name +' ' Text +'?' Punctuation +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +' ' Text +':' Punctuation +' ' Text +"'" Literal.String.Single +'...' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'# SortedSet implements a set which elements are sorted in order. See Set.' Comment.Single +'\n' Text + +'class' Keyword +' ' Text +'SortedSet' Name.Class +' ' Text +'<' Operator +' ' Text +'Set' Name.Constant +'\n ' Text +'@@setup' Name.Variable.Class +' ' Text +'=' Operator +' ' Text +'false' Keyword.Pseudo +'\n\n ' Text +'class' Keyword +' ' Text +'<<' Operator +' ' Text +'self' Name.Builtin +'\n ' Text +'def' Keyword +' ' Text +'[]' Name.Function +'(' Punctuation +'*' Operator +'ary' Name +')' Punctuation +'\t' Text +'# :nodoc:' Comment.Single +'\n ' Text +'new' Keyword.Pseudo +'(' Punctuation +'ary' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'setup' Name.Function +'\t' Text +'# :nodoc:' Comment.Single +'\n ' Text +'@@setup' Name.Variable.Class +' ' Text +'and' Operator.Word +' ' Text +'return' Keyword +'\n\n ' Text +'begin' Keyword +'\n\t' Text +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'rbtree' Literal.String.Single +"'" Literal.String.Single +'\n\n\t' Text +'module_eval' Name.Builtin +' ' Text +'%{' Literal.String.Other +'\n\t def initialize(*args, &block)\n\t @hash = RBTree.new\n\t super\n\t end\n\t' Literal.String.Other +'}' Literal.String.Other +'\n ' Text +'rescue' Keyword +' ' Text +'LoadError' Name.Constant +'\n\t' Text +'module_eval' Name.Builtin +' ' Text +'%{' Literal.String.Other +'\n\t def initialize(*args, &block)\n\t @keys = nil\n\t super\n\t end\n\n\t def clear\n\t @keys = nil\n\t super\n\t end\n\n\t def replace(enum)\n\t @keys = nil\n\t super\n\t end\n\n\t def add(o)\n\t @keys = nil\n\t @hash[o] = true\n\t self\n\t end\n\t alias << add\n\n\t def delete(o)\n\t @keys = nil\n\t @hash.delete(o)\n\t self\n\t end\n\n\t def delete_if\n\t n = @hash.size\n\t @hash.delete_if ' Literal.String.Other +'{' Literal.String.Other +' |o,| yield(o) ' Literal.String.Other +'}' Literal.String.Other +'\n\t @keys = nil if @hash.size != n\n\t self\n\t end\n\n\t def merge(enum)\n\t @keys = nil\n\t super\n\t end\n\n\t def each\n\t to_a.each ' Literal.String.Other +'{' Literal.String.Other +' |o| yield(o) ' Literal.String.Other +'}' Literal.String.Other +'\n\t end\n\n\t def to_a\n\t (@keys = @hash.keys).sort! unless @keys\n\t @keys\n\t end\n\t' Literal.String.Other +'}' Literal.String.Other +'\n ' Text +'end' Keyword +'\n\n ' Text +'@@setup' Name.Variable.Class +' ' Text +'=' Operator +' ' Text +'true' Keyword.Pseudo +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'*' Operator +'args' Name +',' Punctuation +' ' Text +'&' Operator +'block' Name +')' Punctuation +'\t' Text +'# :nodoc:' Comment.Single +'\n ' Text +'SortedSet' Name.Constant +'.' Operator +'setup' Name +'\n ' Text +'initialize' Keyword.Pseudo +'(' Punctuation +'*' Operator +'args' Name +',' Punctuation +' ' Text +'&' Operator +'block' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'module' Keyword +' ' Text +'Enumerable' Name.Namespace +'\n ' Text +'# Makes a set from the enumerable object with given arguments.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'to_set' Name.Function +'(' Punctuation +'klass' Name +' ' Text +'=' Operator +' ' Text +'Set' Name.Constant +',' Punctuation +' ' Text +'*' Operator +'args' Name +',' Punctuation +' ' Text +'&' Operator +'block' Name +')' Punctuation +'\n ' Text +'klass' Name +'.' Operator +'new' Name +'(' Punctuation +'self' Name.Builtin +',' Punctuation +' ' Text +'*' Operator +'args' Name +',' Punctuation +' ' Text +'&' Operator +'block' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'# =begin' Comment.Single +'\n' Text + +'# == RestricedSet class' Comment.Single +'\n' Text + +'# RestricedSet implements a set with restrictions defined by a given' Comment.Single +'\n' Text + +'# block.' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# === Super class' Comment.Single +'\n' Text + +'# Set' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# === Class Methods' Comment.Single +'\n' Text + +'# --- RestricedSet::new(enum = nil) { |o| ... }' Comment.Single +'\n' Text + +'# --- RestricedSet::new(enum = nil) { |rset, o| ... }' Comment.Single +'\n' Text + +'# Creates a new restricted set containing the elements of the given' Comment.Single +'\n' Text + +'# enumerable object. Restrictions are defined by the given block.' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +"# If the block's arity is 2, it is called with the RestrictedSet" Comment.Single +'\n' Text + +'# itself and an object to see if the object is allowed to be put in' Comment.Single +'\n' Text + +'# the set.' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# Otherwise, the block is called with an object to see if the object' Comment.Single +'\n' Text + +'# is allowed to be put in the set.' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# === Instance Methods' Comment.Single +'\n' Text + +'# --- restriction_proc' Comment.Single +'\n' Text + +'# Returns the restriction procedure of the set.' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# =end' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# class RestricedSet < Set' Comment.Single +'\n' Text + +'# def initialize(*args, &block)' Comment.Single +'\n' Text + +'# @proc = block or raise ArgumentError, "missing a block"' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# if @proc.arity == 2' Comment.Single +'\n' Text + +'# instance_eval %{' Comment.Single +'\n' Text + +'# \tdef add(o)' Comment.Single +'\n' Text + +'# \t @hash[o] = true if @proc.call(self, o)' Comment.Single +'\n' Text + +'# \t self' Comment.Single +'\n' Text + +'# \tend' Comment.Single +'\n' Text + +'# \talias << add' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# \tdef add?(o)' Comment.Single +'\n' Text + +'# \t if include?(o) || !@proc.call(self, o)' Comment.Single +'\n' Text + +'# \t nil' Comment.Single +'\n' Text + +'# \t else' Comment.Single +'\n' Text + +'# \t @hash[o] = true' Comment.Single +'\n' Text + +'# \t self' Comment.Single +'\n' Text + +'# \t end' Comment.Single +'\n' Text + +'# \tend' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# \tdef replace(enum)' Comment.Single +'\n' Text + +'# \t enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"' Comment.Single +'\n' Text + +'# \t clear' Comment.Single +'\n' Text + +'# \t enum.each { |o| add(o) }' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# \t self' Comment.Single +'\n' Text + +'# \tend' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# \tdef merge(enum)' Comment.Single +'\n' Text + +'# \t enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"' Comment.Single +'\n' Text + +'# \t enum.each { |o| add(o) }' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# \t self' Comment.Single +'\n' Text + +'# \tend' Comment.Single +'\n' Text + +'# }' Comment.Single +'\n' Text + +'# else' Comment.Single +'\n' Text + +'# instance_eval %{' Comment.Single +'\n' Text + +'# \tdef add(o)' Comment.Single +'\n' Text + +'# if @proc.call(o)' Comment.Single +'\n' Text + +'# \t @hash[o] = true' Comment.Single +'\n' Text + +'# end' Comment.Single +'\n' Text + +'# \t self' Comment.Single +'\n' Text + +'# \tend' Comment.Single +'\n' Text + +'# \talias << add' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# \tdef add?(o)' Comment.Single +'\n' Text + +'# \t if include?(o) || !@proc.call(o)' Comment.Single +'\n' Text + +'# \t nil' Comment.Single +'\n' Text + +'# \t else' Comment.Single +'\n' Text + +'# \t @hash[o] = true' Comment.Single +'\n' Text + +'# \t self' Comment.Single +'\n' Text + +'# \t end' Comment.Single +'\n' Text + +'# \tend' Comment.Single +'\n' Text + +'# }' Comment.Single +'\n' Text + +'# end' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# super(*args)' Comment.Single +'\n' Text + +'# end' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# def restriction_proc' Comment.Single +'\n' Text + +'# @proc' Comment.Single +'\n' Text + +'# end' Comment.Single +'\n' Text + +'# end' Comment.Single +'\n\n' Text + +'if' Keyword +' ' Text +'$0' Name.Variable.Global +' ' Text +'==' Operator +' ' Text +'__FILE__' Name.Builtin.Pseudo +'\n ' Text +'eval' Name.Builtin +' ' Text +'DATA' Name.Constant +'.' Operator +'read' Name +',' Punctuation +' ' Text +'nil' Keyword.Pseudo +',' Punctuation +' ' Text +'$0' Name.Variable.Global +',' Punctuation +' ' Text +'__LINE__' Name.Builtin.Pseudo +'+' Operator +'4' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'# = rweb - CGI Support Library' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# Author:: Johannes Barre (mailto:rweb@igels.net)' Comment.Single +'\n' Text + +'# Copyright:: Copyright (c) 2003, 04 by Johannes Barre' Comment.Single +'\n' Text + +'# License:: GNU Lesser General Public License (COPYING, http://www.gnu.org/copyleft/lesser.html)' Comment.Single +'\n' Text + +'# Version:: 0.1.0' Comment.Single +'\n' Text + +'# CVS-ID:: $Id: example.rb 39 2005-11-05 03:33:55Z murphy $' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# == What is Rweb?' Comment.Single +'\n' Text + +'# Rweb is a replacement for the cgi class included in the ruby distribution.' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# == How to use' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# === Basics' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# This class is made to be as easy as possible to use. An example:' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# \trequire "rweb"' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# \tweb = Rweb.new' Comment.Single +'\n' Text + +'# \tweb.out do' Comment.Single +'\n' Text + +'# \t\tweb.puts "Hello world!"' Comment.Single +'\n' Text + +'# \tend' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# The visitor will get a simple "Hello World!" in his browser. Please notice,' Comment.Single +'\n' Text + +"# that won't set html-tags for you, so you should better do something like this:" Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# \trequire "rweb"' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# \tweb = Rweb.new' Comment.Single +'\n' Text + +'# \tweb.out do' Comment.Single +'\n' Text + +'# \t\tweb.puts "<html><body>Hello world!</body></html>"' Comment.Single +'\n' Text + +'# \tend' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# === Set headers' Comment.Single +'\n' Text + +"# Of course, it's also possible to tell the browser, that the content of this" Comment.Single +'\n' Text + +'# page is plain text instead of html code:' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# \trequire "rweb"' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# \tweb = Rweb.new' Comment.Single +'\n' Text + +'# \tweb.out do' Comment.Single +'\n' Text + +'# \t\tweb.header("content-type: text/plain")' Comment.Single +'\n' Text + +'# \t\tweb.puts "Hello plain world!"' Comment.Single +'\n' Text + +'# \tend' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +"# Please remember, headers can't be set after the page content has been send." Comment.Single +'\n' Text + +"# You have to set all nessessary headers before the first puts oder print. It's" Comment.Single +'\n' Text + +'# possible to cache the content until everything is complete. Doing it this' Comment.Single +'\n' Text + +'# way, you can set headers everywhere.' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# If you set a header twice, the second header will replace the first one. The' Comment.Single +'\n' Text + +'# header name is not casesensitive, it will allways converted in to the' Comment.Single +'\n' Text + +'# capitalised form suggested by the w3c (http://w3.org)' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# === Set cookies' Comment.Single +'\n' Text + +'# Setting cookies is quite easy:' Comment.Single +'\n' Text + +"# \tinclude 'rweb'" Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# \tweb = Rweb.new' Comment.Single +'\n' Text + +'# \tCookie.new("Visits", web.cookies[\'visits\'].to_i +1)' Comment.Single +'\n' Text + +'# \tweb.out do' Comment.Single +'\n' Text + +'# \t\tweb.puts "Welcome back! You visited this page #{web.cookies[\'visits\'].to_i +1} times"' Comment.Single +'\n' Text + +'# \tend' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# See the class Cookie for more details.' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# === Get form and cookie values' Comment.Single +'\n' Text + +'# There are four ways to submit data from the browser to the server and your' Comment.Single +'\n' Text + +"# ruby script: via GET, POST, cookies and file upload. Rweb doesn't support" Comment.Single +'\n' Text + +'# file upload by now.' Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +"# \tinclude 'rweb'" Comment.Single +'\n' Text + +'#' Comment.Single +'\n' Text + +'# \tweb = Rweb.new' Comment.Single +'\n' Text + +'# \tweb.out do' Comment.Single +'\n' Text + +'# \t\tweb.print "action: #{web.get[\'action\']} "' Comment.Single +'\n' Text + +'# \t\tweb.puts "The value of the cookie \'visits\' is #{web.cookies[\'visits\']}"' Comment.Single +'\n' Text + +'# \t\tweb.puts "The post parameter \'test[\'x\']\' is #{web.post[\'test\'][\'x\']}"' Comment.Single +'\n' Text + +'# \tend' Comment.Single +'\n\n' Text + +'RWEB_VERSION' Name.Constant +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'0.1.0' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'RWEB' Name.Constant +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'rweb/' Literal.String.Double +'#{' Literal.String.Interpol +'RWEB_VERSION' Name.Constant +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n\n' Text + +"#require 'rwebcookie' -> edit by bunny :-)" Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Rweb' Name.Class +'\n ' Text +'# All parameter submitted via the GET method are available in attribute' Comment.Single +'\n\t\t' Text +'# get. This is Hash, where every parameter is available as a key-value' Comment.Single +'\n\t\t' Text +'# pair.' Comment.Single +'\n\t\t' Text +'#' Comment.Single +'\n\t\t' Text +"# If your input tag has a name like this one, it's value will be available" Comment.Single +'\n\t\t' Text +'# as web.get["fieldname"]' Comment.Single +'\n\t\t' Text +'# <input name="fieldname">' Comment.Single +'\n\t\t' Text +'# You can submit values as a Hash' Comment.Single +'\n\t\t' Text +'# <input name="text[\'index\']">' Comment.Single +'\n\t\t' Text +'# <input name="text[\'index2\']">' Comment.Single +'\n\t\t' Text +'# will be available as' Comment.Single +'\n\t\t' Text +'# web.get["text"]["index"]' Comment.Single +'\n\t\t' Text +'# web.get["text"]["index2"]' Comment.Single +'\n\t\t' Text +'# Integers are also possible' Comment.Single +'\n\t\t' Text +'# <input name="int[2]">' Comment.Single +'\n\t\t' Text +'# <input name="int[3][\'hi\']>' Comment.Single +'\n\t\t' Text +'# will be available as' Comment.Single +'\n\t\t' Text +'# web.get["int"][2]' Comment.Single +'\n\t\t' Text +'# web.get["int"][3]["hi"]' Comment.Single +'\n\t\t' Text +'# If you specify no index, the lowest unused index will be used:' Comment.Single +'\n\t\t' Text +'# <input name="int[]"><!-- First Field -->' Comment.Single +'\n\t\t' Text +'# <input name="int[]"><!-- Second one -->' Comment.Single +'\n\t\t' Text +'# will be available as' Comment.Single +'\n\t\t' Text +'# web.get["int"][0] # First Field' Comment.Single +'\n\t\t' Text +'# web.get["int"][1] # Second one' Comment.Single +'\n\t\t' Text +"# Please notice, this doesn'd work like you might expect:" Comment.Single +'\n\t\t' Text +'# <input name="text[index]">' Comment.Single +'\n\t\t' Text +'# It will not be available as web.get["text"]["index"] but' Comment.Single +'\n\t\t' Text +'# web.get["text[index]"]' Comment.Single +'\n ' Text +'attr_reader' Keyword.Pseudo +' ' Text +':get' Literal.String.Symbol +'\n\n ' Text +'# All parameters submitted via POST are available in the attribute post. It' Comment.Single +'\n\t\t' Text +'# works like the get attribute.' Comment.Single +'\n\t\t' Text +'# <input name="text[0]">' Comment.Single +'\n\t\t' Text +'# will be available as' Comment.Single +'\n\t\t' Text +'# web.post["text"][0]' Comment.Single +'\n\t\t' Text +'attr_reader' Keyword.Pseudo +' ' Text +':post' Literal.String.Symbol +'\n\n ' Text +'# All cookies submitted by the browser are available in cookies. This is a' Comment.Single +'\n\t\t' Text +'# Hash, where every cookie is a key-value pair.' Comment.Single +'\n\t\t' Text +'attr_reader' Keyword.Pseudo +' ' Text +':cookies' Literal.String.Symbol +'\n\n ' Text +'# The name of the browser identification is submitted as USER_AGENT and' Comment.Single +'\n\t\t' Text +'# available in this attribute.' Comment.Single +'\n\t\t' Text +'attr_reader' Keyword.Pseudo +' ' Text +':user_agent' Literal.String.Symbol +'\n\n ' Text +'# The IP address of the client.' Comment.Single +'\n\t\t' Text +'attr_reader' Keyword.Pseudo +' ' Text +':remote_addr' Literal.String.Symbol +'\n\n ' Text +'# Creates a new Rweb object. This should only done once. You can set various' Comment.Single +'\n ' Text +'# options via the settings hash.' Comment.Single +'\n ' Text +'#' Comment.Single +'\n ' Text +'# "cache" => true: Everything you script send to the client will be cached' Comment.Single +'\n ' Text +'# until the end of the out block or until flush is called. This way, you' Comment.Single +'\n ' Text +'# can modify headers and cookies even after printing something to the client.' Comment.Single +'\n ' Text +'#' Comment.Single +'\n ' Text +'# "safe" => level: Changes the $SAFE attribute. By default, $SAFE will be set' Comment.Single +'\n ' Text +"# to 1. If $SAFE is already higher than this value, it won't be changed." Comment.Single +'\n ' Text +'#' Comment.Single +'\n ' Text +'# "silend" => true: Normaly, Rweb adds automaticly a header like this' Comment.Single +'\n ' Text +'# "X-Powered-By: Rweb/x.x.x (Ruby/y.y.y)". With the silend option you can' Comment.Single +'\n ' Text +'# suppress this.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +' ' Text +'(' Punctuation +'settings' Name +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'}' Punctuation +')' Punctuation +'\n ' Text +'# {{{' Comment.Single +'\n ' Text +'@header' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'}' Punctuation +'\n ' Text +'@cookies' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'}' Punctuation +'\n ' Text +'@get' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'}' Punctuation +'\n ' Text +'@post' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'}' Punctuation +'\n\n ' Text +'# Internal attributes' Comment.Single +'\n ' Text +'@status' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Pseudo +'\n ' Text +'@reasonPhrase' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Pseudo +'\n ' Text +'@setcookies' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +'\n ' Text +'@output_started' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'false' Keyword.Pseudo +';' Punctuation +'\n ' Text +'@output_allowed' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'false' Keyword.Pseudo +';' Punctuation +'\n\n ' Text +'@mod_ruby' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'false' Keyword.Pseudo +'\n ' Text +'@env' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'ENV' Name.Constant +'.' Operator +'to_hash' Name +'\n\n ' Text +'if' Keyword +' ' Text +'defined?' Name +'(' Punctuation +'MOD_RUBY' Name.Constant +')' Punctuation +'\n ' Text +'@output_method' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'mod_ruby' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'@mod_ruby' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'true' Keyword.Pseudo +'\n ' Text +'elsif' Keyword +' ' Text +'@env' Name.Variable.Instance +'[' Operator +"'" Literal.String.Single +'SERVER_SOFTWARE' Literal.String.Single +"'" Literal.String.Single +']' Operator +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^Microsoft-IIS' Literal.String.Regex +'/i' Literal.String.Regex +'\n ' Text +'@output_method' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'nph' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'else' Keyword +'\n ' Text +'@output_method' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'ph' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n\n ' Text +'unless' Keyword +' ' Text +'settings' Name +'.' Operator +'is_a?' Name +'(' Punctuation +'Hash' Name.Constant +')' Punctuation +'\n ' Text +'raise' Keyword +' ' Text +'TypeError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'settings must be a Hash' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n ' Text +'@settings' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'settings' Name +'\n\n ' Text +'unless' Keyword +' ' Text +'@settings' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +'"' Literal.String.Double +'safe' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'@settings' Name.Variable.Instance +'[' Operator +'"' Literal.String.Double +'safe' Literal.String.Double +'"' Literal.String.Double +']' Operator +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n\n ' Text +'if' Keyword +' ' Text +'$SAFE' Name.Variable.Global +' ' Text +'<' Operator +' ' Text +'@settings' Name.Variable.Instance +'[' Operator +'"' Literal.String.Double +'safe' Literal.String.Double +'"' Literal.String.Double +']' Operator +'\n ' Text +'$SAFE' Name.Variable.Global +' ' Text +'=' Operator +' ' Text +'@settings' Name.Variable.Instance +'[' Operator +'"' Literal.String.Double +'safe' Literal.String.Double +'"' Literal.String.Double +']' Operator +'\n ' Text +'end' Keyword +'\n\n ' Text +'unless' Keyword +' ' Text +'@settings' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +'"' Literal.String.Double +'cache' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'@settings' Name.Variable.Instance +'[' Operator +'"' Literal.String.Double +'cache' Literal.String.Double +'"' Literal.String.Double +']' Operator +' ' Text +'=' Operator +' ' Text +'false' Keyword.Pseudo +'\n ' Text +'end' Keyword +'\n\n ' Text +'# mod_ruby sets no QUERY_STRING variable, if no GET-Parameters are given' Comment.Single +'\n ' Text +'unless' Keyword +' ' Text +'@env' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +'"' Literal.String.Double +'QUERY_STRING' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'@env' Name.Variable.Instance +'[' Operator +'"' Literal.String.Double +'QUERY_STRING' Literal.String.Double +'"' Literal.String.Double +']' Operator +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Now we split the QUERY_STRING by the seperators & and ; or, if' Comment.Single +'\n ' Text +"# specified, settings['get seperator']" Comment.Single +'\n ' Text +'unless' Keyword +' ' Text +'@settings' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +'"' Literal.String.Double +'get seperator' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'get_args' Name +' ' Text +'=' Operator +' ' Text +'@env' Name.Variable.Instance +'[' Operator +"'" Literal.String.Single +'QUERY_STRING' Literal.String.Single +"'" Literal.String.Single +']' Operator +'.' Operator +'split' Name +'(' Punctuation +'/' Literal.String.Regex +'[&;]' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'\n ' Text +'else' Keyword +'\n ' Text +'get_args' Name +' ' Text +'=' Operator +' ' Text +'@env' Name.Variable.Instance +'[' Operator +"'" Literal.String.Single +'QUERY_STRING' Literal.String.Single +"'" Literal.String.Single +']' Operator +'.' Operator +'split' Name +'(' Punctuation +'@settings' Name.Variable.Instance +'[' Operator +"'" Literal.String.Single +'get seperator' Literal.String.Single +"'" Literal.String.Single +']' Operator +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'get_args' Name +'.' Operator +'each' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +' ' Text +'arg' Name +' ' Text +'|' Operator +'\n ' Text +'arg_key' Name +',' Punctuation +' ' Text +'arg_val' Name +' ' Text +'=' Operator +' ' Text +'arg' Name +'.' Operator +'split' Name +'(' Punctuation +'/' Literal.String.Regex +'=' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +'\n ' Text +'arg_key' Name +' ' Text +'=' Operator +' ' Text +'Rweb' Name.Constant +'::' Operator +'unescape' Name +'(' Punctuation +'arg_key' Name +')' Punctuation +'\n ' Text +'arg_val' Name +' ' Text +'=' Operator +' ' Text +'Rweb' Name.Constant +'::' Operator +'unescape' Name +'(' Punctuation +'arg_val' Name +')' Punctuation +'\n\n ' Text +"# Parse names like name[0], name['text'] or name[]" Comment.Single +'\n ' Text +'pattern' Name +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'^(.+)' Literal.String.Regex +'\\' Literal.String.Regex +'[("[^' Literal.String.Regex +'\\' Literal.String.Regex +']]*"|\'[^' Literal.String.Regex +'\\' Literal.String.Regex +"]]*'|[0-9]*)" Literal.String.Regex +'\\' Literal.String.Regex +']$' Literal.String.Regex +'/' Literal.String.Regex +'\n ' Text +'keys' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +'\n ' Text +'while' Keyword +' ' Text +'match' Name +' ' Text +'=' Operator +' ' Text +'pattern' Name +'.' Operator +'match' Name +'(' Punctuation +'arg_key' Name +')' Punctuation +'\n ' Text +'arg_key' Name +' ' Text +'=' Operator +' ' Text +'match' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +'\n ' Text +'keys' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +'match' Name +'[' Operator +'2' Literal.Number.Integer +']' Operator +']' Operator +' ' Text +'+' Operator +' ' Text +'keys' Name +'\n ' Text +'end' Keyword +'\n ' Text +'keys' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +'arg_key' Name +']' Operator +' ' Text +'+' Operator +' ' Text +'keys' Name +'\n\n ' Text +'akt' Name +' ' Text +'=' Operator +' ' Text +'@get' Name.Variable.Instance +'\n ' Text +'last' Name +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Pseudo +'\n ' Text +'lastkey' Name +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Pseudo +'\n ' Text +'keys' Name +'.' Operator +'each' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'key' Name +'|' Operator +'\n ' Text +'if' Keyword +' ' Text +'key' Name +' ' Text +'==' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'# No key specified (like in "test[]"), so we use the' Comment.Single +'\n ' Text +'# lowerst unused Integer as key' Comment.Single +'\n ' Text +'key' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'while' Keyword +' ' Text +'akt' Name +'.' Operator +'has_key?' Name +'(' Punctuation +'key' Name +')' Punctuation +'\n ' Text +'key' Name +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n ' Text +'elsif' Keyword +' ' Text +'/' Literal.String.Regex +'^[0-9]*$' Literal.String.Regex +'/' Literal.String.Regex +' ' Text +'=~' Operator +' ' Text +'key' Name +'\n ' Text +'# If the index is numerical convert it to an Integer' Comment.Single +'\n ' Text +'key' Name +' ' Text +'=' Operator +' ' Text +'key' Name +'.' Operator +'to_i' Name +'\n ' Text +'elsif' Keyword +' ' Text +'key' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +'.' Operator +'chr' Name +' ' Text +'==' Operator +' ' Text +'"' Literal.String.Double +"'" Literal.String.Double +'"' Literal.String.Double +' ' Text +'||' Operator +' ' Text +'key' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +'.' Operator +'chr' Name +' ' Text +'==' Operator +' ' Text +"'" Literal.String.Single +'"' Literal.String.Single +"'" Literal.String.Single +'\n ' Text +'key' Name +' ' Text +'=' Operator +' ' Text +'key' Name +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'key' Name +'.' Operator +'length' Name +'(' Punctuation +')' Punctuation +' ' Text +'-' Operator +'2' Literal.Number.Integer +']' Operator +'\n ' Text +'end' Keyword +'\n ' Text +'if' Keyword +' ' Text +'!' Operator +'akt' Name +'.' Operator +'has_key?' Name +'(' Punctuation +'key' Name +')' Punctuation +' ' Text +'||' Operator +' ' Text +'!' Operator +'akt' Name +'[' Operator +'key' Name +']' Operator +'.' Operator +'class' Name +' ' Text +'==' Operator +' ' Text +'Hash' Name.Constant +'\n ' Text +"# create an empty Hash if there isn't already one" Comment.Single +'\n ' Text +'akt' Name +'[' Operator +'key' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'}' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'last' Name +' ' Text +'=' Operator +' ' Text +'akt' Name +'\n ' Text +'lastkey' Name +' ' Text +'=' Operator +' ' Text +'key' Name +'\n ' Text +'akt' Name +' ' Text +'=' Operator +' ' Text +'akt' Name +'[' Operator +'key' Name +']' Operator +'\n ' Text +'end' Keyword +'\n ' Text +'last' Name +'[' Operator +'lastkey' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'arg_val' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'if' Keyword +' ' Text +'@env' Name.Variable.Instance +'[' Operator +"'" Literal.String.Single +'REQUEST_METHOD' Literal.String.Single +"'" Literal.String.Single +']' Operator +' ' Text +'==' Operator +' ' Text +'"' Literal.String.Double +'POST' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'if' Keyword +' ' Text +'@env' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +'"' Literal.String.Double +'CONTENT_TYPE' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'&&' Operator +' ' Text +'@env' Name.Variable.Instance +'[' Operator +"'" Literal.String.Single +'CONTENT_TYPE' Literal.String.Single +"'" Literal.String.Single +']' Operator +' ' Text +'==' Operator +' ' Text +'"' Literal.String.Double +'application/x-www-form-urlencoded' Literal.String.Double +'"' Literal.String.Double +' ' Text +'&&' Operator +' ' Text +'@env' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +"'" Literal.String.Single +'CONTENT_LENGTH' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n ' Text +'unless' Keyword +' ' Text +'@settings' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +'"' Literal.String.Double +'post seperator' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'post_args' Name +' ' Text +'=' Operator +' ' Text +'$stdin' Name.Variable.Global +'.' Operator +'read' Name +'(' Punctuation +'@env' Name.Variable.Instance +'[' Operator +"'" Literal.String.Single +'CONTENT_LENGTH' Literal.String.Single +"'" Literal.String.Single +']' Operator +'.' Operator +'to_i' Name +')' Punctuation +'.' Operator +'split' Name +'(' Punctuation +'/' Literal.String.Regex +'[&;]' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'\n ' Text +'else' Keyword +'\n ' Text +'post_args' Name +' ' Text +'=' Operator +' ' Text +'$stdin' Name.Variable.Global +'.' Operator +'read' Name +'(' Punctuation +'@env' Name.Variable.Instance +'[' Operator +"'" Literal.String.Single +'CONTENT_LENGTH' Literal.String.Single +"'" Literal.String.Single +']' Operator +'.' Operator +'to_i' Name +')' Punctuation +'.' Operator +'split' Name +'(' Punctuation +'@settings' Name.Variable.Instance +'[' Operator +"'" Literal.String.Single +'post seperator' Literal.String.Single +"'" Literal.String.Single +']' Operator +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'post_args' Name +'.' Operator +'each' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +' ' Text +'arg' Name +' ' Text +'|' Operator +'\n ' Text +'arg_key' Name +',' Punctuation +' ' Text +'arg_val' Name +' ' Text +'=' Operator +' ' Text +'arg' Name +'.' Operator +'split' Name +'(' Punctuation +'/' Literal.String.Regex +'=' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +'\n ' Text +'arg_key' Name +' ' Text +'=' Operator +' ' Text +'Rweb' Name.Constant +'::' Operator +'unescape' Name +'(' Punctuation +'arg_key' Name +')' Punctuation +'\n ' Text +'arg_val' Name +' ' Text +'=' Operator +' ' Text +'Rweb' Name.Constant +'::' Operator +'unescape' Name +'(' Punctuation +'arg_val' Name +')' Punctuation +'\n\n ' Text +"# Parse names like name[0], name['text'] or name[]" Comment.Single +'\n ' Text +'pattern' Name +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'^(.+)' Literal.String.Regex +'\\' Literal.String.Regex +'[("[^' Literal.String.Regex +'\\' Literal.String.Regex +']]*"|\'[^' Literal.String.Regex +'\\' Literal.String.Regex +"]]*'|[0-9]*)" Literal.String.Regex +'\\' Literal.String.Regex +']$' Literal.String.Regex +'/' Literal.String.Regex +'\n ' Text +'keys' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +'\n ' Text +'while' Keyword +' ' Text +'match' Name +' ' Text +'=' Operator +' ' Text +'pattern' Name +'.' Operator +'match' Name +'(' Punctuation +'arg_key' Name +')' Punctuation +'\n ' Text +'arg_key' Name +' ' Text +'=' Operator +' ' Text +'match' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +'\n ' Text +'keys' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +'match' Name +'[' Operator +'2' Literal.Number.Integer +']' Operator +']' Operator +' ' Text +'+' Operator +' ' Text +'keys' Name +'\n ' Text +'end' Keyword +'\n ' Text +'keys' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +'arg_key' Name +']' Operator +' ' Text +'+' Operator +' ' Text +'keys' Name +'\n\n ' Text +'akt' Name +' ' Text +'=' Operator +' ' Text +'@post' Name.Variable.Instance +'\n ' Text +'last' Name +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Pseudo +'\n ' Text +'lastkey' Name +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Pseudo +'\n ' Text +'keys' Name +'.' Operator +'each' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'key' Name +'|' Operator +'\n ' Text +'if' Keyword +' ' Text +'key' Name +' ' Text +'==' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'# No key specified (like in "test[]"), so we use' Comment.Single +'\n ' Text +'# the lowerst unused Integer as key' Comment.Single +'\n ' Text +'key' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'while' Keyword +' ' Text +'akt' Name +'.' Operator +'has_key?' Name +'(' Punctuation +'key' Name +')' Punctuation +'\n ' Text +'key' Name +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n ' Text +'elsif' Keyword +' ' Text +'/' Literal.String.Regex +'^[0-9]*$' Literal.String.Regex +'/' Literal.String.Regex +' ' Text +'=~' Operator +' ' Text +'key' Name +'\n ' Text +'# If the index is numerical convert it to an Integer' Comment.Single +'\n ' Text +'key' Name +' ' Text +'=' Operator +' ' Text +'key' Name +'.' Operator +'to_i' Name +'\n ' Text +'elsif' Keyword +' ' Text +'key' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +'.' Operator +'chr' Name +' ' Text +'==' Operator +' ' Text +'"' Literal.String.Double +"'" Literal.String.Double +'"' Literal.String.Double +' ' Text +'||' Operator +' ' Text +'key' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +'.' Operator +'chr' Name +' ' Text +'==' Operator +' ' Text +"'" Literal.String.Single +'"' Literal.String.Single +"'" Literal.String.Single +'\n ' Text +'key' Name +' ' Text +'=' Operator +' ' Text +'key' Name +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'key' Name +'.' Operator +'length' Name +'(' Punctuation +')' Punctuation +' ' Text +'-' Operator +'2' Literal.Number.Integer +']' Operator +'\n ' Text +'end' Keyword +'\n ' Text +'if' Keyword +' ' Text +'!' Operator +'akt' Name +'.' Operator +'has_key?' Name +'(' Punctuation +'key' Name +')' Punctuation +' ' Text +'||' Operator +' ' Text +'!' Operator +'akt' Name +'[' Operator +'key' Name +']' Operator +'.' Operator +'class' Name +' ' Text +'==' Operator +' ' Text +'Hash' Name.Constant +'\n ' Text +"# create an empty Hash if there isn't already one" Comment.Single +'\n ' Text +'akt' Name +'[' Operator +'key' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'}' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'last' Name +' ' Text +'=' Operator +' ' Text +'akt' Name +'\n ' Text +'lastkey' Name +' ' Text +'=' Operator +' ' Text +'key' Name +'\n ' Text +'akt' Name +' ' Text +'=' Operator +' ' Text +'akt' Name +'[' Operator +'key' Name +']' Operator +'\n ' Text +'end' Keyword +'\n ' Text +'last' Name +'[' Operator +'lastkey' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'arg_val' Name +'\n ' Text +'end' Keyword +'\n ' Text +'else' Keyword +'\n ' Text +'# Maybe we should print a warning here?' Comment.Single +'\n ' Text +'$stderr' Name.Variable.Global +'.' Operator +'print' Name +'(' Punctuation +'"' Literal.String.Double +'Unidentified form data recived and discarded.' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'if' Keyword +' ' Text +'@env' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +'"' Literal.String.Double +'HTTP_COOKIE' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'cookie' Name +' ' Text +'=' Operator +' ' Text +'@env' Name.Variable.Instance +'[' Operator +"'" Literal.String.Single +'HTTP_COOKIE' Literal.String.Single +"'" Literal.String.Single +']' Operator +'.' Operator +'split' Name +'(' Punctuation +'/' Literal.String.Regex +'; ?' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'\n ' Text +'cookie' Name +'.' Operator +'each' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +' ' Text +'c' Name +' ' Text +'|' Operator +'\n ' Text +'cookie_key' Name +',' Punctuation +' ' Text +'cookie_val' Name +' ' Text +'=' Operator +' ' Text +'c' Name +'.' Operator +'split' Name +'(' Punctuation +'/' Literal.String.Regex +'=' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +'\n\n ' Text +'@cookies' Name.Variable.Instance +' ' Text +'[' Operator +'Rweb' Name.Constant +'::' Operator +'unescape' Name +'(' Punctuation +'cookie_key' Name +')' Punctuation +']' Operator +' ' Text +'=' Operator +' ' Text +'Rweb' Name.Constant +'::' Operator +'unescape' Name +'(' Punctuation +'cookie_val' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'if' Keyword +' ' Text +'defined?' Name +'(' Punctuation +'@env' Name.Variable.Instance +'[' Operator +"'" Literal.String.Single +'HTTP_USER_AGENT' Literal.String.Single +"'" Literal.String.Single +']' Operator +')' Punctuation +'\n ' Text +'@user_agent' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'@env' Name.Variable.Instance +'[' Operator +"'" Literal.String.Single +'HTTP_USER_AGENT' Literal.String.Single +"'" Literal.String.Single +']' Operator +'\n ' Text +'else' Keyword +'\n ' Text +'@user_agent' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Pseudo +';' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'if' Keyword +' ' Text +'defined?' Name +'(' Punctuation +'@env' Name.Variable.Instance +'[' Operator +"'" Literal.String.Single +'REMOTE_ADDR' Literal.String.Single +"'" Literal.String.Single +']' Operator +')' Punctuation +'\n ' Text +'@remote_addr' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'@env' Name.Variable.Instance +'[' Operator +"'" Literal.String.Single +'REMOTE_ADDR' Literal.String.Single +"'" Literal.String.Single +']' Operator +'\n ' Text +'else' Keyword +'\n ' Text +'@remote_addr' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Pseudo +'\n ' Text +'end' Keyword +'\n ' Text +'# }}}' Comment.Single +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Prints a String to the client. If caching is enabled, the String will' Comment.Single +'\n ' Text +'# buffered until the end of the out block ends.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'print' Name.Function +'(' Punctuation +'str' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'# {{{' Comment.Single +'\n ' Text +'unless' Keyword +' ' Text +'@output_allowed' Name.Variable.Instance +'\n ' Text +'raise' Keyword +' ' Text +'"' Literal.String.Double +'You just can write to output inside of a Rweb::out-block' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n\n ' Text +'if' Keyword +' ' Text +'@settings' Name.Variable.Instance +'[' Operator +'"' Literal.String.Double +'cache' Literal.String.Double +'"' Literal.String.Double +']' Operator +'\n ' Text +'@buffer' Name.Variable.Instance +' ' Text +'+=' Operator +' ' Text +'[' Operator +'str' Name +'.' Operator +'to_s' Name +']' Operator +'\n ' Text +'else' Keyword +'\n ' Text +'unless' Keyword +' ' Text +'@output_started' Name.Variable.Instance +'\n ' Text +'sendHeaders' Name +'\n ' Text +'end' Keyword +'\n ' Text +'$stdout' Name.Variable.Global +'.' Operator +'print' Name +'(' Punctuation +'str' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'nil' Keyword.Pseudo +'\n ' Text +'# }}}' Comment.Single +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Prints a String to the client and adds a line break at the end. Please' Comment.Single +'\n\t\t' Text +'# remember, that a line break is not visible in HTML, use the <br> HTML-Tag' Comment.Single +'\n\t\t' Text +'# for this. If caching is enabled, the String will buffered until the end' Comment.Single +'\n\t\t' Text +'# of the out block ends.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'puts' Name.Function +'(' Punctuation +'str' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'# {{{' Comment.Single +'\n ' Text +'self' Name.Builtin +'.' Operator +'print' Name +'(' Punctuation +'str' Name +' ' Text +'+' Operator +' ' Text +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'# }}}' Comment.Single +'\n ' Text +'end' Keyword +'\n\n\t\t' Text +'# Alias to print.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'write' Name.Function +'(' Punctuation +'str' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'# {{{' Comment.Single +'\n ' Text +'self' Name.Builtin +'.' Operator +'print' Name +'(' Punctuation +'str' Name +')' Punctuation +'\n ' Text +'# }}}' Comment.Single +'\n ' Text +'end' Keyword +'\n\n ' Text +'# If caching is enabled, all cached data are send to the cliend and the' Comment.Single +'\n\t\t' Text +'# cache emptied.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'flush' Name.Function +'\n ' Text +'# {{{' Comment.Single +'\n ' Text +'unless' Keyword +' ' Text +'@output_allowed' Name.Variable.Instance +'\n ' Text +'raise' Keyword +' ' Text +'"' Literal.String.Double +"You can't use flush outside of a Rweb::out-block" Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n ' Text +'buffer' Name +' ' Text +'=' Operator +' ' Text +'@buffer' Name.Variable.Instance +'.' Operator +'join' Name +'\n\n ' Text +'unless' Keyword +' ' Text +'@output_started' Name.Variable.Instance +'\n ' Text +'sendHeaders' Name +'\n ' Text +'end' Keyword +'\n ' Text +'$stdout' Name.Variable.Global +'.' Operator +'print' Name +'(' Punctuation +'buffer' Name +')' Punctuation +'\n\n ' Text +'@buffer' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +'\n ' Text +'# }}}' Comment.Single +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Sends one or more header to the client. All headers are cached just' Comment.Single +'\n\t\t' Text +'# before body data are send to the client. If the same header are set' Comment.Single +'\n\t\t' Text +'# twice, only the last value is send.' Comment.Single +'\n\t\t' Text +'#' Comment.Single +'\n\t\t' Text +'# Example:' Comment.Single +'\n\t\t' Text +'# web.header("Last-Modified: Mon, 16 Feb 2004 20:15:41 GMT")' Comment.Single +'\n\t\t' Text +'# web.header("Location: http://www.ruby-lang.org")' Comment.Single +'\n\t\t' Text +'#' Comment.Single +'\n\t\t' Text +'# You can specify more than one header at the time by doing something like' Comment.Single +'\n\t\t' Text +'# this:' Comment.Single +'\n\t\t' Text +'# web.header("Content-Type: text/plain\\nContent-Length: 383")' Comment.Single +'\n\t\t' Text +'# or' Comment.Single +'\n\t\t' Text +'# web.header(["Content-Type: text/plain", "Content-Length: 383"])' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'header' Name.Function +'(' Punctuation +'str' Name +')' Punctuation +'\n ' Text +'# {{{' Comment.Single +'\n ' Text +'if' Keyword +' ' Text +'@output_started' Name.Variable.Instance +'\n ' Text +'raise' Keyword +' ' Text +'"' Literal.String.Double +"HTTP-Headers are already send. You can't change them after output has started!" Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n ' Text +'unless' Keyword +' ' Text +'@output_allowed' Name.Variable.Instance +'\n ' Text +'raise' Keyword +' ' Text +'"' Literal.String.Double +'You just can set headers inside of a Rweb::out-block' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n ' Text +'if' Keyword +' ' Text +'str' Name +'.' Operator +'is_a?' Name +'Array' Name.Builtin +'\n ' Text +'str' Name +'.' Operator +'each' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +' ' Text +'value' Name +' ' Text +'|' Operator +'\n ' Text +'self' Name.Builtin +'.' Operator +'header' Name +'(' Punctuation +'value' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'elsif' Keyword +' ' Text +'str' Name +'.' Operator +'split' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'n' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'.' Operator +'length' Name +' ' Text +'>' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'str' Name +'.' Operator +'split' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'n' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'.' Operator +'each' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +' ' Text +'value' Name +' ' Text +'|' Operator +'\n ' Text +'self' Name.Builtin +'.' Operator +'header' Name +'(' Punctuation +'value' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'elsif' Keyword +' ' Text +'str' Name +'.' Operator +'is_a?' Name +' ' Text +'String' Name.Builtin +'\n ' Text +'str' Name +'.' Operator +'gsub!' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'r' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n ' Text +'if' Keyword +' ' Text +'(' Punctuation +'str' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^HTTP' Literal.String.Regex +'\\/' Literal.String.Regex +'1' Literal.String.Regex +'\\' Literal.String.Regex +'.[01] [0-9]{3} ?.*$' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'==' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'pattern' Name +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'^HTTP' Literal.String.Regex +'\\/' Literal.String.Regex +'1.[01] ([0-9]{3}) ?(.*)$' Literal.String.Regex +'/' Literal.String.Regex +'\n\n ' Text +'result' Name +' ' Text +'=' Operator +' ' Text +'pattern' Name +'.' Operator +'match' Name +'(' Punctuation +'str' Name +')' Punctuation +'\n ' Text +'self' Name.Builtin +'.' Operator +'setstatus' Name +'(' Punctuation +'result' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +',' Punctuation +' ' Text +'result' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +')' Punctuation +'\n ' Text +'elsif' Keyword +' ' Text +'(' Punctuation +'str' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^status: [0-9]{3} ?.*$' Literal.String.Regex +'/i' Literal.String.Regex +')' Punctuation +' ' Text +'==' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'pattern' Name +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'^status: ([0-9]{3}) ?(.*)$' Literal.String.Regex +'/i' Literal.String.Regex +'\n\n ' Text +'result' Name +' ' Text +'=' Operator +' ' Text +'pattern' Name +'.' Operator +'match' Name +'(' Punctuation +'str' Name +')' Punctuation +'\n ' Text +'self' Name.Builtin +'.' Operator +'setstatus' Name +'(' Punctuation +'result' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +',' Punctuation +' ' Text +'result' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +')' Punctuation +'\n ' Text +'else' Keyword +'\n ' Text +'a' Name +' ' Text +'=' Operator +' ' Text +'str' Name +'.' Operator +'split' Name +'(' Punctuation +'/' Literal.String.Regex +': ?' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +'\n\n ' Text +'@header' Name.Variable.Instance +'[' Operator +'a' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +'.' Operator +'downcase' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'a' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n ' Text +'# }}}' Comment.Single +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Changes the status of this page. There are several codes like "200 OK",' Comment.Single +'\n\t\t' Text +'# "302 Found", "404 Not Found" or "500 Internal Server Error". A list of' Comment.Single +'\n\t\t' Text +'# all codes is available at' Comment.Single +'\n\t\t' Text +'# http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10' Comment.Single +'\n\t\t' Text +'#' Comment.Single +'\n\t\t' Text +'# You can just send the code number, the reason phrase will be added' Comment.Single +'\n\t\t' Text +'# automaticly with the recommendations from the w3c if not specified. If' Comment.Single +'\n\t\t' Text +'# you set the status twice or more, only the last status will be send.' Comment.Single +'\n\t\t' Text +'# Examples:' Comment.Single +'\n\t\t' Text +'# web.status("401 Unauthorized")' Comment.Single +'\n\t\t' Text +'# web.status("410 Sad but true, this lonely page is gone :(")' Comment.Single +'\n\t\t' Text +'# web.status(206)' Comment.Single +'\n\t\t' Text +'# web.status("400")' Comment.Single +'\n\t\t' Text +'#' Comment.Single +'\n\t\t' Text +'# The default status is "200 OK". If a "Location" header is set, the' Comment.Single +'\n\t\t' Text +'# default status is "302 Found".' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'status' Name.Function +'(' Punctuation +'str' Name +')' Punctuation +'\n ' Text +'# {{{' Comment.Single +'\n ' Text +'if' Keyword +' ' Text +'@output_started' Name.Variable.Instance +'\n ' Text +'raise' Keyword +' ' Text +'"' Literal.String.Double +"HTTP-Headers are already send. You can't change them after output has started!" Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n ' Text +'unless' Keyword +' ' Text +'@output_allowed' Name.Variable.Instance +'\n ' Text +'raise' Keyword +' ' Text +'"' Literal.String.Double +'You just can set headers inside of a Rweb::out-block' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n ' Text +'if' Keyword +' ' Text +'str' Name +'.' Operator +'is_a?' Name +'Integer' Name.Builtin +'\n ' Text +'@status' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'str' Name +'\n ' Text +'elsif' Keyword +' ' Text +'str' Name +'.' Operator +'is_a?' Name +'String' Name.Builtin +'\n ' Text +'p1' Name +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'^([0-9]{3}) ?(.*)$' Literal.String.Regex +'/' Literal.String.Regex +'\n ' Text +'p2' Name +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'^HTTP' Literal.String.Regex +'\\/' Literal.String.Regex +'1' Literal.String.Regex +'\\' Literal.String.Regex +'.[01] ([0-9]{3}) ?(.*)$' Literal.String.Regex +'/' Literal.String.Regex +'\n ' Text +'p3' Name +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'^status: ([0-9]{3}) ?(.*)$' Literal.String.Regex +'/i' Literal.String.Regex +'\n\n ' Text +'if' Keyword +' ' Text +'(' Punctuation +'a' Name +' ' Text +'=' Operator +' ' Text +'p1' Name +'.' Operator +'match' Name +'(' Punctuation +'str' Name +')' Punctuation +')' Punctuation +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n ' Text +'if' Keyword +' ' Text +'(' Punctuation +'a' Name +' ' Text +'=' Operator +' ' Text +'p2' Name +'.' Operator +'match' Name +'(' Punctuation +'str' Name +')' Punctuation +')' Punctuation +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n ' Text +'if' Keyword +' ' Text +'(' Punctuation +'a' Name +' ' Text +'=' Operator +' ' Text +'p3' Name +'.' Operator +'match' Name +'(' Punctuation +'str' Name +')' Punctuation +')' Punctuation +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n ' Text +'raise' Keyword +' ' Text +'ArgumentError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'Invalid argument' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'caller' Name.Builtin +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n ' Text +'@status' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'a' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +'.' Operator +'to_i' Name +'\n ' Text +'if' Keyword +' ' Text +'a' Name +'[' Operator +'2' Literal.Number.Integer +']' Operator +' ' Text +'!=' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'@reasonPhrase' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'a' Name +'[' Operator +'2' Literal.Number.Integer +']' Operator +'\n ' Text +'else' Keyword +'\n ' Text +'@reasonPhrase' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'getReasonPhrase' Name +'(' Punctuation +'@status' Name.Variable.Instance +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'else' Keyword +'\n ' Text +'raise' Keyword +' ' Text +'ArgumentError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'Argument of setstatus must be integer or string' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'caller' Name.Builtin +'\n ' Text +'end' Keyword +'\n ' Text +'# }}}' Comment.Single +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Handles the output of your content and rescues all exceptions. Send all' Comment.Single +'\n\t\t' Text +'# data in the block to this method. For example:' Comment.Single +'\n\t\t' Text +'# web.out do' Comment.Single +'\n\t\t' Text +'# web.header("Content-Type: text/plain")' Comment.Single +'\n\t\t' Text +'# web.puts("Hello, plain world!")' Comment.Single +'\n\t\t' Text +'# end' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'out' Name.Function +'\n ' Text +'# {{{' Comment.Single +'\n ' Text +'@output_allowed' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'true' Keyword.Pseudo +'\n ' Text +'@buffer' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +';' Punctuation +' ' Text +"# We use an array as buffer, because it's more performant :)" Comment.Single +'\n\n ' Text +'begin' Keyword +'\n ' Text +'yield' Keyword +'\n ' Text +'rescue' Keyword +' ' Text +'Exception' Name.Constant +' ' Text +'=' Operator +'>' Operator +' ' Text +'exception' Name +'\n ' Text +'$stderr' Name.Variable.Global +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'Ruby exception rescued (' Literal.String.Double +'#{' Literal.String.Interpol +'exception' Name +'.' Operator +'class' Name +'}' Literal.String.Interpol +'): ' Literal.String.Double +'#{' Literal.String.Interpol +'exception' Name +'.' Operator +'message' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'$stderr' Name.Variable.Global +'.' Operator +'puts' Name +' ' Text +'exception' Name +'.' Operator +'backtrace' Name +'.' Operator +'join' Name +'(' Punctuation +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +')' Punctuation +'\n\n ' Text +'unless' Keyword +' ' Text +'@output_started' Name.Variable.Instance +'\n ' Text +'self' Name.Builtin +'.' Operator +'setstatus' Name +'(' Punctuation +'500' Literal.Number.Integer +')' Punctuation +'\n ' Text +'@header' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'}' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'unless' Keyword +' ' Text +'(' Punctuation +'@settings' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +'"' Literal.String.Double +'hide errors' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'and' Operator.Word +' ' Text +'@settings' Name.Variable.Instance +'[' Operator +'"' Literal.String.Double +'hide errors' Literal.String.Double +'"' Literal.String.Double +']' Operator +' ' Text +'==' Operator +' ' Text +'true' Keyword.Pseudo +')' Punctuation +'\n ' Text +'unless' Keyword +' ' Text +'@output_started' Name.Variable.Instance +'\n ' Text +'self' Name.Builtin +'.' Operator +'header' Name +'(' Punctuation +'"' Literal.String.Double +'Content-Type: text/html' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'<!DOCTYPE HTML PUBLIC ' Literal.String.Double +'\\"' Literal.String.Escape +'-//W3C//DTD HTML 4.01 Strict//EN' Literal.String.Double +'\\"' Literal.String.Escape +' ' Literal.String.Double +'\\"' Literal.String.Escape +'http://www.w3.org/TR/html4/strict.dtd' Literal.String.Double +'\\"' Literal.String.Escape +'>' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'<html>' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'<head>' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'<title>500 Internal Server Error</title>' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'</head>' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'<body>' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n ' Text +'if' Keyword +' ' Text +'@header' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +'"' Literal.String.Double +'content-type' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'and' Operator.Word +' ' Text +'(' Punctuation +'@header' Name.Variable.Instance +'[' Operator +'"' Literal.String.Double +'content-type' Literal.String.Double +'"' Literal.String.Double +']' Operator +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^text' Literal.String.Regex +'\\/' Literal.String.Regex +'html' Literal.String.Regex +'/i' Literal.String.Regex +')' Punctuation +' ' Text +'==' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'<h1>Internal Server Error</h1>' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'<p>The server encountered an exception and was unable to complete your request.</p>' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'<p>The exception has provided the following information:</p>' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'<pre style=' Literal.String.Double +'\\"' Literal.String.Escape +'background: ' Literal.String.Double +'#' Literal.String.Double +'FFCCCC; border: black solid 2px; margin-left: 2cm; margin-right: 2cm; padding: 2mm;' Literal.String.Double +'\\"' Literal.String.Escape +'><b>' Literal.String.Double +'#{' Literal.String.Interpol +'exception' Name +'.' Operator +'class' Name +'}' Literal.String.Interpol +'</b>: ' Literal.String.Double +'#{' Literal.String.Interpol +'exception' Name +'.' Operator +'message' Name +'}' Literal.String.Interpol +' <b>on</b>' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'exception' Name +'.' Operator +'backtrace' Name +'.' Operator +'join' Name +'(' Punctuation +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +')' Punctuation +'}' Literal.String.Interpol +'</pre>' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'</body>' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'</html>' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'else' Keyword +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'The server encountered an exception and was unable to complete your request' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'The exception has provided the following information:' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'exception' Name +'.' Operator +'class' Name +'}' Literal.String.Interpol +': ' Literal.String.Double +'#{' Literal.String.Interpol +'exception' Name +'.' Operator +'message' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +'\n ' Text +'self' Name.Builtin +'.' Operator +'puts' Name +' ' Text +'exception' Name +'.' Operator +'backtrace' Name +'.' Operator +'join' Name +'(' Punctuation +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'if' Keyword +' ' Text +'@settings' Name.Variable.Instance +'[' Operator +'"' Literal.String.Double +'cache' Literal.String.Double +'"' Literal.String.Double +']' Operator +'\n ' Text +'buffer' Name +' ' Text +'=' Operator +' ' Text +'@buffer' Name.Variable.Instance +'.' Operator +'join' Name +'\n\n ' Text +'unless' Keyword +' ' Text +'@output_started' Name.Variable.Instance +'\n ' Text +'unless' Keyword +' ' Text +'@header' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +'"' Literal.String.Double +'content-length' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'self' Name.Builtin +'.' Operator +'header' Name +'(' Punctuation +'"' Literal.String.Double +'content-length: ' Literal.String.Double +'#{' Literal.String.Interpol +'buffer' Name +'.' Operator +'length' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'sendHeaders' Name +'\n ' Text +'end' Keyword +'\n ' Text +'$stdout' Name.Variable.Global +'.' Operator +'print' Name +'(' Punctuation +'buffer' Name +')' Punctuation +'\n ' Text +'elsif' Keyword +' ' Text +'!' Operator +'@output_started' Name.Variable.Instance +'\n ' Text +'sendHeaders' Name +'\n ' Text +'end' Keyword +'\n ' Text +'@output_allowed' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'false' Keyword.Pseudo +';' Punctuation +'\n ' Text +'# }}}' Comment.Single +'\n ' Text +'end' Keyword +'\n\n ' Text +'# Decodes URL encoded data, %20 for example stands for a space.' Comment.Single +'\n ' Text +'def' Keyword +' ' Text +'Rweb' Name.Class +'.' Operator +'unescape' Name.Function +'(' Punctuation +'str' Name +')' Punctuation +'\n ' Text +'# {{{' Comment.Single +'\n ' Text +'if' Keyword +' ' Text +'defined?' Name +' ' Text +'str' Name +' ' Text +'and' Operator.Word +' ' Text +'str' Name +'.' Operator +'is_a?' Name +' ' Text +'String' Name.Builtin +'\n ' Text +'str' Name +'.' Operator +'gsub!' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'+' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +'"' Literal.String.Double +' ' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'str' Name +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'%.{2}' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'do' Keyword +' ' Text +'|' Operator +' ' Text +'s' Name +' ' Text +'|' Operator +'\n ' Text +'s' Name +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +'2' Literal.Number.Integer +']' Operator +'.' Operator +'hex' Name +'.' Operator +'chr' Name +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n ' Text +'# }}}' Comment.Single +'\n ' Text +'end' Keyword +'\n\n ' Text +'protected' Keyword.Pseudo +'\n ' Text +'def' Keyword +' ' Text +'sendHeaders' Name.Function +'\n ' Text +'# {{{' Comment.Single +'\n\n ' Text +'Cookie' Name.Constant +'.' Operator +'disallow' Name +' ' Text +'# no more cookies can be set or modified' Comment.Single +'\n ' Text +'if' Keyword +' ' Text +'!' Operator +'(' Punctuation +'@settings' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +'"' Literal.String.Double +'silent' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'and' Operator.Word +' ' Text +'@settings' Name.Variable.Instance +'[' Operator +'"' Literal.String.Double +'silent' Literal.String.Double +'"' Literal.String.Double +']' Operator +' ' Text +'==' Operator +' ' Text +'true' Keyword.Pseudo +')' Punctuation +' ' Text +'and' Operator.Word +' ' Text +'!' Operator +'@header' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +'"' Literal.String.Double +'x-powered-by' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'if' Keyword +' ' Text +'@mod_ruby' Name.Variable.Instance +'\n ' Text +'header' Name +'(' Punctuation +'"' Literal.String.Double +'x-powered-by: ' Literal.String.Double +'#{' Literal.String.Interpol +'RWEB' Name.Constant +'}' Literal.String.Interpol +' (Ruby/' Literal.String.Double +'#{' Literal.String.Interpol +'RUBY_VERSION' Name.Constant +'}' Literal.String.Interpol +', ' Literal.String.Double +'#{' Literal.String.Interpol +'MOD_RUBY' Name.Constant +'}' Literal.String.Interpol +')' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +';' Punctuation +'\n ' Text +'else' Keyword +'\n ' Text +'header' Name +'(' Punctuation +'"' Literal.String.Double +'x-powered-by: ' Literal.String.Double +'#{' Literal.String.Interpol +'RWEB' Name.Constant +'}' Literal.String.Interpol +' (Ruby/' Literal.String.Double +'#{' Literal.String.Interpol +'RUBY_VERSION' Name.Constant +'}' Literal.String.Interpol +')' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +';' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'if' Keyword +' ' Text +'@output_method' Name.Variable.Instance +' ' Text +'==' Operator +' ' Text +'"' Literal.String.Double +'ph' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'if' Keyword +' ' Text +'(' Punctuation +'(' Punctuation +'@status' Name.Variable.Instance +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +' ' Text +'or' Operator.Word +' ' Text +'@status' Name.Variable.Instance +' ' Text +'==' Operator +' ' Text +'200' Literal.Number.Integer +')' Punctuation +' ' Text +'and' Operator.Word +' ' Text +'!' Operator +'@header' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +'"' Literal.String.Double +'content-type' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'and' Operator.Word +' ' Text +'!' Operator +'@header' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +'"' Literal.String.Double +'location' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +')' Punctuation +'\n ' Text +'header' Name +'(' Punctuation +'"' Literal.String.Double +'content-type: text/html' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'if' Keyword +' ' Text +'@status' Name.Variable.Instance +' ' Text +'!=' Operator +' ' Text +'nil' Keyword.Pseudo +'\n ' Text +'$stdout' Name.Variable.Global +'.' Operator +'print' Name +' ' Text +'"' Literal.String.Double +'Status: ' Literal.String.Double +'#{' Literal.String.Interpol +'@status' Name.Variable.Instance +'}' Literal.String.Interpol +' ' Literal.String.Double +'#{' Literal.String.Interpol +'@reasonPhrase' Name.Variable.Instance +'}' Literal.String.Interpol +'\\r' Literal.String.Escape +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n\n ' Text +'@header' Name.Variable.Instance +'.' Operator +'each' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'key' Name +',' Punctuation +' ' Text +'value' Name +'|' Operator +'\n ' Text +'key' Name +' ' Text +'=' Operator +' ' Text +'key' Name +' ' Text +'*' Operator +'1' Literal.Number.Integer +' ' Text +'# "unfreeze" key :)' Comment.Single +'\n ' Text +'key' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'key' Name +'[' Operator +'0' Literal.Number.Integer +',' Punctuation +'1' Literal.Number.Integer +']' Operator +'.' Operator +'upcase!' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +'\n\n ' Text +'key' Name +' ' Text +'=' Operator +' ' Text +'key' Name +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'-[a-z]' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'do' Keyword +' ' Text +'|' Operator +'char' Name +'|' Operator +'\n ' Text +'"' Literal.String.Double +'-' Literal.String.Double +'"' Literal.String.Double +' ' Text +'+' Operator +' ' Text +'char' Name +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +'1' Literal.Number.Integer +']' Operator +'.' Operator +'upcase' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'$stdout' Name.Variable.Global +'.' Operator +'print' Name +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'key' Name +'}' Literal.String.Interpol +': ' Literal.String.Double +'#{' Literal.String.Interpol +'value' Name +'}' Literal.String.Interpol +'\\r' Literal.String.Escape +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n ' Text +'cookies' Name +' ' Text +'=' Operator +' ' Text +'Cookie' Name.Constant +'.' Operator +'getHttpHeader' Name +' ' Text +'# Get all cookies as an HTTP Header' Comment.Single +'\n ' Text +'if' Keyword +' ' Text +'cookies' Name +'\n ' Text +'$stdout' Name.Variable.Global +'.' Operator +'print' Name +' ' Text +'cookies' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'$stdout' Name.Variable.Global +'.' Operator +'print' Name +' ' Text +'"' Literal.String.Double +'\\r' Literal.String.Escape +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n\n ' Text +'elsif' Keyword +' ' Text +'@output_method' Name.Variable.Instance +' ' Text +'==' Operator +' ' Text +'"' Literal.String.Double +'nph' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'@output_method' Name.Variable.Instance +' ' Text +'==' Operator +' ' Text +'"' Literal.String.Double +'mod_ruby' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'r' Name +' ' Text +'=' Operator +' ' Text +'Apache' Name.Constant +'.' Operator +'request' Name +'\n\n ' Text +'if' Keyword +' ' Text +'(' Punctuation +'(' Punctuation +'@status' Name.Variable.Instance +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +' ' Text +'or' Operator.Word +' ' Text +'@status' Name.Variable.Instance +' ' Text +'==' Operator +' ' Text +'200' Literal.Number.Integer +')' Punctuation +' ' Text +'and' Operator.Word +' ' Text +'!' Operator +'@header' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +'"' Literal.String.Double +'content-type' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'and' Operator.Word +' ' Text +'!' Operator +'@header' Name.Variable.Instance +'.' Operator +'has_key?' Name +'(' Punctuation +'"' Literal.String.Double +'location' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +')' Punctuation +'\n ' Text +'header' Name +'(' Punctuation +'"' Literal.String.Double +'text/html' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'if' Keyword +' ' Text +'@status' Name.Variable.Instance +' ' Text +'!=' Operator +' ' Text +'nil' Keyword.Pseudo +'\n ' Text +'r' Name +'.' Operator +'status_line' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'@status' Name.Variable.Instance +'}' Literal.String.Interpol +' ' Literal.String.Double +'#{' Literal.String.Interpol +'@reasonPhrase' Name.Variable.Instance +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n\n ' Text +'r' Name +'.' Operator +'send_http_header' Name +'\n ' Text +'@header' Name.Variable.Instance +'.' Operator +'each' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'key' Name +',' Punctuation +' ' Text +'value' Name +'|' Operator +'\n ' Text +'key' Name +' ' Text +'=' Operator +' ' Text +'key' Name +' ' Text +'*' Operator +'1' Literal.Number.Integer +' ' Text +'# "unfreeze" key :)' Comment.Single +'\n\n ' Text +'key' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'key' Name +'[' Operator +'0' Literal.Number.Integer +',' Punctuation +'1' Literal.Number.Integer +']' Operator +'.' Operator +'upcase!' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +'\n ' Text +'key' Name +' ' Text +'=' Operator +' ' Text +'key' Name +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'-[a-z]' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'do' Keyword +' ' Text +'|' Operator +'char' Name +'|' Operator +'\n ' Text +'"' Literal.String.Double +'-' Literal.String.Double +'"' Literal.String.Double +' ' Text +'+' Operator +' ' Text +'char' Name +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +'1' Literal.Number.Integer +']' Operator +'.' Operator +'upcase' Name +'\n ' Text +'end' Keyword +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'key' Name +'}' Literal.String.Interpol +': ' Literal.String.Double +'#{' Literal.String.Interpol +'value' Name +'.' Operator +'class' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'#r.headers_out[key] = value' Comment.Single +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n ' Text +'@output_started' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'true' Keyword.Pseudo +'\n ' Text +'# }}}' Comment.Single +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'getReasonPhrase' Name.Function +' ' Text +'(' Punctuation +'status' Name +')' Punctuation +'\n ' Text +'# {{{' Comment.Single +'\n ' Text +'if' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'100' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Continue' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'101' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Switching Protocols' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'200' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'OK' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'201' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Created' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'202' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Accepted' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'203' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Non-Authoritative Information' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'204' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'No Content' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'205' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Reset Content' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'206' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Partial Content' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'300' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Multiple Choices' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'301' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Moved Permanently' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'302' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Found' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'303' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'See Other' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'304' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Not Modified' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'305' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Use Proxy' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'307' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Temporary Redirect' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'400' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Bad Request' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'401' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Unauthorized' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'402' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Payment Required' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'403' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Forbidden' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'404' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Not Found' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'405' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Method Not Allowed' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'406' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Not Acceptable' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'407' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Proxy Authentication Required' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'408' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Request Time-out' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'409' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Conflict' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'410' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Gone' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'411' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Length Required' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'412' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Precondition Failed' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'413' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Request Entity Too Large' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'414' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Request-URI Too Large' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'415' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Unsupported Media Type' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'416' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Requested range not satisfiable' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'417' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Expectation Failed' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'500' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Internal Server Error' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'501' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Not Implemented' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'502' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Bad Gateway' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'503' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Service Unavailable' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'504' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'Gateway Time-out' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'elsif' Keyword +' ' Text +'status' Name +' ' Text +'==' Operator +' ' Text +'505' Literal.Number.Integer +'\n ' Text +'"' Literal.String.Double +'HTTP Version not supported' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'else' Keyword +'\n ' Text +'raise' Keyword +' ' Text +'"' Literal.String.Double +'Unknown Statuscode. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html' Literal.String.Double +'#' Literal.String.Double +'sec6.1 for more information.' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n ' Text +'# }}}' Comment.Single +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'Cookie' Name.Class +'\n\t' Text +'attr_reader' Keyword.Pseudo +' ' Text +':name' Literal.String.Symbol +',' Punctuation +' ' Text +':value' Literal.String.Symbol +',' Punctuation +' ' Text +':maxage' Literal.String.Symbol +',' Punctuation +' ' Text +':path' Literal.String.Symbol +',' Punctuation +' ' Text +':domain' Literal.String.Symbol +',' Punctuation +' ' Text +':secure' Literal.String.Symbol +',' Punctuation +' ' Text +':comment' Literal.String.Symbol +'\n\n\t' Text +'# Sets a cookie. Please see below for details of the attributes.' Comment.Single +'\n\t' Text +'def' Keyword +' ' Text +'initialize' Name.Function +' ' Text +'(' Punctuation +'name' Name.Builtin +',' Punctuation +' ' Text +'value' Name +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Pseudo +',' Punctuation +' ' Text +'maxage' Name +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Pseudo +',' Punctuation +' ' Text +'path' Name +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Pseudo +',' Punctuation +' ' Text +'domain' Name +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Pseudo +',' Punctuation +' ' Text +'secure' Name +' ' Text +'=' Operator +' ' Text +'false' Keyword.Pseudo +')' Punctuation +'\n\t\t' Text +'# {{{' Comment.Single +'\n\t\t' Text +'# HTTP headers (Cookies are a HTTP header) can only set, while no content' Comment.Single +'\n\t\t' Text +'# is send. So an exception will be raised, when @@allowed is set to false' Comment.Single +'\n\t\t' Text +'# and a new cookie has set.' Comment.Single +'\n\t\t' Text +'unless' Keyword +' ' Text +'defined?' Name +'(' Punctuation +'@@allowed' Name.Variable.Class +')' Punctuation +'\n\t\t\t' Text +'@@allowed' Name.Variable.Class +' ' Text +'=' Operator +' ' Text +'true' Keyword.Pseudo +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'unless' Keyword +' ' Text +'@@allowed' Name.Variable.Class +'\n\t\t\t' Text +'raise' Keyword +' ' Text +'"' Literal.String.Double +"You can't set cookies after the HTTP headers are send." Literal.String.Double +'"' Literal.String.Double +'\n\t\t' Text +'end' Keyword +'\n\n\t\t' Text +'unless' Keyword +' ' Text +'defined?' Name +'(' Punctuation +'@@list' Name.Variable.Class +')' Punctuation +'\n\t\t\t' Text +'@@list' Name.Variable.Class +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'@@list' Name.Variable.Class +' ' Text +'+=' Operator +' ' Text +'[' Operator +'self' Name.Builtin +']' Operator +'\n\n\t\t' Text +'unless' Keyword +' ' Text +'defined?' Name +'(' Punctuation +'@@type' Name.Variable.Class +')' Punctuation +'\n\t\t\t' Text +'@@type' Name.Variable.Class +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'netscape' Literal.String.Double +'"' Literal.String.Double +'\n\t\t' Text +'end' Keyword +'\n\n\t\t' Text +'unless' Keyword +' ' Text +'name' Name.Builtin +'.' Operator +'class' Name +' ' Text +'==' Operator +' ' Text +'String' Name.Builtin +'\n\t\t\t' Text +'raise' Keyword +' ' Text +'TypeError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'The name of a cookie must be a string' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'caller' Name.Builtin +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'if' Keyword +' ' Text +'value' Name +'.' Operator +'class' Name +'.' Operator +'superclass' Name +' ' Text +'==' Operator +' ' Text +'Integer' Name.Builtin +' ' Text +'||' Operator +' ' Text +'value' Name +'.' Operator +'class' Name +' ' Text +'==' Operator +' ' Text +'Float' Name.Builtin +'\n\t\t\t' Text +'value' Name +' ' Text +'=' Operator +' ' Text +'value' Name +'.' Operator +'to_s' Name +'\n\t\t' Text +'elsif' Keyword +' ' Text +'value' Name +'.' Operator +'class' Name +' ' Text +'!=' Operator +' ' Text +'String' Name.Builtin +' ' Text +'&&' Operator +' ' Text +'value' Name +' ' Text +'!=' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t' Text +'raise' Keyword +' ' Text +'TypeError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'The value of a cookie must be a string, integer, float or nil' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'caller' Name.Builtin +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'if' Keyword +' ' Text +'maxage' Name +'.' Operator +'class' Name +' ' Text +'==' Operator +' ' Text +'Time' Name.Constant +'\n\t\t\t' Text +'maxage' Name +' ' Text +'=' Operator +' ' Text +'maxage' Name +' ' Text +'-' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'\n\t\t' Text +'elsif' Keyword +' ' Text +'!' Operator +'maxage' Name +'.' Operator +'class' Name +'.' Operator +'superclass' Name +' ' Text +'==' Operator +' ' Text +'Integer' Name.Builtin +' ' Text +'||' Operator +' ' Text +'!' Operator +'maxage' Name +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t' Text +'raise' Keyword +' ' Text +'TypeError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'The maxage date of a cookie must be an Integer or Time object or nil.' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'caller' Name.Builtin +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'unless' Keyword +' ' Text +'path' Name +'.' Operator +'class' Name +' ' Text +'==' Operator +' ' Text +'String' Name.Builtin +' ' Text +'||' Operator +' ' Text +'path' Name +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t' Text +'raise' Keyword +' ' Text +'TypeError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'The path of a cookie must be nil or a string' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'caller' Name.Builtin +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'unless' Keyword +' ' Text +'domain' Name +'.' Operator +'class' Name +' ' Text +'==' Operator +' ' Text +'String' Name.Builtin +' ' Text +'||' Operator +' ' Text +'domain' Name +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t' Text +'raise' Keyword +' ' Text +'TypeError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'The value of a cookie must be nil or a string' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'caller' Name.Builtin +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'unless' Keyword +' ' Text +'secure' Name +' ' Text +'==' Operator +' ' Text +'true' Keyword.Pseudo +' ' Text +'||' Operator +' ' Text +'secure' Name +' ' Text +'==' Operator +' ' Text +'false' Keyword.Pseudo +'\n\t\t\t' Text +'raise' Keyword +' ' Text +'TypeError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'The secure field of a cookie must be true or false' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'caller' Name.Builtin +'\n\t\t' Text +'end' Keyword +'\n\n\t\t' Text +'@name' Name.Variable.Instance +',' Punctuation +' ' Text +'@value' Name.Variable.Instance +',' Punctuation +' ' Text +'@maxage' Name.Variable.Instance +',' Punctuation +' ' Text +'@path' Name.Variable.Instance +',' Punctuation +' ' Text +'@domain' Name.Variable.Instance +',' Punctuation +' ' Text +'@secure' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'name' Name.Builtin +',' Punctuation +' ' Text +'value' Name +',' Punctuation +' ' Text +'maxage' Name +',' Punctuation +' ' Text +'path' Name +',' Punctuation +' ' Text +'domain' Name +',' Punctuation +' ' Text +'secure' Name +'\n\t\t' Text +'@comment' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t' Text +'# }}}' Comment.Single +'\n\t' Text +'end' Keyword +'\n\n\t' Text +'# Modifies the value of this cookie. The information you want to store. If the' Comment.Single +'\n\t' Text +'# value is nil, the cookie will be deleted by the client.' Comment.Single +'\n\t' Text +'#' Comment.Single +'\n\t' Text +'# This attribute can be a String, Integer or Float object or nil.' Comment.Single +'\n\t' Text +'def' Keyword +' ' Text +'value' Name.Function +'=' Operator +'(' Punctuation +'value' Name +')' Punctuation +'\n\t\t' Text +'# {{{' Comment.Single +'\n\t\t' Text +'if' Keyword +' ' Text +'value' Name +'.' Operator +'class' Name +'.' Operator +'superclass' Name +' ' Text +'==' Operator +' ' Text +'Integer' Name.Builtin +' ' Text +'||' Operator +' ' Text +'value' Name +'.' Operator +'class' Name +' ' Text +'==' Operator +' ' Text +'Float' Name.Builtin +'\n\t\t\t' Text +'value' Name +' ' Text +'=' Operator +' ' Text +'value' Name +'.' Operator +'to_s' Name +'\n\t\t' Text +'elsif' Keyword +' ' Text +'value' Name +'.' Operator +'class' Name +' ' Text +'!=' Operator +' ' Text +'String' Name.Builtin +' ' Text +'&&' Operator +' ' Text +'value' Name +' ' Text +'!=' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t' Text +'raise' Keyword +' ' Text +'TypeError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'The value of a cookie must be a string, integer, float or nil' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'caller' Name.Builtin +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'@value' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'value' Name +'\n\t\t' Text +'# }}}' Comment.Single +'\n\t' Text +'end' Keyword +'\n\n\t' Text +'# Modifies the maxage of this cookie. This attribute defines the lifetime of' Comment.Single +'\n\t' Text +'# the cookie, in seconds. A value of 0 means the cookie should be discarded' Comment.Single +'\n\t' Text +'# imediatly. If it set to nil, the cookie will be deleted when the browser' Comment.Single +'\n\t' Text +'# will be closed.' Comment.Single +'\n\t' Text +'#' Comment.Single +'\n\t' Text +'# Attention: This is different from other implementations like PHP, where you' Comment.Single +'\n\t' Text +'# gives the seconds since 1/1/1970 0:00:00 GMT.' Comment.Single +'\n\t' Text +'#' Comment.Single +'\n\t' Text +'# This attribute must be an Integer or Time object or nil.' Comment.Single +'\n\t' Text +'def' Keyword +' ' Text +'maxage' Name.Function +'=' Operator +'(' Punctuation +'maxage' Name +')' Punctuation +'\n\t\t' Text +'# {{{' Comment.Single +'\n\t\t' Text +'if' Keyword +' ' Text +'maxage' Name +'.' Operator +'class' Name +' ' Text +'==' Operator +' ' Text +'Time' Name.Constant +'\n\t\t\t' Text +'maxage' Name +' ' Text +'=' Operator +' ' Text +'maxage' Name +' ' Text +'-' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'\n\t\t' Text +'elsif' Keyword +' ' Text +'maxage' Name +'.' Operator +'class' Name +'.' Operator +'superclass' Name +' ' Text +'==' Operator +' ' Text +'Integer' Name.Builtin +' ' Text +'||' Operator +' ' Text +'!' Operator +'maxage' Name +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t' Text +'raise' Keyword +' ' Text +'TypeError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'The maxage of a cookie must be an Interger or Time object or nil.' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'caller' Name.Builtin +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'@maxage' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'maxage' Name +'\n\t\t' Text +'# }}}' Comment.Single +'\n\t' Text +'end' Keyword +'\n\n\t' Text +'# Modifies the path value of this cookie. The client will send this cookie' Comment.Single +'\n\t' Text +'# only, if the requested document is this directory or a subdirectory of it.' Comment.Single +'\n\t' Text +'#' Comment.Single +'\n\t' Text +'# The value of the attribute must be a String object or nil.' Comment.Single +'\n\t' Text +'def' Keyword +' ' Text +'path' Name.Function +'=' Operator +'(' Punctuation +'path' Name +')' Punctuation +'\n\t\t' Text +'# {{{' Comment.Single +'\n\t\t' Text +'unless' Keyword +' ' Text +'path' Name +'.' Operator +'class' Name +' ' Text +'==' Operator +' ' Text +'String' Name.Builtin +' ' Text +'||' Operator +' ' Text +'path' Name +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t' Text +'raise' Keyword +' ' Text +'TypeError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'The path of a cookie must be nil or a string' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'caller' Name.Builtin +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'@path' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'path' Name +'\n\t\t' Text +'# }}}' Comment.Single +'\n\t' Text +'end' Keyword +'\n\n\t' Text +'# Modifies the domain value of this cookie. The client will send this cookie' Comment.Single +'\n\t' Text +"# only if it's connected with this domain (or a subdomain, if the first" Comment.Single +'\n\t' Text +'# character is a dot like in ".ruby-lang.org")' Comment.Single +'\n\t' Text +'#' Comment.Single +'\n\t' Text +'# The value of this attribute must be a String or nil.' Comment.Single +'\n\t' Text +'def' Keyword +' ' Text +'domain' Name.Function +'=' Operator +'(' Punctuation +'domain' Name +')' Punctuation +'\n\t\t' Text +'# {{{' Comment.Single +'\n\t\t' Text +'unless' Keyword +' ' Text +'domain' Name +'.' Operator +'class' Name +' ' Text +'==' Operator +' ' Text +'String' Name.Builtin +' ' Text +'||' Operator +' ' Text +'domain' Name +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t' Text +'raise' Keyword +' ' Text +'TypeError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'The domain of a cookie must be a String or nil.' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'caller' Name.Builtin +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'@domain' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'domain' Name +'\n\t\t' Text +'# }}}' Comment.Single +'\n\t' Text +'end' Keyword +'\n\n\t' Text +"# Modifies the secure flag of this cookie. If it's true, the client will only" Comment.Single +'\n\t' Text +'# send this cookie if it is secured connected with us.' Comment.Single +'\n\t' Text +'#' Comment.Single +'\n\t' Text +'# The value od this attribute has to be true or false.' Comment.Single +'\n\t' Text +'def' Keyword +' ' Text +'secure' Name.Function +'=' Operator +'(' Punctuation +'secure' Name +')' Punctuation +'\n\t\t' Text +'# {{{' Comment.Single +'\n\t\t' Text +'unless' Keyword +' ' Text +'secure' Name +' ' Text +'==' Operator +' ' Text +'true' Keyword.Pseudo +' ' Text +'||' Operator +' ' Text +'secure' Name +' ' Text +'==' Operator +' ' Text +'false' Keyword.Pseudo +'\n\t\t\t' Text +'raise' Keyword +' ' Text +'TypeError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'The secure field of a cookie must be true or false' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'caller' Name.Builtin +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'@secure' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'secure' Name +'\n\t\t' Text +'# }}}' Comment.Single +'\n\t' Text +'end' Keyword +'\n\n\t' Text +"# Modifies the comment value of this cookie. The comment won't be send, if" Comment.Single +'\n\t' Text +'# type is "netscape".' Comment.Single +'\n\t' Text +'def' Keyword +' ' Text +'comment' Name.Function +'=' Operator +'(' Punctuation +'comment' Name +')' Punctuation +'\n\t\t' Text +'# {{{' Comment.Single +'\n\t\t' Text +'unless' Keyword +' ' Text +'comment' Name +'.' Operator +'class' Name +' ' Text +'==' Operator +' ' Text +'String' Name.Builtin +' ' Text +'||' Operator +' ' Text +'comment' Name +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t' Text +'raise' Keyword +' ' Text +'TypeError' Name.Constant +',' Punctuation +' ' Text +'"' Literal.String.Double +'The comment of a cookie must be a string or nil' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'caller' Name.Builtin +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'@comment' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'comment' Name +'\n\t\t' Text +'# }}}' Comment.Single +'\n\t' Text +'end' Keyword +'\n\n\t' Text +'# Changes the type of all cookies.' Comment.Single +'\n\t' Text +'# Allowed values are RFC2109 and netscape (default).' Comment.Single +'\n\t' Text +'def' Keyword +' ' Text +'Cookie' Name.Class +'.' Operator +'type' Name.Function +'=' Operator +'(' Punctuation +'type' Name +')' Punctuation +'\n\t\t' Text +'# {{{' Comment.Single +'\n\t\t' Text +'unless' Keyword +' ' Text +'@@allowed' Name.Variable.Class +'\n\t\t\t' Text +'raise' Keyword +' ' Text +'"' Literal.String.Double +"The cookies are allready send, so you can't change the type anymore." Literal.String.Double +'"' Literal.String.Double +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'unless' Keyword +' ' Text +'type' Name +'.' Operator +'downcase' Name +' ' Text +'==' Operator +' ' Text +'"' Literal.String.Double +'rfc2109' Literal.String.Double +'"' Literal.String.Double +' ' Text +'&&' Operator +' ' Text +'type' Name +'.' Operator +'downcase' Name +' ' Text +'==' Operator +' ' Text +'"' Literal.String.Double +'netscape' Literal.String.Double +'"' Literal.String.Double +'\n\t\t\t' Text +'raise' Keyword +' ' Text +'"' Literal.String.Double +'The type of the cookies must be ' Literal.String.Double +'\\"' Literal.String.Escape +'RFC2109' Literal.String.Double +'\\"' Literal.String.Escape +' or ' Literal.String.Double +'\\"' Literal.String.Escape +'netscape' Literal.String.Double +'\\"' Literal.String.Escape +'.' Literal.String.Double +'"' Literal.String.Double +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'@@type' Name.Variable.Class +' ' Text +'=' Operator +' ' Text +'type' Name +';' Punctuation +'\n\t\t' Text +'# }}}' Comment.Single +'\n\t' Text +'end' Keyword +'\n\n\t' Text +'# After sending this message, no cookies can be set or modified. Use it, when' Comment.Single +'\n\t' Text +'# HTTP-Headers are send. Rweb does this for you.' Comment.Single +'\n\t' Text +'def' Keyword +' ' Text +'Cookie' Name.Class +'.' Operator +'disallow' Name.Function +'\n\t\t' Text +'# {{{' Comment.Single +'\n\t\t' Text +'@@allowed' Name.Variable.Class +' ' Text +'=' Operator +' ' Text +'false' Keyword.Pseudo +'\n\t\t' Text +'true' Keyword.Pseudo +'\n\t\t' Text +'# }}}' Comment.Single +'\n\t' Text +'end' Keyword +'\n\n\t' Text +'# Returns a HTTP header (type String) with all cookies. Rweb does this for' Comment.Single +'\n\t' Text +'# you.' Comment.Single +'\n\t' Text +'def' Keyword +' ' Text +'Cookie' Name.Class +'.' Operator +'getHttpHeader' Name.Function +'\n\t\t' Text +'# {{{' Comment.Single +'\n\t\t' Text +'if' Keyword +' ' Text +'defined?' Name +'(' Punctuation +'@@list' Name.Variable.Class +')' Punctuation +'\n\t\t\t' Text +'if' Keyword +' ' Text +'@@type' Name.Variable.Class +' ' Text +'==' Operator +' ' Text +'"' Literal.String.Double +'netscape' Literal.String.Double +'"' Literal.String.Double +'\n\t\t\t\t' Text +'str' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +'\n\t\t\t\t' Text +'@@list' Name.Variable.Class +'.' Operator +'each' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'cookie' Name +'|' Operator +'\n\t\t\t\t\t' Text +'if' Keyword +' ' Text +'cookie' Name +'.' Operator +'value' Name +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t\t\t\t' Text +'cookie' Name +'.' Operator +'maxage' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n\t\t\t\t\t\t' Text +'cookie' Name +'.' Operator +'value' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +'\n\t\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t\t' Text +'# TODO: Name and value should be escaped!' Comment.Single +'\n\t\t\t\t\t' Text +'str' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'Set-Cookie: ' Literal.String.Double +'#{' Literal.String.Interpol +'cookie' Name +'.' Operator +'name' Name +'}' Literal.String.Interpol +'=' Literal.String.Double +'#{' Literal.String.Interpol +'cookie' Name +'.' Operator +'value' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n\t\t\t\t\t' Text +'unless' Keyword +' ' Text +'cookie' Name +'.' Operator +'maxage' Name +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t\t\t\t' Text +'expire' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +' ' Text +'+' Operator +' ' Text +'cookie' Name +'.' Operator +'maxage' Name +'\n\t\t\t\t\t\t' Text +'expire' Name +'.' Operator +'gmtime' Name +'\n\t\t\t\t\t\t' Text +'str' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'; Expire=' Literal.String.Double +'#{' Literal.String.Interpol +'expire' Name +'.' Operator +'strftime' Name +'(' Punctuation +'"' Literal.String.Double +'%a, %d-%b-%Y %H:%M:%S %Z' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n\t\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t\t' Text +'unless' Keyword +' ' Text +'cookie' Name +'.' Operator +'domain' Name +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t\t\t\t' Text +'str' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'; Domain=' Literal.String.Double +'#{' Literal.String.Interpol +'cookie' Name +'.' Operator +'domain' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n\t\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t\t' Text +'unless' Keyword +' ' Text +'cookie' Name +'.' Operator +'path' Name +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t\t\t\t' Text +'str' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'; Path=' Literal.String.Double +'#{' Literal.String.Interpol +'cookie' Name +'.' Operator +'path' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n\t\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t\t' Text +'if' Keyword +' ' Text +'cookie' Name +'.' Operator +'secure' Name +'\n\t\t\t\t\t\t' Text +'str' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'; Secure' Literal.String.Double +'"' Literal.String.Double +'\n\t\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t\t' Text +'str' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'\\r' Literal.String.Escape +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t' Text +'return' Keyword +' ' Text +'str' Name +'\n\t\t\t' Text +'else' Keyword +' ' Text +'# type == "RFC2109"' Comment.Single +'\n\t\t\t\t' Text +'str' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'Set-Cookie: ' Literal.String.Double +'"' Literal.String.Double +'\n\t\t\t\t' Text +'comma' Name +' ' Text +'=' Operator +' ' Text +'false' Keyword.Pseudo +';' Punctuation +'\n\n\t\t\t\t' Text +'@@list' Name.Variable.Class +'.' Operator +'each' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'cookie' Name +'|' Operator +'\n\t\t\t\t\t' Text +'if' Keyword +' ' Text +'cookie' Name +'.' Operator +'value' Name +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t\t\t\t' Text +'cookie' Name +'.' Operator +'maxage' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n\t\t\t\t\t\t' Text +'cookie' Name +'.' Operator +'value' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +'\n\t\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t\t' Text +'if' Keyword +' ' Text +'comma' Name +'\n\t\t\t\t\t\t' Text +'str' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +',' Literal.String.Double +'"' Literal.String.Double +'\n\t\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t\t' Text +'comma' Name +' ' Text +'=' Operator +' ' Text +'true' Keyword.Pseudo +'\n\n\t\t\t\t\t' Text +'str' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'cookie' Name +'.' Operator +'name' Name +'}' Literal.String.Interpol +'=' Literal.String.Double +'\\"' Literal.String.Escape +'#{' Literal.String.Interpol +'cookie' Name +'.' Operator +'value' Name +'}' Literal.String.Interpol +'\\"' Literal.String.Escape +'"' Literal.String.Double +'\n\t\t\t\t\t' Text +'unless' Keyword +' ' Text +'cookie' Name +'.' Operator +'maxage' Name +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t\t\t\t' Text +'str' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'; Max-Age=' Literal.String.Double +'\\"' Literal.String.Escape +'#{' Literal.String.Interpol +'cookie' Name +'.' Operator +'maxage' Name +'}' Literal.String.Interpol +'\\"' Literal.String.Escape +'"' Literal.String.Double +'\n\t\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t\t' Text +'unless' Keyword +' ' Text +'cookie' Name +'.' Operator +'domain' Name +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t\t\t\t' Text +'str' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'; Domain=' Literal.String.Double +'\\"' Literal.String.Escape +'#{' Literal.String.Interpol +'cookie' Name +'.' Operator +'domain' Name +'}' Literal.String.Interpol +'\\"' Literal.String.Escape +'"' Literal.String.Double +'\n\t\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t\t' Text +'unless' Keyword +' ' Text +'cookie' Name +'.' Operator +'path' Name +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t\t\t\t' Text +'str' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'; Path=' Literal.String.Double +'\\"' Literal.String.Escape +'#{' Literal.String.Interpol +'cookie' Name +'.' Operator +'path' Name +'}' Literal.String.Interpol +'\\"' Literal.String.Escape +'"' Literal.String.Double +'\n\t\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t\t' Text +'if' Keyword +' ' Text +'cookie' Name +'.' Operator +'secure' Name +'\n\t\t\t\t\t\t' Text +'str' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'; Secure' Literal.String.Double +'"' Literal.String.Double +'\n\t\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t\t' Text +'unless' Keyword +' ' Text +'cookie' Name +'.' Operator +'comment' Name +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n\t\t\t\t\t\t' Text +'str' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'; Comment=' Literal.String.Double +'\\"' Literal.String.Escape +'#{' Literal.String.Interpol +'cookie' Name +'.' Operator +'comment' Name +'}' Literal.String.Interpol +'\\"' Literal.String.Escape +'"' Literal.String.Double +'\n\t\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t\t' Text +'str' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'; Version=' Literal.String.Double +'\\"' Literal.String.Escape +'1' Literal.String.Double +'\\"' Literal.String.Escape +'"' Literal.String.Double +'\n\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t' Text +'str' Name +'\n\t\t\t' Text +'end' Keyword +'\n\t\t' Text +'else' Keyword +'\n\t\t\t' Text +'false' Keyword.Pseudo +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'# }}}' Comment.Single +'\n\t' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'strscan' Literal.String.Single +"'" Literal.String.Single +'\n\n' Text + +'module' Keyword +' ' Text +'BBCode' Name.Namespace +'\n\t' Text +'DEBUG' Name.Constant +' ' Text +'=' Operator +' ' Text +'true' Keyword.Pseudo +'\n\n\t' Text +'use' Name +' ' Text +"'" Literal.String.Single +'encoder' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'tags' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'tagstack' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'smileys' Literal.String.Single +"'" Literal.String.Single +'\n\n' Text + +'=begin\n\tThe Parser class takes care of the encoding.\n\tIt scans the given BBCode (as plain text), finds tags\n\tand smilies and also makes links of urls in text.\n\n\tNormal text is send directly to the encoder.\n\n\tIf a tag was found, an instance of a Tag subclass is created\n\tto handle the case.\n\n\tThe @tagstack manages tag nesting and ensures valid HTML.\n=end' Comment.Multiline +'\n\n\t' Text +'class' Keyword +' ' Text +'Parser' Name.Class +'\n\t\t' Text +'class' Keyword +' ' Text +'Attribute' Name.Class +'\n\t\t\t' Text +'# flatten and use only one empty_arg' Comment.Single +'\n\t\t\t' Text +'def' Keyword +' ' Text +'self' Name.Class +'.' Operator +'create' Name.Function +' ' Text +'attr' Keyword.Pseudo +'\n\t\t\t\t' Text +'attr' Keyword.Pseudo +' ' Text +'=' Operator +' ' Text +'flatten' Name +' ' Text +'attr' Keyword.Pseudo +'\n\t\t\t\t' Text +'return' Keyword +' ' Text +'@@empty_attr' Name.Variable.Class +' ' Text +'if' Keyword +' ' Text +'attr' Keyword.Pseudo +'.' Operator +'empty?' Name +'\n\t\t\t\t' Text +'new' Keyword.Pseudo +' ' Text +'attr' Keyword.Pseudo +'\n\t\t\t' Text +'end' Keyword +'\n\n\t\t\t' Text +'private_class_method' Name.Builtin +' ' Text +':new' Literal.String.Symbol +'\n\n\t\t\t' Text +'# remove leading and trailing whitespace; concat lines' Comment.Single +'\n\t\t\t' Text +'def' Keyword +' ' Text +'self' Name.Class +'.' Operator +'flatten' Name.Function +' ' Text +'attr' Keyword.Pseudo +'\n\t\t\t\t' Text +'attr' Keyword.Pseudo +'.' Operator +'strip' Name +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'n' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +"'" Literal.String.Single +' ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n\t\t\t\t' Text +'# -> ^ and $ can only match at begin and end now' Comment.Single +'\n\t\t\t' Text +'end' Keyword +'\n\n\t\t\t' Text +'ATTRIBUTE_SCAN' Name.Constant +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'\n\t\t\t\t(?!$) ' Literal.String.Regex +'#' Literal.String.Regex +" don't match at end\n\t\t\t\t" Literal.String.Regex +'\\' Literal.String.Regex +'s*\n\t\t\t\t( ' Literal.String.Regex +'#' Literal.String.Regex +' $1 = key\n\t\t\t\t\t[^=' Literal.String.Regex +'\\' Literal.String.Regex +'s' Literal.String.Regex +'\\' Literal.String.Regex +']"' Literal.String.Regex +'\\\\' Literal.String.Regex +']*\n\t\t\t\t\t(?:\n\t\t\t\t\t\t(?: ' Literal.String.Regex +'\\\\' Literal.String.Regex +'. | "[^"' Literal.String.Regex +'\\\\' Literal.String.Regex +']*(?:' Literal.String.Regex +'\\\\' Literal.String.Regex +'.[^"' Literal.String.Regex +'\\\\' Literal.String.Regex +']*)*"? )\n\t\t\t\t\t\t[^=' Literal.String.Regex +'\\' Literal.String.Regex +'s' Literal.String.Regex +'\\' Literal.String.Regex +']"' Literal.String.Regex +'\\\\' Literal.String.Regex +']*\n\t\t\t\t\t)*\n\t\t\t\t)\n\t\t\t\t(?:\n\t\t\t\t\t=\n\t\t\t\t\t( ' Literal.String.Regex +'#' Literal.String.Regex +' $2 = value\n\t\t\t\t\t\t[^' Literal.String.Regex +'\\' Literal.String.Regex +'s' Literal.String.Regex +'\\' Literal.String.Regex +']"' Literal.String.Regex +'\\\\' Literal.String.Regex +']*\n\t\t\t\t\t\t(?:\n\t\t\t\t\t\t\t(?: ' Literal.String.Regex +'\\\\' Literal.String.Regex +'. | "[^"' Literal.String.Regex +'\\\\' Literal.String.Regex +']*(?:' Literal.String.Regex +'\\\\' Literal.String.Regex +'.[^"' Literal.String.Regex +'\\\\' Literal.String.Regex +']*)*"? )\n\t\t\t\t\t\t\t[^' Literal.String.Regex +'\\' Literal.String.Regex +'s' Literal.String.Regex +'\\' Literal.String.Regex +']"' Literal.String.Regex +'\\\\' Literal.String.Regex +']*\n\t\t\t\t\t\t)*\n\t\t\t\t\t)?\n\t\t\t\t)?\n\t\t\t\t' Literal.String.Regex +'\\' Literal.String.Regex +'s*\n\t\t\t' Literal.String.Regex +'/x' Literal.String.Regex +'\n\n\t\t\t' Text +'def' Keyword +' ' Text +'self' Name.Class +'.' Operator +'parse' Name.Function +' ' Text +'source' Name +'\n\t\t\t\t' Text +'source' Name +' ' Text +'=' Operator +' ' Text +'source' Name +'.' Operator +'dup' Name +'\n\t\t\t\t' Text +'# empty_tag: the tag looks like [... /]' Comment.Single +'\n\t\t\t\t' Text +'# slice!: this deletes the \\s*/] at the end' Comment.Single +'\n\t\t\t\t' Text +'# \\s+ because [url=http://rubybb.org/forum/] is NOT an empty tag.' Comment.Single +'\n\t\t\t\t' Text +'# In RubyBBCode, you can use [url=http://rubybb.org/forum/ /], and this has to be' Comment.Single +'\n\t\t\t\t' Text +'# interpreted correctly.' Comment.Single +'\n\t\t\t\t' Text +'empty_tag' Name +' ' Text +'=' Operator +' ' Text +'source' Name +'.' Operator +'sub!' Name +'(' Punctuation +'/' Literal.String.Regex +'^:' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +"'" Literal.String.Single +'=' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +' ' Text +'or' Operator.Word +' ' Text +'source' Name +'.' Operator +'slice!' Name +'(' Punctuation +'/' Literal.String.Regex +'\\/' Literal.String.Regex +'$' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'\n\t\t\t\t' Text +'debug' Name +' ' Text +"'" Literal.String.Single +'PARSE: ' Literal.String.Single +"'" Literal.String.Single +' ' Text +'+' Operator +' ' Text +'source' Name +'.' Operator +'inspect' Name +' ' Text +'+' Operator +' ' Text +"'" Literal.String.Single +' => ' Literal.String.Single +"'" Literal.String.Single +' ' Text +'+' Operator +' ' Text +'empty_tag' Name +'.' Operator +'inspect' Name +'\n\t\t\t\t' Text +"#-> we have now an attr that's EITHER empty OR begins and ends with non-whitespace." Comment.Single +'\n\n\t\t\t\t' Text +'attr' Keyword.Pseudo +' ' Text +'=' Operator +' ' Text +'Hash' Name.Constant +'.' Operator +'new' Name +'\n\t\t\t\t' Text +'attr' Keyword.Pseudo +'[' Operator +':flags' Literal.String.Symbol +']' Operator +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +'\n\t\t\t\t' Text +'source' Name +'.' Operator +'scan' Name +'(' Punctuation +'ATTRIBUTE_SCAN' Name.Constant +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'key' Name +',' Punctuation +' ' Text +'value' Name +'|' Operator +'\n\t\t\t\t\t' Text +'if' Keyword +' ' Text +'not' Operator.Word +' ' Text +'value' Name +'\n\t\t\t\t\t\t' Text +'attr' Keyword.Pseudo +'[' Operator +':flags' Literal.String.Symbol +']' Operator +' ' Text +'<<' Operator +' ' Text +'unescape' Name +'(' Punctuation +'key' Name +')' Punctuation +'\n\t\t\t\t\t' Text +'else' Keyword +'\n\t\t\t\t\t\t' Text +'next' Keyword +' ' Text +'if' Keyword +' ' Text +'value' Name +'.' Operator +'empty?' Name +' ' Text +'and' Operator.Word +' ' Text +'key' Name +'.' Operator +'empty?' Name +'\n\t\t\t\t\t\t' Text +'attr' Keyword.Pseudo +'[' Operator +'unescape' Name +'(' Punctuation +'key' Name +')' Punctuation +']' Operator +' ' Text +'=' Operator +' ' Text +'unescape' Name +'(' Punctuation +'value' Name +')' Punctuation +'\n\t\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t' Text +'}' Punctuation +'\n\t\t\t\t' Text +'debug' Name +' ' Text +'attr' Keyword.Pseudo +'.' Operator +'inspect' Name +'\n\n\t\t\t\t' Text +'return' Keyword +' ' Text +'empty_tag' Name +',' Punctuation +' ' Text +'attr' Keyword.Pseudo +'\n\t\t\t' Text +'end' Keyword +'\n\n\t\t\t' Text +'def' Keyword +' ' Text +'self' Name.Class +'.' Operator +'unescape_char' Name.Function +' ' Text +'esc' Name +'\n\t\t\t\t' Text +'esc' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +'\n\t\t\t' Text +'end' Keyword +'\n\n\t\t\t' Text +'def' Keyword +' ' Text +'self' Name.Class +'.' Operator +'unquote' Name.Function +' ' Text +'qt' Name +'\n\t\t\t\t' Text +'qt' Name +'[' Operator +'1' Literal.Number.Integer +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +'.' Operator +'chomp' Name +'(' Punctuation +"'" Literal.String.Single +'"' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'\\\\' Literal.String.Regex +'.' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'esc' Name +'|' Operator +' ' Text +'unescape_char' Name +' ' Text +'esc' Name +' ' Text +'}' Punctuation +'\n\t\t\t' Text +'end' Keyword +'\n\n\t\t\t' Text +'def' Keyword +' ' Text +'self' Name.Class +'.' Operator +'unescape' Name.Function +' ' Text +'str' Name +'\n\t\t\t\t' Text +'str' Name +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +' (' Literal.String.Regex +'\\\\' Literal.String.Regex +'.) | (" [^"' Literal.String.Regex +'\\\\' Literal.String.Regex +']* (?:' Literal.String.Regex +'\\\\' Literal.String.Regex +'.[^"' Literal.String.Regex +'\\\\' Literal.String.Regex +']*)* "?) ' Literal.String.Regex +'/x' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +'\n\t\t\t\t\t' Text +'if' Keyword +' ' Text +'$1' Name.Variable.Global +'\n\t\t\t\t\t\t' Text +'unescape_char' Name +' ' Text +'$1' Name.Variable.Global +'\n\t\t\t\t\t' Text +'else' Keyword +'\n\t\t\t\t\t\t' Text +'unquote' Name +' ' Text +'$2' Name.Variable.Global +'\n\t\t\t\t\t' Text +'end' Keyword +'\n\t\t\t\t' Text +'}' Punctuation +'\n\t\t\t' Text +'end' Keyword +'\n\n\t\t\t' Text +'include' Keyword.Pseudo +' ' Text +'Enumerable' Name.Constant +'\n\t\t\t' Text +'def' Keyword +' ' Text +'each' Name.Function +' ' Text +'&' Operator +'block' Name +'\n\t\t\t\t' Text +'@args' Name.Variable.Instance +'.' Operator +'each' Name +'(' Punctuation +'&' Operator +'block' Name +')' Punctuation +'\n\t\t\t' Text +'end' Keyword +'\n\n\t\t\t' Text +'attr_reader' Keyword.Pseudo +' ' Text +':source' Literal.String.Symbol +',' Punctuation +' ' Text +':args' Literal.String.Symbol +',' Punctuation +' ' Text +':value' Literal.String.Symbol +'\n\n\t\t\t' Text +'def' Keyword +' ' Text +'initialize' Name.Function +' ' Text +'source' Name +'\n\t\t\t\t' Text +'@source' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'source' Name +'\n\t\t\t\t' Text +'debug' Name +' ' Text +"'" Literal.String.Single +'Attribute' Literal.String.Single +'#' Literal.String.Single +'new(%p)' Literal.String.Single +"'" Literal.String.Single +' ' Text +'%' Operator +' ' Text +'source' Name +'\n\t\t\t\t' Text +'@empty_tag' Name.Variable.Instance +',' Punctuation +' ' Text +'@attr' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'Attribute' Name.Constant +'.' Operator +'parse' Name +' ' Text +'source' Name +'\n\t\t\t\t' Text +'@value' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'@attr' Name.Variable.Instance +'[' Operator +"'" Literal.String.Single +"'" Literal.String.Single +']' Operator +'.' Operator +'to_s' Name +'\n\t\t\t' Text +'end' Keyword +'\n\n\t\t\t' Text +'def' Keyword +' ' Text +'empty?' Name.Function +'\n\t\t\t\t' Text +'self' Name.Builtin +' ' Text +'==' Operator +' ' Text +'@@empty_attr' Name.Variable.Class +'\n\t\t\t' Text +'end' Keyword +'\n\n\t\t\t' Text +'def' Keyword +' ' Text +'empty_tag?' Name.Function +'\n\t\t\t\t' Text +'@empty_tag' Name.Variable.Instance +'\n\t\t\t' Text +'end' Keyword +'\n\n\t\t\t' Text +'def' Keyword +' ' Text +'[]' Name.Function +' ' Text +'*' Operator +'keys' Name +'\n\t\t\t\t' Text +'res' Name +' ' Text +'=' Operator +' ' Text +'@attr' Name.Variable.Instance +'[' Operator +'*' Operator +'keys' Name +']' Operator +'\n\t\t\t' Text +'end' Keyword +'\n\n\t\t\t' Text +'def' Keyword +' ' Text +'flags' Name.Function +'\n\t\t\t\t' Text +'attr' Keyword.Pseudo +'[' Operator +':flags' Literal.String.Symbol +']' Operator +'\n\t\t\t' Text +'end' Keyword +'\n\n\t\t\t' Text +'def' Keyword +' ' Text +'to_s' Name.Function +'\n\t\t\t\t' Text +'@attr' Name.Variable.Instance +'\n\t\t\t' Text +'end' Keyword +'\n\n\t\t\t' Text +'def' Keyword +' ' Text +'inspect' Name.Function +'\n\t\t\t\t' Text +"'" Literal.String.Single +'ATTR[' Literal.String.Single +"'" Literal.String.Single +' ' Text +'+' Operator +' ' Text +'@attr' Name.Variable.Instance +'.' Operator +'inspect' Name +' ' Text +'+' Operator +' ' Text +'(' Punctuation +'@empty_tag' Name.Variable.Instance +' ' Text +'?' Punctuation +' ' Text +"'" Literal.String.Single +' | empty tag' Literal.String.Single +"'" Literal.String.Single +' ' Text +':' Punctuation +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +')' Punctuation +' ' Text +'+' Operator +' ' Text +"'" Literal.String.Single +']' Literal.String.Single +"'" Literal.String.Single +'\n\t\t\t' Text +'end' Keyword +'\n\t\t' Text +'end' Keyword +'\n\t\t' Text +'class' Keyword +' ' Text +'Attribute' Name.Class +'\n\t\t\t' Text +'@@empty_attr' Name.Variable.Class +' ' Text +'=' Operator +' ' Text +'new' Keyword.Pseudo +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +'\n\t\t' Text +'end' Keyword +'\n\t' Text +'end' Keyword +'\n' Text diff --git a/tests/lexers/rb/example3.txt b/tests/lexers/rb/example3.txt new file mode 100644 index 00000000..a9b54e66 --- /dev/null +++ b/tests/lexers/rb/example3.txt @@ -0,0 +1,473 @@ +---input--- +# vim:ft=ruby + +events = Hash.new { |h, k| h[k] = [] } +DATA.read.split(/\n\n\n\s*/).each do |event| + name = event[/^.*/].sub(/http:.*/, '') + event[/\n.*/m].scan(/^([A-Z]{2}\S*)\s*(\S*)\s*(\S*)(\s*\S*)/) do |kind, day, daytime, comment| + events[ [day, daytime] ] << [kind, name + comment] + end +end + +conflicts = 0 +events.to_a.sort_by do |(day, daytime),| + [%w(Mo Di Mi Do Fr).index(day) || 0, daytime] +end.each do |(day, daytime), names| + if names.size > 1 + conflicts += 1 + print '!!! ' + end + print "#{day} #{daytime}: " + names.each { |kind, name| puts " #{kind} #{name}" } + puts +end + +puts '%d conflicts' % conflicts +puts '%d SWS' % (events.inject(0) { |sum, ((day, daytime),)| sum + (daytime[/\d+$/].to_i - daytime[/^\d+/].to_i) }) + +string = % foo # strange. huh? +print "Escape here: \n" +print 'Dont escape here: \n' + +__END__ +Informatik und Informationsgesellschaft I: Digitale Medien (32 214) +Computer lassen ihre eigentliche Bestimmung durch Multimedia und Vernetzung erkennen: Es sind digitale Medien, die alle bisherigen Massen- und Kommunikationsmedien simulieren, kopieren oder ersetzen können. Die kurze Geschichte elektronischer Medien vom Telegramm bis zum Fernsehen wird so zur Vorgeschichte des Computers als Medium. Der Prozess der Mediatisierung der Rechnernetze soll in Technik, Theorie und Praxis untersucht werden. Das PR soll die Techniken der ortsverteilten und zeitversetzten Lehre an Hand praktischer Übungen vorführen und untersuchen. +VL Di 15-17 wöch. RUD 25, 3.101 J. Koubek +VL Do 15-17 wöch. RUD 25, 3.101 +UE/PR Do 17-19 wöch. RUD 25, 3.101 J.-M. Loebel + + +Methoden und Modelle des Systementwurfs (32 223) +Gute Methoden zum Entwurf und zur Verifikation von Systemen sind ein Schlüssel für gute Software. Dieses Seminar betrachtet moderne Entwurfsmethoden. + VL Di 09-11 wöch. RUD 26, 0’313 W. Reisig + VL Do 09-11 wöch. RUD 26, 0’313 + UE Di 11-13 wöch. RUD 26, 0’313 + PR Di 13-15 wöch. RUD 26, 0’313 D. Weinberg + + +Komplexitätstheorie (32 229) +In dieser Vorlesung untersuchen wir eine Reihe von wichtigen algorithmischen Problemstellungen aus verschiedenen Bereichen der Informatik. Unser besonderes Interesse gilt dabei der Abschätzung der Rechenressourcen, die zu ihrer Lösung aufzubringen sind. Die Vorlesung bildet eine wichtige Grundlage für weiterführende Veranstaltungen in den Bereichen Algorithmen, Kryptologie, Algorithmisches Lernen und Algorithmisches Beweisen. + VL Di 09-11 wöch. RUD 26, 1’303 J. Köbler + VL Do 09-11 wöch. RUD 26, 1’305 + UE Do 11-13 wöch. RUD 26, 1’305 + + +Zuverlässige Systeme (32 234) +Mit zunehmender Verbreitung der Computertechnologie in immer mehr Bereichen des menschlichen Lebens wird die Zuverlässigkeit solcher Systeme zu einer immer zentraleren Frage. +Der Halbkurs "Zuverlässige Systeme" konzentriert sich auf folgende Schwerpunkte: Zuverlässigkeit, Fehlertoleranz, Responsivität, Messungen, Anwendungen, Systemmodelle und Techniken, Ausfallverhalten, Fehlermodelle, Schedulingtechniken, Software/Hardware - responsives Systemdesign, Analyse und Synthese, Bewertung, Fallstudien in Forschung und Industrie. +Der Halbkurs kann mit dem Halbkurs "Eigenschaften mobiler und eingebetteter Systeme" zu einem Projektkurs kombiniert werden. Ein gemeinsames Projekt begleitet beide Halbkurse. +VL Di 09-11 wöch. RUD 26, 1’308 M. Malek +VL Do 09-11 wöch. RUD 26, 1’308 +PR n.V. + + +Stochastik für InformatikerInnen (32 239) +Grundlagen der Wahrscheinlichkeitsrechnung, Diskrete und stetige Wahrscheinlichkeitsmodelle in der Informatik, Grenzwertsätze, Simulationsverfahren, Zufallszahlen, Statistische Schätz- und Testverfahren, Markoffsche Ketten, Simulated Annealing, Probabilistische Analyse von Algorithmen. +VL Mo 09-11 wöch. RUD 25, 3.101 W. Kössler +VL Mi 09-11 wöch. RUD 25, 3.101 +UE Mo 11-13 wöch. RUD 25, 3.101 + UE Mi 11-13 wöch. RUD 25. 3.101 + + +Geschichte der Informatik – Ausgewählte Kapitel (32 243) +VL Mi 13-15 wöch. RUD 25, 3.113 W. Coy + + +Aktuelle Themen der Theoretischen Informatik (32 260) +In diesem Seminar sollen wichtige aktuelle Veröffentlichungen aus der theoretischen Informatik gemeinsam erarbeitet werden. Genaueres wird erst kurz vor dem Seminar entschieden. Bei Interesse wenden Sie sich bitte möglichst frühzeitig an den Veranstalter. + SE Fr 09-11 wöch. RUD 26, 1’307 M. Grohe + +---tokens--- +'# vim:ft=ruby' Comment.Single +'\n\n' Text + +'events' Name +' ' Text +'=' Operator +' ' Text +'Hash' Name.Constant +'.' Operator +'new' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'h' Name +',' Punctuation +' ' Text +'k' Name +'|' Operator +' ' Text +'h' Name +'[' Operator +'k' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +' ' Text +'}' Punctuation +'\n' Text + +'DATA' Name.Constant +'.' Operator +'read' Name +'.' Operator +'split' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'n' Literal.String.Regex +'\\' Literal.String.Regex +'n' Literal.String.Regex +'\\' Literal.String.Regex +'n' Literal.String.Regex +'\\' Literal.String.Regex +'s*' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'.' Operator +'each' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'event' Name +'|' Operator +'\n\t' Text +'name' Name.Builtin +' ' Text +'=' Operator +' ' Text +'event' Name +'[' Operator +'/' Literal.String.Regex +'^.*' Literal.String.Regex +'/' Literal.String.Regex +']' Operator +'.' Operator +'sub' Name +'(' Punctuation +'/' Literal.String.Regex +'http:.*' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n\t' Text +'event' Name +'[' Operator +'/' Literal.String.Regex +'\\' Literal.String.Regex +'n.*' Literal.String.Regex +'/m' Literal.String.Regex +']' Operator +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +'^([A-Z]{2}' Literal.String.Regex +'\\' Literal.String.Regex +'S*)' Literal.String.Regex +'\\' Literal.String.Regex +'s*(' Literal.String.Regex +'\\' Literal.String.Regex +'S*)' Literal.String.Regex +'\\' Literal.String.Regex +'s*(' Literal.String.Regex +'\\' Literal.String.Regex +'S*)(' Literal.String.Regex +'\\' Literal.String.Regex +'s*' Literal.String.Regex +'\\' Literal.String.Regex +'S*)' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'do' Keyword +' ' Text +'|' Operator +'kind' Name +',' Punctuation +' ' Text +'day' Name +',' Punctuation +' ' Text +'daytime' Name +',' Punctuation +' ' Text +'comment' Name +'|' Operator +'\n\t\t' Text +'events' Name +'[' Operator +' ' Text +'[' Operator +'day' Name +',' Punctuation +' ' Text +'daytime' Name +']' Operator +' ' Text +']' Operator +' ' Text +'<<' Operator +' ' Text +'[' Operator +'kind' Name +',' Punctuation +' ' Text +'name' Name.Builtin +' ' Text +'+' Operator +' ' Text +'comment' Name +']' Operator +'\n\t' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'conflicts' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n' Text + +'events' Name +'.' Operator +'to_a' Name +'.' Operator +'sort_by' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'(' Punctuation +'day' Name +',' Punctuation +' ' Text +'daytime' Name +')' Punctuation +',' Punctuation +'|' Operator +'\n\t' Text +'[' Operator +'%w(' Literal.String.Other +'Mo Di Mi Do Fr' Literal.String.Other +')' Literal.String.Other +'.' Operator +'index' Name +'(' Punctuation +'day' Name +')' Punctuation +' ' Text +'||' Operator +' ' Text +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'daytime' Name +']' Operator +'\n' Text + +'end' Keyword +'.' Operator +'each' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'(' Punctuation +'day' Name +',' Punctuation +' ' Text +'daytime' Name +')' Punctuation +',' Punctuation +' ' Text +'names' Name +'|' Operator +'\n\t' Text +'if' Keyword +' ' Text +'names' Name +'.' Operator +'size' Name +' ' Text +'>' Operator +' ' Text +'1' Literal.Number.Integer +'\n\t\t' Text +'conflicts' Name +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n\t\t' Text +'print' Name.Builtin +' ' Text +"'" Literal.String.Single +'!!! ' Literal.String.Single +"'" Literal.String.Single +'\n\t' Text +'end' Keyword +'\n\t' Text +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'day' Name +'}' Literal.String.Interpol +' ' Literal.String.Double +'#{' Literal.String.Interpol +'daytime' Name +'}' Literal.String.Interpol +': ' Literal.String.Double +'"' Literal.String.Double +'\n\t' Text +'names' Name +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'kind' Name +',' Punctuation +' ' Text +'name' Name.Builtin +'|' Operator +' ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +' ' Literal.String.Double +'#{' Literal.String.Interpol +'kind' Name +'}' Literal.String.Interpol +' ' Literal.String.Double +'#{' Literal.String.Interpol +'name' Name.Builtin +'}' Literal.String.Interpol +'"' Literal.String.Double +' ' Text +'}' Punctuation +'\n\t' Text +'puts' Name.Builtin +'\n' Text + +'end' Keyword +'\n\n' Text + +'puts' Name.Builtin +' ' Text +"'" Literal.String.Single +'%d conflicts' Literal.String.Single +"'" Literal.String.Single +' ' Text +'%' Operator +' ' Text +'conflicts' Name +'\n' Text + +'puts' Name.Builtin +' ' Text +"'" Literal.String.Single +'%d SWS' Literal.String.Single +"'" Literal.String.Single +' ' Text +'%' Operator +' ' Text +'(' Punctuation +'events' Name +'.' Operator +'inject' Name +'(' Punctuation +'0' Literal.Number.Integer +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'sum' Name +',' Punctuation +' ' Text +'(' Punctuation +'(' Punctuation +'day' Name +',' Punctuation +' ' Text +'daytime' Name +')' Punctuation +',' Punctuation +')' Punctuation +'|' Operator +' ' Text +'sum' Name +' ' Text +'+' Operator +' ' Text +'(' Punctuation +'daytime' Name +'[' Operator +'/' Literal.String.Regex +'\\' Literal.String.Regex +'d+$' Literal.String.Regex +'/' Literal.String.Regex +']' Operator +'.' Operator +'to_i' Name +' ' Text +'-' Operator +' ' Text +'daytime' Name +'[' Operator +'/' Literal.String.Regex +'^' Literal.String.Regex +'\\' Literal.String.Regex +'d+' Literal.String.Regex +'/' Literal.String.Regex +']' Operator +'.' Operator +'to_i' Name +')' Punctuation +' ' Text +'}' Punctuation +')' Punctuation +'\n\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'% foo ' Literal.String.Other +' ' Text +'# strange. huh?' Comment.Single +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Escape here: ' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'print' Name.Builtin +' ' Text +"'" Literal.String.Single +'Dont escape here: ' Literal.String.Single +'\\n' Literal.String.Escape +"'" Literal.String.Single +'\n\n' Text + +'__END__' Comment.Preproc +'\nInformatik und Informationsgesellschaft I: Digitale Medien (32 214)\nComputer lassen ihre eigentliche Bestimmung durch Multimedia und Vernetzung erkennen: Es sind digitale Medien, die alle bisherigen Massen- und Kommunikationsmedien simulieren, kopieren oder ersetzen können. Die kurze Geschichte elektronischer Medien vom Telegramm bis zum Fernsehen wird so zur Vorgeschichte des Computers als Medium. Der Prozess der Mediatisierung der Rechnernetze soll in Technik, Theorie und Praxis untersucht werden. Das PR soll die Techniken der ortsverteilten und zeitversetzten Lehre an Hand praktischer Übungen vorführen und untersuchen.\nVL \tDi\t15-17\twöch.\tRUD 25, 3.101\tJ. Koubek\nVL\tDo\t15-17\twöch.\tRUD 25, 3.101\nUE/PR\tDo\t17-19\twöch.\tRUD 25, 3.101\tJ.-M. Loebel\n\n\nMethoden und Modelle des Systementwurfs (32 223)\nGute Methoden zum Entwurf und zur Verifikation von Systemen sind ein Schlüssel für gute Software. Dieses Seminar betrachtet moderne Entwurfsmethoden.\n VL\tDi\t09-11\twöch.\tRUD 26, 0\x92313\tW. Reisig\n VL\tDo\t09-11\twöch.\tRUD 26, 0\x92313\t\n UE\tDi\t11-13\twöch.\tRUD 26, 0\x92313\t\n PR\tDi\t13-15\twöch.\tRUD 26, 0\x92313\tD. Weinberg\n\n\nKomplexitätstheorie (32 229)\nIn dieser Vorlesung untersuchen wir eine Reihe von wichtigen algorithmischen Problemstellungen aus verschiedenen Bereichen der Informatik. Unser besonderes Interesse gilt dabei der Abschätzung der Rechenressourcen, die zu ihrer Lösung aufzubringen sind. Die Vorlesung bildet eine wichtige Grundlage für weiterführende Veranstaltungen in den Bereichen Algorithmen, Kryptologie, Algorithmisches Lernen und Algorithmisches Beweisen.\n VL \tDi\t09-11\twöch.\tRUD 26, 1\x92303\tJ. Köbler\n VL\tDo\t09-11\twöch.\tRUD 26, 1\x92305\t\n UE\tDo\t11-13\twöch.\tRUD 26, 1\x92305\t\n\n\nZuverlässige Systeme (32 234)\nMit zunehmender Verbreitung der Computertechnologie in immer mehr Bereichen des menschlichen Lebens wird die Zuverlässigkeit solcher Systeme zu einer immer zentraleren Frage.\nDer Halbkurs "Zuverlässige Systeme" konzentriert sich auf folgende Schwerpunkte: Zuverlässigkeit, Fehlertoleranz, Responsivität, Messungen, Anwendungen, Systemmodelle und Techniken, Ausfallverhalten, Fehlermodelle, Schedulingtechniken, Software/Hardware - responsives Systemdesign, Analyse und Synthese, Bewertung, Fallstudien in Forschung und Industrie.\nDer Halbkurs kann mit dem Halbkurs "Eigenschaften mobiler und eingebetteter Systeme" zu einem Projektkurs kombiniert werden. Ein gemeinsames Projekt begleitet beide Halbkurse.\nVL \tDi\t09-11\twöch.\tRUD 26, 1\x92308\tM. Malek\nVL\tDo\t09-11\twöch.\tRUD 26, 1\x92308\nPR\tn.V.\n\n\nStochastik für InformatikerInnen (32 239)\nGrundlagen der Wahrscheinlichkeitsrechnung, Diskrete und stetige Wahrscheinlichkeitsmodelle in der Informatik, Grenzwertsätze, Simulationsverfahren, Zufallszahlen, Statistische Schätz- und Testverfahren, Markoffsche Ketten, Simulated Annealing, Probabilistische Analyse von Algorithmen.\nVL\tMo\t09-11\twöch.\tRUD 25, 3.101\tW. Kössler\nVL\tMi\t09-11\twöch.\tRUD 25, 3.101\nUE\tMo\t11-13\twöch.\tRUD 25, 3.101\n UE\tMi\t11-13\twöch.\tRUD 25. 3.101\n\n\nGeschichte der Informatik \x96 Ausgewählte Kapitel (32 243)\nVL\tMi\t13-15\twöch.\tRUD 25, 3.113\tW. Coy\n\n\nAktuelle Themen der Theoretischen Informatik (32 260)\nIn diesem Seminar sollen wichtige aktuelle Veröffentlichungen aus der theoretischen Informatik gemeinsam erarbeitet werden. Genaueres wird erst kurz vor dem Seminar entschieden. Bei Interesse wenden Sie sich bitte möglichst frühzeitig an den Veranstalter.\n SE\tFr\t09-11\twöch.\tRUD 26, 1\x92307\tM. Grohe\xa0\n' Comment.Preproc diff --git a/tests/lexers/rb/example4.txt b/tests/lexers/rb/example4.txt new file mode 100644 index 00000000..059c5d17 --- /dev/null +++ b/tests/lexers/rb/example4.txt @@ -0,0 +1,161 @@ +---input--- +/ +this is a +multiline +regex +/ + +this /is a +multiline regex too/ + +foo = /is also +one/ + +also /4 +is one/ + +this(/ +too +/) + +# this not +2 /4 +asfsadf/ + +# this is also not one +0x4d /25 +foo/ + +42 and /this +is also a multiline +regex/ + + +# And here some special string cases +foo = % blah # comment here to ensure whitespace +foo(% blah ) +foo << % blah # stupid but has to work +foo = % blah + % blub # wicked +foo = %q wicked # works too + +---tokens--- +'/' Literal.String.Regex +'\nthis is a\nmultiline\nregex\n' Literal.String.Regex + +'/' Literal.String.Regex +'\n\n' Text + +'this' Name +' ' Text +'/' Literal.String.Regex +'is a\nmultiline regex too' Literal.String.Regex +'/' Literal.String.Regex +'\n\n' Text + +'foo' Name +' ' Text +'=' Operator +' ' Text +'/' Literal.String.Regex +'is also\none' Literal.String.Regex +'/' Literal.String.Regex +'\n\n' Text + +'also' Name +' ' Text +'/' Literal.String.Regex +'4\nis one' Literal.String.Regex +'/' Literal.String.Regex +'\n\n' Text + +'this' Name +'(' Punctuation +'/' Literal.String.Regex +'\ntoo\n' Literal.String.Regex + +'/' Literal.String.Regex +')' Punctuation +'\n\n' Text + +'# this not' Comment.Single +'\n' Text + +'2' Literal.Number.Integer +' ' Text +'/' Operator +'4' Literal.Number.Integer +'\n' Text + +'asfsadf' Name +'/' Operator +'\n\n' Text + +'# this is also not one' Comment.Single +'\n' Text + +'0x4d' Literal.Number.Hex +' ' Text +'/' Operator +'25' Literal.Number.Integer +'\n' Text + +'foo' Name +'/' Operator +'\n\n' Text + +'42' Literal.Number.Integer +' ' Text +'and' Operator.Word +' ' Text +'/' Literal.String.Regex +'this\nis also a multiline\nregex' Literal.String.Regex +'/' Literal.String.Regex +'\n\n\n' Text + +'# And here some special string cases' Comment.Single +'\n' Text + +'foo' Name +' ' Text +'=' Operator +' ' Text +'% blah ' Literal.String.Other +' ' Text +'# comment here to ensure whitespace' Comment.Single +'\n' Text + +'foo' Name +'(' Punctuation +'% blah ' Literal.String.Other +')' Punctuation +'\n' Text + +'foo' Name +' ' Text +'<<' Operator +' ' Text +'% blah ' Literal.String.Other +' ' Text +'# stupid but has to work' Comment.Single +'\n' Text + +'foo' Name +' ' Text +'=' Operator +' ' Text +'% blah ' Literal.String.Other +'+' Operator +' ' Text +'% blub ' Literal.String.Other +' ' Text +'# wicked' Comment.Single +'\n' Text + +'foo' Name +' ' Text +'=' Operator +' ' Text +'%q wicked ' Literal.String.Other +' ' Text +'# works too' Comment.Single +'\n' Text diff --git a/tests/lexers/rb/example5.txt b/tests/lexers/rb/example5.txt new file mode 100644 index 00000000..5edc3d94 --- /dev/null +++ b/tests/lexers/rb/example5.txt @@ -0,0 +1,10683 @@ +---input--- +# -*- ruby -*- + +# Local variables: +# indent-tabs-mode: nil +# ruby-indent-level: 4 +# End: + +# @@PLEAC@@_NAME +# @@SKIP@@ Ruby + +# @@PLEAC@@_WEB +# @@SKIP@@ http://www.ruby-lang.org + + +# @@PLEAC@@_1.0 +string = '\n' # two characters, \ and an n +string = 'Jon \'Maddog\' Orwant' # literal single quotes + +string = "\n" # a "newline" character +string = "Jon \"Maddog\" Orwant" # literal double quotes + +string = %q/Jon 'Maddog' Orwant/ # literal single quotes + +string = %q[Jon 'Maddog' Orwant] # literal single quotes +string = %q{Jon 'Maddog' Orwant} # literal single quotes +string = %q(Jon 'Maddog' Orwant) # literal single quotes +string = %q<Jon 'Maddog' Orwant> # literal single quotes + +a = <<"EOF" +This is a multiline here document +terminated by EOF on a line by itself +EOF + + +# @@PLEAC@@_1.1 +value = string[offset,count] +value = string[offset..-1] + +string[offset,count] = newstring +string[offset..-1] = newtail + +# in Ruby we can also specify intervals by their two offsets +value = string[offset..offs2] +string[offset..offs2] = newstring + +leading, s1, s2, trailing = data.unpack("A5 x3 A8 A8 A*") + +fivers = string.unpack("A5" * (string.length/5)) + +chars = string.unpack("A1" * string.length) + +string = "This is what you have" +# +012345678901234567890 Indexing forwards (left to right) +# 109876543210987654321- Indexing backwards (right to left) +# note that 0 means 10 or 20, etc. above + +first = string[0, 1] # "T" +start = string[5, 2] # "is" +rest = string[13..-1] # "you have" +last = string[-1, 1] # "e" +end_ = string[-4..-1] # "have" +piece = string[-8, 3] # "you" + +string[5, 2] = "wasn't" # change "is" to "wasn't" +string[-12..-1] = "ondrous" # "This wasn't wondrous" +string[0, 1] = "" # delete first character +string[-10..-1] = "" # delete last 10 characters + +if string[-10..-1] =~ /pattern/ + puts "Pattern matches in last 10 characters" +end + +string[0, 5].gsub!(/is/, 'at') + +a = "make a hat" +a[0, 1], a[-1, 1] = a[-1, 1], a[0, 1] + +a = "To be or not to be" +b = a.unpack("x6 A6") + +b, c = a.unpack("x6 A2 X5 A2") +puts "#{b}\n#{c}\n" + +def cut2fmt(*args) + template = '' + lastpos = 1 + for place in args + template += "A" + (place - lastpos).to_s + " " + lastpos = place + end + template += "A*" + return template +end + +fmt = cut2fmt(8, 14, 20, 26, 30) + + +# @@PLEAC@@_1.2 +# careful! "b is true" doesn't mean "b != 0" (0 is true in Ruby) +# thus no problem of "defined" later since only nil is false +# the following sets to `c' if `b' is nil or false +a = b || c + +# if you need Perl's behaviour (setting to `c' if `b' is 0) the most +# effective way is to use Numeric#nonzero? (thanks to Dave Thomas!) +a = b.nonzero? || c + +# you will still want to use defined? in order to test +# for scope existence of a given object +a = defined?(b) ? b : c + +dir = ARGV.shift || "/tmp" + + +# @@PLEAC@@_1.3 +v1, v2 = v2, v1 + +alpha, beta, production = %w(January March August) +alpha, beta, production = beta, production, alpha + + +# @@PLEAC@@_1.4 +num = char[0] +char = num.chr + +# Ruby also supports having a char from character constant +num = ?r + +char = sprintf("%c", num) +printf("Number %d is character %c\n", num, num) + +ascii = string.unpack("C*") +string = ascii.pack("C*") + +hal = "HAL" +ascii = hal.unpack("C*") +# We can't use Array#each since we can't mutate a Fixnum +ascii.collect! { |i| + i + 1 # add one to each ASCII value +} +ibm = ascii.pack("C*") +puts ibm + + +# @@PLEAC@@_1.5 +array = string.split('') + +array = string.unpack("C*") + +string.scan(/./) { |b| + # do something with b +} + +string = "an apple a day" +print "unique chars are: ", string.split('').uniq.sort, "\n" + +sum = 0 +for ascval in string.unpack("C*") # or use Array#each for a pure OO style :) + sum += ascval +end +puts "sum is #{sum & 0xffffffff}" # since Ruby will go Bignum if necessary + +# @@INCLUDE@@ include/ruby/slowcat.rb + + +# @@PLEAC@@_1.6 +revbytes = string.reverse + +revwords = string.split(" ").reverse.join(" ") + +revwords = string.split(/(\s+)/).reverse.join + +# using the fact that IO is Enumerable, you can directly "select" it +long_palindromes = File.open("/usr/share/dict/words"). + select { |w| w.chomp!; w.reverse == w && w.length > 5 } + + +# @@PLEAC@@_1.7 +while string.sub!("\t+") { ' ' * ($&.length * 8 - $`.length % 8) } +end + + +# @@PLEAC@@_1.8 +'You owe #{debt} to me'.gsub(/\#{(\w+)}/) { eval($1) } + +rows, cols = 24, 80 +text = %q(I am #{rows} high and #{cols} long) +text.gsub!(/\#{(\w+)}/) { eval("#{$1}") } +puts text + +'I am 17 years old'.gsub(/\d+/) { 2 * $&.to_i } + + +# @@PLEAC@@_1.9 +e = "bo peep".upcase +e.downcase! +e.capitalize! + +"thIS is a loNG liNE".gsub!(/\w+/) { $&.capitalize } + + +# @@PLEAC@@_1.10 +"I have #{n+1} guanacos." +print "I have ", n+1, " guanacos." + + +# @@PLEAC@@_1.11 +var = <<'EOF'.gsub(/^\s+/, '') + your text + goes here +EOF + + +# @@PLEAC@@_1.12 +string = "Folding and splicing is the work of an editor,\n"+ + "not a mere collection of silicon\n"+ + "and\n"+ + "mobile electrons!" + +def wrap(str, max_size) + all = [] + line = '' + for l in str.split + if (line+l).length >= max_size + all.push(line) + line = '' + end + line += line == '' ? l : ' ' + l + end + all.push(line).join("\n") +end + +print wrap(string, 20) +#=> Folding and +#=> splicing is the +#=> work of an editor, +#=> not a mere +#=> collection of +#=> silicon and mobile +#=> electrons! + + +# @@PLEAC@@_1.13 +string = %q(Mom said, "Don't do that.") +string.gsub(/['"]/) { '\\'+$& } +string.gsub(/['"]/, '\&\&') +string.gsub(/[^A-Z]/) { '\\'+$& } +"is a test!".gsub(/\W/) { '\\'+$& } # no function like quotemeta? + + +# @@PLEAC@@_1.14 +string.strip! + + +# @@PLEAC@@_1.15 +def parse_csv(text) + new = text.scan(/"([^\"\\]*(?:\\.[^\"\\]*)*)",?|([^,]+),?|,/) + new << nil if text[-1] == ?, + new.flatten.compact +end + +line = %q<XYZZY,"","O'Reilly, Inc","Wall, Larry","a \"glug\" bit,",5,"Error, Core Dumped"> +fields = parse_csv(line) +fields.each_with_index { |v,i| + print "#{i} : #{v}\n"; +} + + +# @@PLEAC@@_1.16 +# Use the soundex.rb Library from Michael Neumann. +# http://www.s-direktnet.de/homepages/neumann/rb_prgs/Soundex.rb +require 'Soundex' + +code = Text::Soundex.soundex(string) +codes = Text::Soundex.soundex(array) + +# substitution function for getpwent(): +# returns an array of user entries, +# each entry contains the username and the full name +def login_names + result = [] + File.open("/etc/passwd") { |file| + file.each_line { |line| + next if line.match(/^#/) + cols = line.split(":") + result.push([cols[0], cols[4]]) + } + } + result +end + +puts "Lookup user: " +user = STDIN.gets +user.chomp! +exit unless user +name_code = Text::Soundex.soundex(user) + +splitter = Regexp.new('(\w+)[^,]*\b(\w+)') +for username, fullname in login_names do + firstname, lastname = splitter.match(fullname)[1,2] + if name_code == Text::Soundex.soundex(username) + || name_code == Text::Soundex.soundex(firstname) + || name_code == Text::Soundex.soundex(lastname) + then + puts "#{username}: #{firstname} #{lastname}" + end +end + + +# @@PLEAC@@_1.17 +# @@INCLUDE@@ include/ruby/fixstyle.rb + + +# @@PLEAC@@_1.18 +# @@INCLUDE@@ include/ruby/psgrep.rb + + +# @@PLEAC@@_2.1 +# Matz tells that you can use Integer() for strict checked conversion. +Integer("abc") +#=> `Integer': invalid value for Integer: "abc" (ArgumentError) +Integer("567") +#=> 567 + +# You may use Float() for floating point stuff +Integer("56.7") +#=> `Integer': invalid value for Integer: "56.7" (ArgumentError) +Float("56.7") +#=> 56.7 + +# You may also use a regexp for that +if string =~ /^[+-]?\d+$/ + p 'is an integer' +else + p 'is not' +end + +if string =~ /^-?(?:\d+(?:\.\d*)?|\.\d+)$/ + p 'is a decimal number' +else + p 'is not' +end + + +# @@PLEAC@@_2.2 +# equal(num1, num2, accuracy) : returns true if num1 and num2 are +# equal to accuracy number of decimal places +def equal(i, j, a) + sprintf("%.#{a}g", i) == sprintf("%.#{a}g", j) +end + +wage = 536 # $5.36/hour +week = 40 * wage # $214.40 +printf("One week's wage is: \$%.2f\n", week/100.0) + + +# @@PLEAC@@_2.3 +num.round # rounds to integer + +a = 0.255 +b = sprintf("%.2f", a) +print "Unrounded: #{a}\nRounded: #{b}\n" +printf "Unrounded: #{a}\nRounded: %.2f\n", a + +print "number\tint\tfloor\tceil\n" +a = [ 3.3 , 3.5 , 3.7, -3.3 ] +for n in a + printf("% .1f\t% .1f\t% .1f\t% .1f\n", # at least I don't fake my output :) + n, n.to_i, n.floor, n.ceil) +end + + +# @@PLEAC@@_2.4 +def dec2bin(n) + [n].pack("N").unpack("B32")[0].sub(/^0+(?=\d)/, '') +end + +def bin2dec(n) + [("0"*32+n.to_s)[-32..-1]].pack("B32").unpack("N")[0] +end + + +# @@PLEAC@@_2.5 +for i in x .. y + # i is set to every integer from x to y, inclusive +end + +x.step(y,7) { |i| + # i is set to every integer from x to y, stepsize = 7 +} + +print "Infancy is: " +(0..2).each { |i| + print i, " " +} +print "\n" + + +# @@PLEAC@@_2.6 +# We can add conversion methods to the Integer class, +# this makes a roman number just a representation for normal numbers. +class Integer + + @@romanlist = [["M", 1000], + ["CM", 900], + ["D", 500], + ["CD", 400], + ["C", 100], + ["XC", 90], + ["L", 50], + ["XL", 40], + ["X", 10], + ["IX", 9], + ["V", 5], + ["IV", 4], + ["I", 1]] + + def to_roman + remains = self + roman = "" + for sym, num in @@romanlist + while remains >= num + remains -= num + roman << sym + end + end + roman + end + + def Integer.from_roman(roman) + ustr = roman.upcase + sum = 0 + for entry in @@romanlist + sym, num = entry[0], entry[1] + while sym == ustr[0, sym.length] + sum += num + ustr.slice!(0, sym.length) + end + end + sum + end + +end + + +roman_fifteen = 15.to_roman +puts "Roman for fifteen is #{roman_fifteen}" +i = Integer.from_roman(roman_fifteen) +puts "Converted back, #{roman_fifteen} is #{i}" + +# check +for i in (1..3900) + r = i.to_roman + j = Integer.from_roman(r) + if i != j + puts "error: #{i} : #{r} - #{j}" + end +end + + +# @@PLEAC@@_2.7 +random = rand(y-x+1)+x + +chars = ["A".."Z","a".."z","0".."9"].collect { |r| r.to_a }.join + %q(!@$%^&*) +password = (1..8).collect { chars[rand(chars.size)] }.pack("C*") + + +# @@PLEAC@@_2.8 +srand # uses a combination of the time, the process id, and a sequence number +srand(val) # for repeatable behaviour + + +# @@PLEAC@@_2.9 +# from the randomr lib: +# http://raa.ruby-lang.org/project/randomr/ +----> http://raa.ruby-lang.org/project/randomr/ + +require 'random/mersenne_twister' +mers = Random::MersenneTwister.new 123456789 +puts mers.rand(0) # 0.550321932544541 +puts mers.rand(10) # 2 + +# using online sources of random data via the realrand package: +# http://raa.ruby-lang.org/project/realrand/ +# **Note** +# The following online services are used in this package: +# http://www.random.org - source: atmospheric noise +# http://www.fourmilab.ch/hotbits - source: radioactive decay timings +# http://random.hd.org - source: entropy from local and network noise +# Please visit the sites and respect the rules of each service. + +require 'random/online' + +generator1 = Random::RandomOrg.new +puts generator1.randbyte(5).join(",") +puts generator1.randnum(10, 1, 6).join(",") # Roll dice 10 times. + +generator2 = Random::FourmiLab.new +puts generator2.randbyte(5).join(",") +# randnum is not supported. + +generator3 = Random::EntropyPool.new +puts generator3.randbyte(5).join(",") +# randnum is not supported. + + +# @@PLEAC@@_2.10 +def gaussian_rand + begin + u1 = 2 * rand() - 1 + u2 = 2 * rand() - 1 + w = u1*u1 + u2*u2 + end while (w >= 1) + w = Math.sqrt((-2*Math.log(w))/w) + [ u2*w, u1*w ] +end + +mean = 25 +sdev = 2 +salary = gaussian_rand[0] * sdev + mean +printf("You have been hired at \$%.2f\n", salary) + + +# @@PLEAC@@_2.11 +def deg2rad(d) + (d/180.0)*Math::PI +end + +def rad2deg(r) + (r/Math::PI)*180 +end + + +# @@PLEAC@@_2.12 +sin_val = Math.sin(angle) +cos_val = Math.cos(angle) +tan_val = Math.tan(angle) + +# AFAIK Ruby's Math module doesn't provide acos/asin +# While we're at it, let's also define missing hyperbolic functions +module Math + def Math.asin(x) + atan2(x, sqrt(1 - x**2)) + end + def Math.acos(x) + atan2(sqrt(1 - x**2), x) + end + def Math.atan(x) + atan2(x, 1) + end + def Math.sinh(x) + (exp(x) - exp(-x)) / 2 + end + def Math.cosh(x) + (exp(x) + exp(-x)) / 2 + end + def Math.tanh(x) + sinh(x) / cosh(x) + end +end + +# The support for Complex numbers is not built-in +y = Math.acos(3.7) +#=> in `sqrt': square root for negative number (ArgumentError) + +# There is an implementation of Complex numbers in 'complex.rb' in current +# Ruby distro, but it doesn't support atan2 with complex args, so it doesn't +# solve this problem. + + +# @@PLEAC@@_2.13 +log_e = Math.log(val) +log_10 = Math.log10(val) + +def log_base(base, val) + Math.log(val)/Math.log(base) +end + +answer = log_base(10, 10_000) +puts "log10(10,000) = #{answer}" + + +# @@PLEAC@@_2.14 +require 'matrix.rb' + +a = Matrix[[3, 2, 3], [5, 9, 8]] +b = Matrix[[4, 7], [9, 3], [8, 1]] +c = a * b + +a.row_size +a.column_size + +c.det +a.transpose + + +# @@PLEAC@@_2.15 +require 'complex.rb' +require 'rational.rb' + +a = Complex(3, 5) # 3 + 5i +b = Complex(2, -2) # 2 - 2i +puts "c = #{a*b}" + +c = a * b +d = 3 + 4*Complex::I + +printf "sqrt(#{d}) = %s\n", Math.sqrt(d) + + +# @@PLEAC@@_2.16 +number = hexadecimal.hex +number = octal.oct + +print "Gimme a number in decimal, octal, or hex: " +num = gets.chomp +exit unless defined?(num) +num = num.oct if num =~ /^0/ # does both oct and hex +printf "%d %x %o\n", num, num, num + +print "Enter file permission in octal: " +permissions = gets.chomp +raise "Exiting ...\n" unless defined?(permissions) +puts "The decimal value is #{permissions.oct}" + + +# @@PLEAC@@_2.17 +def commify(n) + n.to_s =~ /([^\.]*)(\..*)?/ + int, dec = $1.reverse, $2 ? $2 : "" + while int.gsub!(/(,|\.|^)(\d{3})(\d)/, '\1\2,\3') + end + int.reverse + dec +end + + +# @@PLEAC@@_2.18 +printf "It took %d hour%s\n", time, time == 1 ? "" : "s" + +# dunno if an equivalent to Lingua::EN::Inflect exists... + + +# @@PLEAC@@_2.19 +#----------------------------- +#!/usr/bin/ruby +# bigfact - calculating prime factors +def factorize(orig) + factors = {} + factors.default = 0 # return 0 instead nil if key not found in hash + n = orig + i = 2 + sqi = 4 # square of i + while sqi <= n do + while n.modulo(i) == 0 do + n /= i + factors[i] += 1 + # puts "Found factor #{i}" + end + # we take advantage of the fact that (i +1)**2 = i**2 + 2*i +1 + sqi += 2 * i + 1 + i += 1 + end + + if (n != 1) && (n != orig) + factors[n] += 1 + end + factors +end + +def printfactorhash(orig, factorcount) + print format("%-10d ", orig) + if factorcount.length == 0 + print "PRIME" + else + # sorts after number, because the hash keys are numbers + factorcount.sort.each { |factor,exponent| + print factor + if exponent > 1 + print "**", exponent + end + print " " + } + end + puts +end + +for arg in ARGV + n = arg.to_i + mfactors = factorize(n) + printfactorhash(n, mfactors) +end +#----------------------------- + + +# @@PLEAC@@_3.0 +puts Time.now + +print "Today is day ", Time.now.yday, " of the current year.\n" +print "Today is day ", Time.now.day, " of the current month.\n" + + +# @@PLEAC@@_3.1 +day, month, year = Time.now.day, Time.now.month, Time.now.year +# or +day, month, year = Time.now.to_a[3..5] + +tl = Time.now.localtime +printf("The current date is %04d %02d %02d\n", tl.year, tl.month, tl.day) + +Time.now.localtime.strftime("%Y-%m-%d") + + +# @@PLEAC@@_3.2 +Time.local(year, month, day, hour, minute, second).tv_sec +Time.gm(year, month, day, hour, minute, second).tv_sec + + +# @@PLEAC@@_3.3 +sec, min, hour, day, month, year, wday, yday, isdst, zone = Time.at(epoch_secs).to_a + + +# @@PLEAC@@_3.4 +when_ = now + difference # now -> Time ; difference -> Numeric (delta in seconds) +then_ = now - difference + + +# @@PLEAC@@_3.5 +bree = 361535725 +nat = 96201950 + +difference = bree - nat +puts "There were #{difference} seconds between Nat and Bree" + +seconds = difference % 60 +difference = (difference - seconds) / 60 +minutes = difference % 60 +difference = (difference - minutes) / 60 +hours = difference % 24 +difference = (difference - hours) / 24 +days = difference % 7 +weeks = (difference - days) / 7 + +puts "(#{weeks} weeks, #{days} days, #{hours}:#{minutes}:#{seconds})" + + +# @@PLEAC@@_3.6 +monthday, weekday, yearday = date.mday, date.wday, date.yday + +# AFAIK the week number is not just a division since week boundaries are on sundays +weeknum = d.strftime("%U").to_i + 1 + +year = 1981 +month = "jun" # or `6' if you want to emulate a broken language +day = 16 +t = Time.mktime(year, month, day) +print "#{month}/#{day}/#{year} was a ", t.strftime("%A"), "\n" + + +# @@PLEAC@@_3.7 +yyyy, mm, dd = $1, $2, $3 if "1998-06-25" =~ /(\d+)-(\d+)-(\d+)/ + +epoch_seconds = Time.mktime(yyyy, mm, dd).tv_sec + +# dunno an equivalent to Date::Manip#ParseDate + + +# @@PLEAC@@_3.8 +string = Time.at(epoch_secs) +Time.at(1234567890).gmtime # gives: Fri Feb 13 23:31:30 UTC 2009 + +time = Time.mktime(1973, "jan", 18, 3, 45, 50) +print "In localtime it gives: ", time.localtime, "\n" + + +# @@PLEAC@@_3.9 +# Ruby provides micro-seconds in Time object +Time.now.usec + +# Ruby gives the seconds in floating format when substracting two Time objects +before = Time.now +line = gets +elapsed = Time.now - before +puts "You took #{elapsed} seconds." + +# On my Celeron-400 with Linux-2.2.19-14mdk, average for three execs are: +# This Ruby version: average 0.00321 sec +# Cookbook's Perl version: average 0.00981 sec +size = 500 +number_of_times = 100 +total_time = 0 +number_of_times.times { + # populate array + array = [] + size.times { array << rand } + # sort it + begin_ = Time.now + array.sort! + time = Time.now - begin_ + total_time += time +} +printf "On average, sorting %d random numbers takes %.5f seconds\n", + size, (total_time/Float(number_of_times)) + + +# @@PLEAC@@_3.10 +sleep(0.005) # Ruby is definitely not as broken as Perl :) +# (may be interrupted by sending the process a SIGALRM) + + +# @@PLEAC@@_3.11 +#!/usr/bin/ruby -w +# hopdelta - feed mail header, produce lines +# showing delay at each hop. +require 'time' +class MailHopDelta + + def initialize(mail) + @head = mail.gsub(/\n\s+/,' ') + @topline = %w-Sender Recipient Time Delta- + @start_from = mail.match(/^From.*\@([^\s>]*)/)[1] + @date = Time.parse(mail.match(/^Date:\s+(.*)/)[1]) + end + + def out(line) + "%-20.20s %-20.20s %-20.20s %s" % line + end + + def hop_date(day) + day.strftime("%I:%M:%S %Y/%m/%d") + end + + def puts_hops + puts out(@topline) + puts out(['Start', @start_from, hop_date(@date),'']) + @head.split(/\n/).reverse.grep(/^Received:/).each do |hop| + hop.gsub!(/\bon (.*?) (id.*)/,'; \1') + whence = hop.match(/;\s+(.*)$/)[1] + unless whence + warn "Bad received line: #{hop}" + next + end + from = $+ if hop =~ /from\s+(\S+)|\((.*?)\)/ + by = $1 if hop =~ /by\s+(\S+\.\S+)/ + next unless now = Time.parse(whence).localtime + delta = now - @date + puts out([from, by, hop_date(now), hop_time(delta)]) + @date = now + end + end + + def hop_time(secs) + sign = secs < 0 ? -1 : 1 + days, secs = secs.abs.divmod(60 * 60 * 24) + hours,secs = secs.abs.divmod(60 * 60) + mins, secs = secs.abs.divmod(60) + rtn = "%3ds" % [secs * sign] + rtn << "%3dm" % [mins * sign] if mins != 0 + rtn << "%3dh" % [hours * sign] if hours != 0 + rtn << "%3dd" % [days * sign] if days != 0 + rtn + end +end + +$/ = "" +mail = MailHopDelta.new(ARGF.gets).puts_hops + + +# @@PLEAC@@_4.0 +single_level = [ "this", "that", "the", "other" ] + +# Ruby directly supports nested arrays +double_level = [ "this", "that", [ "the", "other" ] ] +still_single_level = [ "this", "that", [ "the", "other" ] ].flatten + + +# @@PLEAC@@_4.1 +a = [ "quick", "brown", "fox" ] +a = %w(Why are you teasing me?) + +lines = <<"END_OF_HERE_DOC".gsub(/^\s*(.+)/, '\1') + The boy stood on the burning deck, + It was as hot as glass. +END_OF_HERE_DOC + +bigarray = IO.readlines("mydatafile").collect { |l| l.chomp } + +name = "Gandalf" +banner = %Q(Speak, #{name}, and welcome!) + +host_info = `host #{his_host}` + +%x(ps #{$$}) + +banner = 'Costs only $4.95'.split(' ') + +rax = %w! ( ) < > { } [ ] ! + + +# @@PLEAC@@_4.2 +def commify_series(arr) + return '' if not arr + case arr.size + when 0 then '' + when 1 then arr[0] + when 2 then arr.join(' and ') + else arr[0..-2].join(', ') + ', and ' + arr[-1] + end +end + +array = [ "red", "yellow", "green" ] + +print "I have ", array, " marbles\n" +# -> I have redyellowgreen marbles + +# But unlike Perl: +print "I have #{array} marbles\n" +# -> I have redyellowgreen marbles +# So, needs: +print "I have #{array.join(' ')} marbles\n" +# -> I have red yellow green marbles + +#!/usr/bin/ruby +# communify_series - show proper comma insertion in list output + +def commify_series(arr) + return '' if not arr + sepchar = arr.find { |p| p =~ /,/ } ? '; ' : ', ' + case arr.size + when 0 then '' + when 1 then arr[0] + when 2 then arr.join(' and ') + else arr[0..-2].join(sepchar) + sepchar + 'and ' + arr[-1] + end +end + +lists = [ + [ 'just one thing' ], + %w(Mutt Jeff), + %w(Peter Paul Mary), + [ 'To our parents', 'Mother Theresa', 'God' ], + [ 'pastrami', 'ham and cheese', 'peanut butter and jelly', 'tuna' ], + [ 'recycle tired, old phrases', 'ponder big, happy thoughts' ], + [ 'recycle tired, old phrases', + 'ponder big, happy thoughts', + 'sleep and dream peacefully' ], +] + +for list in lists do + puts "The list is: #{commify_series(list)}." +end + + +# @@PLEAC@@_4.3 +# (note: AFAIK Ruby doesn't allow gory change of Array length) +# grow the array by assigning nil to past the end of array +ary[new_size-1] = nil +# shrink the array by slicing it down +ary.slice!(new_size..-1) +# init the array with given size +Array.new(number_of_elems) +# assign to an element past the original end enlarges the array +ary[index_new_last_elem] = value + +def what_about_that_array(a) + print "The array now has ", a.size, " elements.\n" + # Index of last element is not really interesting in Ruby + print "Element #3 is `#{a[3]}'.\n" +end +people = %w(Crosby Stills Nash Young) +what_about_that_array(people) + + +# @@PLEAC@@_4.4 +# OO style +bad_users.each { |user| + complain(user) +} +# or, functional style +for user in bad_users + complain(user) +end + +for var in ENV.keys.sort + puts "#{var}=#{ENV[var]}" +end + +for user in all_users + disk_space = get_usage(user) + if (disk_space > MAX_QUOTA) + complain(user) + end +end + +for l in IO.popen("who").readlines + print l if l =~ /^gc/ +end + +# we can mimic the obfuscated Perl way +while fh.gets # $_ is set to the line just read + chomp # $_ has a trailing \n removed, if it had one + split.each { |w| # $_ is split on whitespace + # but $_ is not set to each chunk as in Perl + print w.reverse + } +end +# ...or use a cleaner way +for l in fh.readlines + l.chomp.split.each { |w| print w.reverse } +end + +# same drawback as in problem 1.4, we can't mutate a Numeric... +array.collect! { |v| v - 1 } + +a = [ .5, 3 ]; b = [ 0, 1 ] +for ary in [ a, b ] + ary.collect! { |v| v * 7 } +end +puts "#{a.join(' ')} #{b.join(' ')}" + +# we can mutate Strings, cool; we need a trick for the scalar +for ary in [ [ scalar ], array, hash.values ] + ary.each { |v| v.strip! } # String#strip rules :) +end + + +# @@PLEAC@@_4.5 +# not relevant in Ruby since we have always references +for item in array + # do somethingh with item +end + + +# @@PLEAC@@_4.6 +unique = list.uniq + +# generate a list of users logged in, removing duplicates +users = `who`.collect { |l| l =~ /(\w+)/; $1 }.sort.uniq +puts("users logged in: #{commify_series(users)}") # see 4.2 for commify_series + + +# @@PLEAC@@_4.7 +a - b +# [ 1, 1, 2, 2, 3, 3, 3, 4, 5 ] - [ 1, 2, 4 ] -> [3, 5] + + +# @@PLEAC@@_4.8 +union = a | b +intersection = a & b +difference = a - b + + +# @@PLEAC@@_4.9 +array1.concat(array2) +# if you will assign to another object, better use: +new_ary = array1 + array2 + +members = [ "Time", "Flies" ] +initiates = [ "An", "Arrow" ] +members += initiates + +members = [ "Time", "Flies" ] +initiates = [ "An", "Arrow" ] +members[2,0] = [ "Like", initiates ].flatten + +members[0] = "Fruit" +members[3,2] = "A", "Banana" + + +# @@PLEAC@@_4.10 +reversed = ary.reverse + +ary.reverse_each { |e| + # do something with e +} + +descending = ary.sort.reverse +descending = ary.sort { |a,b| b <=> a } + + +# @@PLEAC@@_4.11 +# remove n elements from front of ary (shift n) +front = ary.slice!(0, n) + +# remove n elements from the end of ary (pop n) +end_ = ary.slice!(-n .. -1) + +# let's extend the Array class, to make that useful +class Array + def shift2() + slice!(0 .. 1) # more symetric with pop2... + end + def pop2() + slice!(-2 .. -1) + end +end + +friends = %w(Peter Paul Mary Jim Tim) +this, that = friends.shift2 + +beverages = %w(Dew Jolt Cola Sprite Fresca) +pair = beverages.pop2 + + +# @@PLEAC@@_4.12 +# use Enumerable#detect (or the synonym Enumerable#find) +highest_eng = employees.detect { |emp| emp.category == 'engineer' } + + +# @@PLEAC@@_4.13 +# use Enumerable#select (or the synonym Enumerable#find_all) +bigs = nums.select { |i| i > 1_000_000 } +pigs = users.keys.select { |k| users[k] > 1e7 } + +matching = `who`.select { |u| u =~ /^gnat / } + +engineers = employees.select { |e| e.position == 'Engineer' } + +secondary_assistance = applicants.select { |a| + a.income >= 26_000 && a.income < 30_000 +} + + +# @@PLEAC@@_4.14 +# normally you would have an array of Numeric (Float or +# Fixnum or Bignum), so you would use: +sorted = unsorted.sort +# if you have strings representing Integers or Floats +# you may specify another sort method: +sorted = unsorted.sort { |a,b| a.to_f <=> b.to_f } + +# let's use the list of my own PID's +`ps ux`.split("\n")[1..-1]. + select { |i| i =~ /^#{ENV['USER']}/ }. + collect { |i| i.split[1] }. + sort { |a,b| a.to_i <=> b.to_i }.each { |i| puts i } +puts "Select a process ID to kill:" +pid = gets.chomp +raise "Exiting ... \n" unless pid && pid =~ /^\d+$/ +Process.kill('TERM', pid.to_i) +sleep 2 +Process.kill('KILL', pid.to_i) + +descending = unsorted.sort { |a,b| b.to_f <=> a.to_f } + + +# @@PLEAC@@_4.15 +ordered = unordered.sort { |a,b| compare(a,b) } + +precomputed = unordered.collect { |e| [compute, e] } +ordered_precomputed = precomputed.sort { |a,b| a[0] <=> b[0] } +ordered = ordered_precomputed.collect { |e| e[1] } + +ordered = unordered.collect { |e| [compute, e] }. + sort { |a,b| a[0] <=> b[0] }. + collect { |e| e[1] } + +for employee in employees.sort { |a,b| a.name <=> b.name } + print employee.name, " earns \$ ", employee.salary, "\n" +end + +# Beware! `0' is true in Ruby. +# For chaining comparisons, you may use Numeric#nonzero?, which +# returns num if num is not zero, nil otherwise +sorted = employees.sort { |a,b| (a.name <=> b.name).nonzero? || b.age <=> a.age } + +users = [] +# getpwent is not wrapped in Ruby... let's fallback +IO.readlines('/etc/passwd').each { |u| users << u.split(':') } +users.sort! { |a,b| a[0] <=> b[0] } +for user in users + puts user[0] +end + +sorted = names.sort { |a,b| a[1, 1] <=> b[1, 1] } +sorted = strings.sort { |a,b| a.length <=> b.length } + +# let's show only the compact version +ordered = strings.collect { |e| [e.length, e] }. + sort { |a,b| a[0] <=> b[0] }. + collect { |e| e[1] } + +ordered = strings.collect { |e| [/\d+/.match(e)[0].to_i, e] }. + sort { |a,b| a[0] <=> b[0] }. + collect { |e| e[1] } + +print `cat /etc/passwd`.collect { |e| [e, e.split(':').indexes(3,2,0)].flatten }. + sort { |a,b| (a[1] <=> b[1]).nonzero? || (a[2] <=> b[2]).nonzero? || a[3] <=> b[3] }. + collect { |e| e[0] } + + +# @@PLEAC@@_4.16 +circular.unshift(circular.pop) # the last shall be first +circular.push(circular.shift) # and vice versa + +def grab_and_rotate(l) + l.push(ret = l.shift) + ret +end + +processes = [1, 2, 3, 4, 5] +while (1) + process = grab_and_rotate(processes) + puts "Handling process #{process}" + sleep 1 +end + + +# @@PLEAC@@_4.17 +def fisher_yates_shuffle(a) + (a.size-1).downto(1) { |i| + j = rand(i+1) + a[i], a[j] = a[j], a[i] if i != j + } +end + +def naive_shuffle(a) + for i in 0...a.size + j = rand(a.size) + a[i], a[j] = a[j], a[i] + end +end + + + +---tokens--- +'# -*- ruby -*-' Comment.Single +'\n\n' Text + +'# Local variables:' Comment.Single +'\n' Text + +'# indent-tabs-mode: nil' Comment.Single +'\n' Text + +'# ruby-indent-level: 4' Comment.Single +'\n' Text + +'# End:' Comment.Single +'\n\n' Text + +'# @@PLEAC@@_NAME' Comment.Single +'\n' Text + +'# @@SKIP@@ Ruby' Comment.Single +'\n\n' Text + +'# @@PLEAC@@_WEB' Comment.Single +'\n' Text + +'# @@SKIP@@ http://www.ruby-lang.org' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_1.0' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +"'" Literal.String.Single +'\\n' Literal.String.Escape +"'" Literal.String.Single +' ' Text +'# two characters, \\ and an n' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +"'" Literal.String.Single +'Jon ' Literal.String.Single +"\\'" Literal.String.Escape +'Maddog' Literal.String.Single +"\\'" Literal.String.Escape +' Orwant' Literal.String.Single +"'" Literal.String.Single +' ' Text +'# literal single quotes' Comment.Single +'\n\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# a "newline" character' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'Jon ' Literal.String.Double +'\\"' Literal.String.Escape +'Maddog' Literal.String.Double +'\\"' Literal.String.Escape +' Orwant' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# literal double quotes' Comment.Single +'\n\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +"%q/Jon 'Maddog' Orwant/" Literal.String.Other +' ' Text +'# literal single quotes' Comment.Single +'\n\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'%q[' Literal.String.Other +"Jon 'Maddog' Orwant" Literal.String.Other +']' Literal.String.Other +' ' Text +'# literal single quotes' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'%q{' Literal.String.Other +"Jon 'Maddog' Orwant" Literal.String.Other +'}' Literal.String.Other +' ' Text +'# literal single quotes' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'%q(' Literal.String.Other +"Jon 'Maddog' Orwant" Literal.String.Other +')' Literal.String.Other +' ' Text +'# literal single quotes' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'%q<' Literal.String.Other +"Jon 'Maddog' Orwant" Literal.String.Other +'>' Literal.String.Other +' ' Text +'# literal single quotes' Comment.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'<<' Operator +'"' Literal.String.Heredoc +'EOF' Literal.String.Delimiter +'"' Literal.String.Heredoc +'\n' Text + +'This is a multiline here document\n' Literal.String.Heredoc + +'terminated by EOF on a line by itself\n' Literal.String.Heredoc + +'EOF\n' Literal.String.Delimiter + +'\n\n' Text + +'# @@PLEAC@@_1.1' Comment.Single +'\n' Text + +'value' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'offset' Name +',' Punctuation +'count' Name +']' Operator +'\n' Text + +'value' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'offset' Name +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +'\n\n' Text + +'string' Name +'[' Operator +'offset' Name +',' Punctuation +'count' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'newstring' Name +'\n' Text + +'string' Name +'[' Operator +'offset' Name +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'newtail' Name +'\n\n' Text + +'# in Ruby we can also specify intervals by their two offsets' Comment.Single +'\n' Text + +'value' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'offset' Name +'..' Operator +'offs2' Name +']' Operator +'\n' Text + +'string' Name +'[' Operator +'offset' Name +'..' Operator +'offs2' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'newstring' Name +'\n\n' Text + +'leading' Name +',' Punctuation +' ' Text +'s1' Name +',' Punctuation +' ' Text +'s2' Name +',' Punctuation +' ' Text +'trailing' Name +' ' Text +'=' Operator +' ' Text +'data' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'A5 x3 A8 A8 A*' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n' Text + +'fivers' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'A5' Literal.String.Double +'"' Literal.String.Double +' ' Text +'*' Operator +' ' Text +'(' Punctuation +'string' Name +'.' Operator +'length' Name +'/' Operator +'5' Literal.Number.Integer +')' Punctuation +')' Punctuation +'\n\n' Text + +'chars' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'A1' Literal.String.Double +'"' Literal.String.Double +' ' Text +'*' Operator +' ' Text +'string' Name +'.' Operator +'length' Name +')' Punctuation +'\n\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'This is what you have' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'# +012345678901234567890 Indexing forwards (left to right)' Comment.Single +'\n' Text + +'# 109876543210987654321- Indexing backwards (right to left)' Comment.Single +'\n' Text + +'# note that 0 means 10 or 20, etc. above' Comment.Single +'\n\n' Text + +'first' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +' ' Text +'# "T"' Comment.Single +'\n' Text + +'start' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'5' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +']' Operator +' ' Text +'# "is"' Comment.Single +'\n' Text + +'rest' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'13' Literal.Number.Integer +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'# "you have"' Comment.Single +'\n' Text + +'last' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'-' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +' ' Text +'# "e"' Comment.Single +'\n' Text + +'end_' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'-' Operator +'4' Literal.Number.Integer +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'# "have"' Comment.Single +'\n' Text + +'piece' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'-' Operator +'8' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +']' Operator +' ' Text +'# "you"' Comment.Single +'\n\n' Text + +'string' Name +'[' Operator +'5' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +"wasn't" Literal.String.Double +'"' Literal.String.Double +' ' Text +'# change "is" to "wasn\'t"' Comment.Single +'\n' Text + +'string' Name +'[' Operator +'-' Operator +'12' Literal.Number.Integer +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'ondrous' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# "This wasn\'t wondrous"' Comment.Single +'\n' Text + +'string' Name +'[' Operator +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# delete first character' Comment.Single +'\n' Text + +'string' Name +'[' Operator +'-' Operator +'10' Literal.Number.Integer +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# delete last 10 characters' Comment.Single +'\n\n' Text + +'if' Keyword +' ' Text +'string' Name +'[' Operator +'-' Operator +'10' Literal.Number.Integer +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'pattern' Literal.String.Regex +'/' Literal.String.Regex +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Pattern matches in last 10 characters' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'string' Name +'[' Operator +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'5' Literal.Number.Integer +']' Operator +'.' Operator +'gsub!' Name +'(' Punctuation +'/' Literal.String.Regex +'is' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +"'" Literal.String.Single +'at' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'make a hat' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'a' Name +'[' Operator +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +',' Punctuation +' ' Text +'a' Name +'[' Operator +'-' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'a' Name +'[' Operator +'-' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +',' Punctuation +' ' Text +'a' Name +'[' Operator +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'To be or not to be' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'b' Name +' ' Text +'=' Operator +' ' Text +'a' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'x6 A6' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n' Text + +'b' Name +',' Punctuation +' ' Text +'c' Name +' ' Text +'=' Operator +' ' Text +'a' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'x6 A2 X5 A2' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'b' Name +'}' Literal.String.Interpol +'\\n' Literal.String.Escape +'#{' Literal.String.Interpol +'c' Name +'}' Literal.String.Interpol +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n\n' Text + +'def' Keyword +' ' Text +'cut2fmt' Name.Function +'(' Punctuation +'*' Operator +'args' Name +')' Punctuation +'\n ' Text +'template' Name +' ' Text +'=' Operator +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +'\n ' Text +'lastpos' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'for' Keyword +' ' Text +'place' Name +' ' Text +'in' Keyword +' ' Text +'args' Name +'\n ' Text +'template' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'A' Literal.String.Double +'"' Literal.String.Double +' ' Text +'+' Operator +' ' Text +'(' Punctuation +'place' Name +' ' Text +'-' Operator +' ' Text +'lastpos' Name +')' Punctuation +'.' Operator +'to_s' Name +' ' Text +'+' Operator +' ' Text +'"' Literal.String.Double +' ' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'lastpos' Name +' ' Text +'=' Operator +' ' Text +'place' Name +'\n ' Text +'end' Keyword +'\n ' Text +'template' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'A*' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'return' Keyword +' ' Text +'template' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'fmt' Name +' ' Text +'=' Operator +' ' Text +'cut2fmt' Name +'(' Punctuation +'8' Literal.Number.Integer +',' Punctuation +' ' Text +'14' Literal.Number.Integer +',' Punctuation +' ' Text +'20' Literal.Number.Integer +',' Punctuation +' ' Text +'26' Literal.Number.Integer +',' Punctuation +' ' Text +'30' Literal.Number.Integer +')' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_1.2' Comment.Single +'\n' Text + +'# careful! "b is true" doesn\'t mean "b != 0" (0 is true in Ruby)' Comment.Single +'\n' Text + +'# thus no problem of "defined" later since only nil is false' Comment.Single +'\n' Text + +"# the following sets to `c' if `b' is nil or false" Comment.Single +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'b' Name +' ' Text +'||' Operator +' ' Text +'c' Name +'\n\n' Text + +"# if you need Perl's behaviour (setting to `c' if `b' is 0) the most" Comment.Single +'\n' Text + +'# effective way is to use Numeric#nonzero? (thanks to Dave Thomas!)' Comment.Single +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'b' Name +'.' Operator +'nonzero?' Name +' ' Text +'||' Operator +' ' Text +'c' Name +'\n\n' Text + +'# you will still want to use defined? in order to test' Comment.Single +'\n' Text + +'# for scope existence of a given object' Comment.Single +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'defined?' Name +'(' Punctuation +'b' Name +')' Punctuation +' ' Text +'?' Punctuation +' ' Text +'b' Name +' ' Text +':' Punctuation +' ' Text +'c' Name +'\n\n' Text + +'dir' Name +' ' Text +'=' Operator +' ' Text +'ARGV' Name.Constant +'.' Operator +'shift' Name +' ' Text +'||' Operator +' ' Text +'"' Literal.String.Double +'/tmp' Literal.String.Double +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_1.3' Comment.Single +'\n' Text + +'v1' Name +',' Punctuation +' ' Text +'v2' Name +' ' Text +'=' Operator +' ' Text +'v2' Name +',' Punctuation +' ' Text +'v1' Name +'\n\n' Text + +'alpha' Name +',' Punctuation +' ' Text +'beta' Name +',' Punctuation +' ' Text +'production' Name +' ' Text +'=' Operator +' ' Text +'%w(' Literal.String.Other +'January March August' Literal.String.Other +')' Literal.String.Other +'\n' Text + +'alpha' Name +',' Punctuation +' ' Text +'beta' Name +',' Punctuation +' ' Text +'production' Name +' ' Text +'=' Operator +' ' Text +'beta' Name +',' Punctuation +' ' Text +'production' Name +',' Punctuation +' ' Text +'alpha' Name +'\n\n\n' Text + +'# @@PLEAC@@_1.4' Comment.Single +'\n' Text + +'num' Name +' ' Text +'=' Operator +' ' Text +'char' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +'\n' Text + +'char' Name +' ' Text +'=' Operator +' ' Text +'num' Name +'.' Operator +'chr' Name +'\n\n' Text + +'# Ruby also supports having a char from character constant' Comment.Single +'\n' Text + +'num' Name +' ' Text +'=' Operator +' ' Text +'?r' Literal.String.Char +'\n\n' Text + +'char' Name +' ' Text +'=' Operator +' ' Text +'sprintf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'%c' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'num' Name +')' Punctuation +'\n' Text + +'printf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'Number %d is character %c' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'num' Name +',' Punctuation +' ' Text +'num' Name +')' Punctuation +'\n\n' Text + +'ascii' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'C*' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'ascii' Name +'.' Operator +'pack' Name +'(' Punctuation +'"' Literal.String.Double +'C*' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n' Text + +'hal' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'HAL' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'ascii' Name +' ' Text +'=' Operator +' ' Text +'hal' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'C*' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +"# We can't use Array#each since we can't mutate a Fixnum" Comment.Single +'\n' Text + +'ascii' Name +'.' Operator +'collect!' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'i' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'# add one to each ASCII value' Comment.Single +'\n' Text + +'}' Punctuation +' \n' Text + +'ibm' Name +' ' Text +'=' Operator +' ' Text +'ascii' Name +'.' Operator +'pack' Name +'(' Punctuation +'"' Literal.String.Double +'C*' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'puts' Name.Builtin +' ' Text +'ibm' Name +'\n\n\n' Text + +'# @@PLEAC@@_1.5' Comment.Single +'\n' Text + +'array' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'.' Operator +'split' Name +'(' Punctuation +"'" Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n\n' Text + +'array' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'C*' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n' Text + +'string' Name +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +'.' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'b' Name +'|' Operator +'\n ' Text +'# do something with b' Comment.Single +'\n' Text + +'}' Punctuation +'\n\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'an apple a day' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'unique chars are: ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'string' Name +'.' Operator +'split' Name +'(' Punctuation +"'" Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'.' Operator +'uniq' Name +'.' Operator +'sort' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n\n' Text + +'sum' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n' Text + +'for' Keyword +' ' Text +'ascval' Name +' ' Text +'in' Keyword +' ' Text +'string' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'C*' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'# or use Array#each for a pure OO style :)' Comment.Single +'\n ' Text +'sum' Name +' ' Text +'+=' Operator +' ' Text +'ascval' Name +'\n' Text + +'end' Keyword +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'sum is ' Literal.String.Double +'#{' Literal.String.Interpol +'sum' Name +' ' Text +'&' Operator +' ' Text +'0xffffffff' Literal.Number.Hex +'}' Literal.String.Interpol +'"' Literal.String.Double +' ' Text +'# since Ruby will go Bignum if necessary' Comment.Single +'\n\n' Text + +'# @@INCLUDE@@ include/ruby/slowcat.rb' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_1.6' Comment.Single +'\n' Text + +'revbytes' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'.' Operator +'reverse' Name +'\n\n' Text + +'revwords' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'.' Operator +'split' Name +'(' Punctuation +'"' Literal.String.Double +' ' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'.' Operator +'reverse' Name +'.' Operator +'join' Name +'(' Punctuation +'"' Literal.String.Double +' ' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n' Text + +'revwords' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'.' Operator +'split' Name +'(' Punctuation +'/' Literal.String.Regex +'(' Literal.String.Regex +'\\' Literal.String.Regex +'s+)' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'.' Operator +'reverse' Name +'.' Operator +'join' Name +'\n\n' Text + +'# using the fact that IO is Enumerable, you can directly "select" it' Comment.Single +'\n' Text + +'long_palindromes' Name +' ' Text +'=' Operator +' ' Text +'File' Name.Constant +'.' Operator +'open' Name +'(' Punctuation +'"' Literal.String.Double +'/usr/share/dict/words' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'.' Operator +'\n ' Text +'select' Name.Builtin +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'w' Name +'|' Operator +' ' Text +'w' Name +'.' Operator +'chomp!' Name +';' Punctuation +' ' Text +'w' Name +'.' Operator +'reverse' Name +' ' Text +'==' Operator +' ' Text +'w' Name +' ' Text +'&&' Operator +' ' Text +'w' Name +'.' Operator +'length' Name +' ' Text +'>' Operator +' ' Text +'5' Literal.Number.Integer +' ' Text +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_1.7' Comment.Single +'\n' Text + +'while' Keyword +' ' Text +'string' Name +'.' Operator +'sub!' Name +'(' Punctuation +'"' Literal.String.Double +'\\t' Literal.String.Escape +'+' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +"'" Literal.String.Single +' ' Literal.String.Single +"'" Literal.String.Single +' ' Text +'*' Operator +' ' Text +'(' Punctuation +'$&' Name.Variable.Global +'.' Operator +'length' Name +' ' Text +'*' Operator +' ' Text +'8' Literal.Number.Integer +' ' Text +'-' Operator +' ' Text +'$`' Name.Variable.Global +'.' Operator +'length' Name +' ' Text +'%' Operator +' ' Text +'8' Literal.Number.Integer +')' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_1.8' Comment.Single +'\n' Text + +"'" Literal.String.Single +'You owe ' Literal.String.Single +'#{' Literal.String.Interpol +'debt' Name +'}' Literal.String.Interpol +' to me' Literal.String.Single +"'" Literal.String.Single +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'#{' Literal.String.Interpol +'(' Punctuation +'\\' Punctuation +'w' Name +'+' Operator +')' Punctuation +'}' Literal.String.Interpol +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'eval' Name.Builtin +'(' Punctuation +'$1' Name.Variable.Global +')' Punctuation +' ' Text +'}' Punctuation +'\n\n' Text + +'rows' Name +',' Punctuation +' ' Text +'cols' Name +' ' Text +'=' Operator +' ' Text +'24' Literal.Number.Integer +',' Punctuation +' ' Text +'80' Literal.Number.Integer +'\n' Text + +'text' Name +' ' Text +'=' Operator +' ' Text +'%q(' Literal.String.Other +'I am ' Literal.String.Other +'#' Literal.String.Other +'{rows} high and ' Literal.String.Other +'#' Literal.String.Other +'{cols} long' Literal.String.Other +')' Literal.String.Other +'\n' Text + +'text' Name +'.' Operator +'gsub!' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'#{' Literal.String.Interpol +'(' Punctuation +'\\' Punctuation +'w' Name +'+' Operator +')' Punctuation +'}' Literal.String.Interpol +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'eval' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'#{' Literal.String.Interpol +'$1' Name.Variable.Global +'}' Literal.String.Interpol +'"' Literal.String.Double +')' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'puts' Name.Builtin +' ' Text +'text' Name +'\n\n' Text + +"'" Literal.String.Single +'I am 17 years old' Literal.String.Single +"'" Literal.String.Single +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'d+' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'2' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'$&' Name.Variable.Global +'.' Operator +'to_i' Name +' ' Text +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_1.9' Comment.Single +'\n' Text + +'e' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'bo peep' Literal.String.Double +'"' Literal.String.Double +'.' Operator +'upcase' Name +'\n' Text + +'e' Name +'.' Operator +'downcase!' Name +'\n' Text + +'e' Name +'.' Operator +'capitalize!' Name +'\n\n' Text + +'"' Literal.String.Double +'thIS is a loNG liNE' Literal.String.Double +'"' Literal.String.Double +'.' Operator +'gsub!' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'w+' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'$&' Name.Variable.Global +'.' Operator +'capitalize' Name +' ' Text +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_1.10' Comment.Single +'\n' Text + +'"' Literal.String.Double +'I have ' Literal.String.Double +'#{' Literal.String.Interpol +'n' Name +'+' Operator +'1' Literal.Number.Integer +'}' Literal.String.Interpol +' guanacos.' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'I have ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'n' Name +'+' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'"' Literal.String.Double +' guanacos.' Literal.String.Double +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_1.11' Comment.Single +'\n' Text + +'var' Name +' ' Text +'=' Operator +' ' Text +'<<' Operator +"'" Literal.String.Heredoc +'EOF' Literal.String.Delimiter +"'" Literal.String.Heredoc +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'^' Literal.String.Regex +'\\' Literal.String.Regex +'s+' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n' Text + +' your text\n' Literal.String.Heredoc + +' goes here\n' Literal.String.Heredoc + +'EOF\n' Literal.String.Delimiter + +'\n\n' Text + +'# @@PLEAC@@_1.12' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'Folding and splicing is the work of an editor,' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'+' Operator +'\n ' Text +'"' Literal.String.Double +'not a mere collection of silicon' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'+' Operator +' \n ' Text +'"' Literal.String.Double +'and' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'+' Operator +'\n ' Text +'"' Literal.String.Double +'mobile electrons!' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'def' Keyword +' ' Text +'wrap' Name.Function +'(' Punctuation +'str' Name +',' Punctuation +' ' Text +'max_size' Name +')' Punctuation +'\n ' Text +'all' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +'\n ' Text +'line' Name +' ' Text +'=' Operator +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +'\n ' Text +'for' Keyword +' ' Text +'l' Name +' ' Text +'in' Keyword +' ' Text +'str' Name +'.' Operator +'split' Name +'\n ' Text +'if' Keyword +' ' Text +'(' Punctuation +'line' Name +'+' Operator +'l' Name +')' Punctuation +'.' Operator +'length' Name +' ' Text +'>' Operator +'=' Operator +' ' Text +'max_size' Name +'\n ' Text +'all' Name +'.' Operator +'push' Name +'(' Punctuation +'line' Name +')' Punctuation +'\n ' Text +'line' Name +' ' Text +'=' Operator +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +'\n ' Text +'end' Keyword +'\n ' Text +'line' Name +' ' Text +'+=' Operator +' ' Text +'line' Name +' ' Text +'==' Operator +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +' ' Text +'?' Punctuation +' ' Text +'l' Name +' ' Text +':' Punctuation +' ' Text +"'" Literal.String.Single +' ' Literal.String.Single +"'" Literal.String.Single +' ' Text +'+' Operator +' ' Text +'l' Name +'\n ' Text +'end' Keyword +'\n ' Text +'all' Name +'.' Operator +'push' Name +'(' Punctuation +'line' Name +')' Punctuation +'.' Operator +'join' Name +'(' Punctuation +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'print' Name.Builtin +' ' Text +'wrap' Name +'(' Punctuation +'string' Name +',' Punctuation +' ' Text +'20' Literal.Number.Integer +')' Punctuation +'\n' Text + +'#=> Folding and ' Comment.Single +'\n' Text + +'#=> splicing is the ' Comment.Single +'\n' Text + +'#=> work of an editor, ' Comment.Single +'\n' Text + +'#=> not a mere ' Comment.Single +'\n' Text + +'#=> collection of ' Comment.Single +'\n' Text + +'#=> silicon and mobile ' Comment.Single +'\n' Text + +'#=> electrons!' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_1.13' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'%q(' Literal.String.Other +'Mom said, "Don\'t do that."' Literal.String.Other +')' Literal.String.Other +'\n' Text + +'string' Name +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'[\'"]' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +"'" Literal.String.Single +'\\\\' Literal.String.Escape +"'" Literal.String.Single +'+' Operator +'$&' Name.Variable.Global +' ' Text +'}' Punctuation +'\n' Text + +'string' Name +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'[\'"]' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +"'" Literal.String.Single +'\\' Literal.String.Single +'&' Literal.String.Single +'\\' Literal.String.Single +'&' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n' Text + +'string' Name +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'[^A-Z]' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +"'" Literal.String.Single +'\\\\' Literal.String.Escape +"'" Literal.String.Single +'+' Operator +'$&' Name.Variable.Global +' ' Text +'}' Punctuation +'\n' Text + +'"' Literal.String.Double +'is a test!' Literal.String.Double +'"' Literal.String.Double +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'W' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +"'" Literal.String.Single +'\\\\' Literal.String.Escape +"'" Literal.String.Single +'+' Operator +'$&' Name.Variable.Global +' ' Text +'}' Punctuation +' ' Text +'# no function like quotemeta?' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_1.14' Comment.Single +'\n' Text + +'string' Name +'.' Operator +'strip!' Name +'\n\n\n' Text + +'# @@PLEAC@@_1.15' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'parse_csv' Name.Function +'(' Punctuation +'text' Name +')' Punctuation +'\n ' Text +'new' Keyword.Pseudo +' ' Text +'=' Operator +' ' Text +'text' Name +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +'"([^' Literal.String.Regex +'\\' Literal.String.Regex +'"' Literal.String.Regex +'\\\\' Literal.String.Regex +']*(?:' Literal.String.Regex +'\\\\' Literal.String.Regex +'.[^' Literal.String.Regex +'\\' Literal.String.Regex +'"' Literal.String.Regex +'\\\\' Literal.String.Regex +']*)*)",?|([^,]+),?|,' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'\n ' Text +'new' Keyword.Pseudo +' ' Text +'<<' Operator +' ' Text +'nil' Keyword.Pseudo +' ' Text +'if' Keyword +' ' Text +'text' Name +'[' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'==' Operator +' ' Text +'?,' Literal.String.Char +'\n ' Text +'new' Keyword.Pseudo +'.' Operator +'flatten' Name +'.' Operator +'compact' Name +'\n' Text + +'end' Keyword +' \n\n' Text + +'line' Name +' ' Text +'=' Operator +' ' Text +'%q<' Literal.String.Other +'XYZZY,"","O\'Reilly, Inc","Wall, Larry","a ' Literal.String.Other +'\\' Literal.String.Other +'"glug' Literal.String.Other +'\\' Literal.String.Other +'" bit,",5,"Error, Core Dumped"' Literal.String.Other +'>' Literal.String.Other +'\n' Text + +'fields' Name +' ' Text +'=' Operator +' ' Text +'parse_csv' Name +'(' Punctuation +'line' Name +')' Punctuation +'\n' Text + +'fields' Name +'.' Operator +'each_with_index' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'v' Name +',' Punctuation +'i' Name +'|' Operator +'\n ' Text +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'i' Name +'}' Literal.String.Interpol +' : ' Literal.String.Double +'#{' Literal.String.Interpol +'v' Name +'}' Literal.String.Interpol +'\\n' Literal.String.Escape +'"' Literal.String.Double +';' Punctuation +'\n' Text + +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_1.16' Comment.Single +'\n' Text + +'# Use the soundex.rb Library from Michael Neumann.' Comment.Single +'\n' Text + +'# http://www.s-direktnet.de/homepages/neumann/rb_prgs/Soundex.rb' Comment.Single +'\n' Text + +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'Soundex' Literal.String.Single +"'" Literal.String.Single +'\n\n' Text + +'code' Name +' ' Text +'=' Operator +' ' Text +'Text' Name.Constant +'::' Operator +'Soundex' Name.Constant +'.' Operator +'soundex' Name +'(' Punctuation +'string' Name +')' Punctuation +'\n' Text + +'codes' Name +' ' Text +'=' Operator +' ' Text +'Text' Name.Constant +'::' Operator +'Soundex' Name.Constant +'.' Operator +'soundex' Name +'(' Punctuation +'array' Name +')' Punctuation +'\n\n' Text + +'# substitution function for getpwent():' Comment.Single +'\n' Text + +'# returns an array of user entries,' Comment.Single +'\n' Text + +'# each entry contains the username and the full name' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'login_names' Name.Function +'\n ' Text +'result' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +'\n ' Text +'File' Name.Constant +'.' Operator +'open' Name +'(' Punctuation +'"' Literal.String.Double +'/etc/passwd' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'file' Name +'|' Operator +'\n ' Text +'file' Name +'.' Operator +'each_line' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'line' Name +'|' Operator +'\n ' Text +'next' Keyword +' ' Text +'if' Keyword +' ' Text +'line' Name +'.' Operator +'match' Name +'(' Punctuation +'/' Literal.String.Regex +'^' Literal.String.Regex +'#' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'\n ' Text +'cols' Name +' ' Text +'=' Operator +' ' Text +'line' Name +'.' Operator +'split' Name +'(' Punctuation +'"' Literal.String.Double +':' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'result' Name +'.' Operator +'push' Name +'(' Punctuation +'[' Operator +'cols' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +',' Punctuation +' ' Text +'cols' Name +'[' Operator +'4' Literal.Number.Integer +']' Operator +']' Operator +')' Punctuation +'\n ' Text +'}' Punctuation +'\n ' Text +'}' Punctuation +'\n ' Text +'result' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Lookup user: ' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'user' Name +' ' Text +'=' Operator +' ' Text +'STDIN' Name.Constant +'.' Operator +'gets' Name +'\n' Text + +'user' Name +'.' Operator +'chomp!' Name +'\n' Text + +'exit' Name.Builtin +' ' Text +'unless' Keyword +' ' Text +'user' Name +'\n' Text + +'name_code' Name +' ' Text +'=' Operator +' ' Text +'Text' Name.Constant +'::' Operator +'Soundex' Name.Constant +'.' Operator +'soundex' Name +'(' Punctuation +'user' Name +')' Punctuation +'\n\n' Text + +'splitter' Name +' ' Text +'=' Operator +' ' Text +'Regexp' Name.Constant +'.' Operator +'new' Name +'(' Punctuation +"'" Literal.String.Single +'(' Literal.String.Single +'\\' Literal.String.Single +'w+)[^,]*' Literal.String.Single +'\\b' Literal.String.Escape +'(' Literal.String.Single +'\\' Literal.String.Single +'w+)' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n' Text + +'for' Keyword +' ' Text +'username' Name +',' Punctuation +' ' Text +'fullname' Name +' ' Text +'in' Keyword +' ' Text +'login_names' Name +' ' Text +'do' Keyword +'\n ' Text +'firstname' Name +',' Punctuation +' ' Text +'lastname' Name +' ' Text +'=' Operator +' ' Text +'splitter' Name +'.' Operator +'match' Name +'(' Punctuation +'fullname' Name +')' Punctuation +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +'2' Literal.Number.Integer +']' Operator +'\n ' Text +'if' Keyword +' ' Text +'name_code' Name +' ' Text +'==' Operator +' ' Text +'Text' Name.Constant +'::' Operator +'Soundex' Name.Constant +'.' Operator +'soundex' Name +'(' Punctuation +'username' Name +')' Punctuation +'\n ' Text +'||' Operator +' ' Text +'name_code' Name +' ' Text +'==' Operator +' ' Text +'Text' Name.Constant +'::' Operator +'Soundex' Name.Constant +'.' Operator +'soundex' Name +'(' Punctuation +'firstname' Name +')' Punctuation +'\n ' Text +'||' Operator +' ' Text +'name_code' Name +' ' Text +'==' Operator +' ' Text +'Text' Name.Constant +'::' Operator +'Soundex' Name.Constant +'.' Operator +'soundex' Name +'(' Punctuation +'lastname' Name +')' Punctuation +'\n ' Text +'then' Keyword +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'username' Name +'}' Literal.String.Interpol +': ' Literal.String.Double +'#{' Literal.String.Interpol +'firstname' Name +'}' Literal.String.Interpol +' ' Literal.String.Double +'#{' Literal.String.Interpol +'lastname' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_1.17' Comment.Single +'\n' Text + +'# @@INCLUDE@@ include/ruby/fixstyle.rb' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_1.18' Comment.Single +'\n' Text + +'# @@INCLUDE@@ include/ruby/psgrep.rb' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_2.1' Comment.Single +'\n' Text + +'# Matz tells that you can use Integer() for strict checked conversion.' Comment.Single +'\n' Text + +'Integer' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'abc' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'#=> `Integer\': invalid value for Integer: "abc" (ArgumentError)' Comment.Single +'\n' Text + +'Integer' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'567' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'#=> 567' Comment.Single +'\n\n' Text + +'# You may use Float() for floating point stuff' Comment.Single +'\n' Text + +'Integer' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'56.7' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'#=> `Integer\': invalid value for Integer: "56.7" (ArgumentError)' Comment.Single +'\n' Text + +'Float' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'56.7' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'#=> 56.7' Comment.Single +'\n\n' Text + +'# You may also use a regexp for that' Comment.Single +'\n' Text + +'if' Keyword +' ' Text +'string' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^[+-]?' Literal.String.Regex +'\\' Literal.String.Regex +'d+$' Literal.String.Regex +'/' Literal.String.Regex +'\n ' Text +'p' Name.Builtin +' ' Text +"'" Literal.String.Single +'is an integer' Literal.String.Single +"'" Literal.String.Single +'\n' Text + +'else' Keyword +'\n ' Text +'p' Name.Builtin +' ' Text +"'" Literal.String.Single +'is not' Literal.String.Single +"'" Literal.String.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'if' Keyword +' ' Text +'string' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^-?(?:' Literal.String.Regex +'\\' Literal.String.Regex +'d+(?:' Literal.String.Regex +'\\' Literal.String.Regex +'.' Literal.String.Regex +'\\' Literal.String.Regex +'d*)?|' Literal.String.Regex +'\\' Literal.String.Regex +'.' Literal.String.Regex +'\\' Literal.String.Regex +'d+)$' Literal.String.Regex +'/' Literal.String.Regex +'\n ' Text +'p' Name.Builtin +' ' Text +"'" Literal.String.Single +'is a decimal number' Literal.String.Single +"'" Literal.String.Single +'\n' Text + +'else' Keyword +'\n ' Text +'p' Name.Builtin +' ' Text +"'" Literal.String.Single +'is not' Literal.String.Single +"'" Literal.String.Single +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_2.2' Comment.Single +'\n' Text + +'# equal(num1, num2, accuracy) : returns true if num1 and num2 are' Comment.Single +'\n' Text + +'# equal to accuracy number of decimal places' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'equal' Name.Function +'(' Punctuation +'i' Name +',' Punctuation +' ' Text +'j' Name +',' Punctuation +' ' Text +'a' Name +')' Punctuation +'\n ' Text +'sprintf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'%.' Literal.String.Double +'#{' Literal.String.Interpol +'a' Name +'}' Literal.String.Interpol +'g' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'i' Name +')' Punctuation +' ' Text +'==' Operator +' ' Text +'sprintf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'%.' Literal.String.Double +'#{' Literal.String.Interpol +'a' Name +'}' Literal.String.Interpol +'g' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'j' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'wage' Name +' ' Text +'=' Operator +' ' Text +'536' Literal.Number.Integer +' ' Text +'# $5.36/hour' Comment.Single +'\n' Text + +'week' Name +' ' Text +'=' Operator +' ' Text +'40' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'wage' Name +' ' Text +'# $214.40' Comment.Single +'\n' Text + +'printf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +"One week's wage is: " Literal.String.Double +'\\' Literal.String.Double +'$%.2f' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'week' Name +'/' Operator +'100' Literal.Number.Integer +'.' Operator +'0' Literal.Number.Integer +')' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_2.3' Comment.Single +'\n' Text + +'num' Name +'.' Operator +'round' Name +' ' Text +'# rounds to integer' Comment.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'.' Operator +'255' Literal.Number.Integer +'\n' Text + +'b' Name +' ' Text +'=' Operator +' ' Text +'sprintf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'%.2f' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'a' Name +')' Punctuation +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Unrounded: ' Literal.String.Double +'#{' Literal.String.Interpol +'a' Name +'}' Literal.String.Interpol +'\\n' Literal.String.Escape +'Rounded: ' Literal.String.Double +'#{' Literal.String.Interpol +'b' Name +'}' Literal.String.Interpol +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'printf' Name.Builtin +' ' Text +'"' Literal.String.Double +'Unrounded: ' Literal.String.Double +'#{' Literal.String.Interpol +'a' Name +'}' Literal.String.Interpol +'\\n' Literal.String.Escape +'Rounded: %.2f' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'a' Name +'\n\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'number' Literal.String.Double +'\\t' Literal.String.Escape +'int' Literal.String.Double +'\\t' Literal.String.Escape +'floor' Literal.String.Double +'\\t' Literal.String.Escape +'ceil' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'3' Literal.Number.Integer +'.' Operator +'3' Literal.Number.Integer +' ' Text +',' Punctuation +' ' Text +'3' Literal.Number.Integer +'.' Operator +'5' Literal.Number.Integer +' ' Text +',' Punctuation +' ' Text +'3' Literal.Number.Integer +'.' Operator +'7' Literal.Number.Integer +',' Punctuation +' ' Text +'-' Operator +'3' Literal.Number.Integer +'.' Operator +'3' Literal.Number.Integer +' ' Text +']' Operator +'\n' Text + +'for' Keyword +' ' Text +'n' Name +' ' Text +'in' Keyword +' ' Text +'a' Name +'\n ' Text +'printf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'% .1f' Literal.String.Double +'\\t' Literal.String.Escape +'% .1f' Literal.String.Double +'\\t' Literal.String.Escape +'% .1f' Literal.String.Double +'\\t' Literal.String.Escape +'% .1f' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +"# at least I don't fake my output :)" Comment.Single +'\n ' Text +'n' Name +',' Punctuation +' ' Text +'n' Name +'.' Operator +'to_i' Name +',' Punctuation +' ' Text +'n' Name +'.' Operator +'floor' Name +',' Punctuation +' ' Text +'n' Name +'.' Operator +'ceil' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_2.4' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'dec2bin' Name.Function +'(' Punctuation +'n' Name +')' Punctuation +'\n ' Text +'[' Operator +'n' Name +']' Operator +'.' Operator +'pack' Name +'(' Punctuation +'"' Literal.String.Double +'N' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'B32' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'[' Operator +'0' Literal.Number.Integer +']' Operator +'.' Operator +'sub' Name +'(' Punctuation +'/' Literal.String.Regex +'^0+(?=' Literal.String.Regex +'\\' Literal.String.Regex +'d)' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'bin2dec' Name.Function +'(' Punctuation +'n' Name +')' Punctuation +'\n ' Text +'[' Operator +'(' Punctuation +'"' Literal.String.Double +'0' Literal.String.Double +'"' Literal.String.Double +'*' Operator +'32' Literal.Number.Integer +'+' Operator +'n' Name +'.' Operator +'to_s' Name +')' Punctuation +'[' Operator +'-' Operator +'32' Literal.Number.Integer +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +']' Operator +'.' Operator +'pack' Name +'(' Punctuation +'"' Literal.String.Double +'B32' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'N' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'[' Operator +'0' Literal.Number.Integer +']' Operator +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_2.5' Comment.Single +'\n' Text + +'for' Keyword +' ' Text +'i' Name +' ' Text +'in' Keyword +' ' Text +'x' Name +' ' Text +'..' Operator +' ' Text +'y' Name +'\n ' Text +'# i is set to every integer from x to y, inclusive' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'x' Name +'.' Operator +'step' Name +'(' Punctuation +'y' Name +',' Punctuation +'7' Literal.Number.Integer +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'# i is set to every integer from x to y, stepsize = 7' Comment.Single +'\n' Text + +'}' Punctuation +'\n\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Infancy is: ' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'(' Punctuation +'0' Literal.Number.Integer +'..' Operator +'2' Literal.Number.Integer +')' Punctuation +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'print' Name.Builtin +' ' Text +'i' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +' ' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'}' Punctuation +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_2.6' Comment.Single +'\n' Text + +'# We can add conversion methods to the Integer class,' Comment.Single +'\n' Text + +'# this makes a roman number just a representation for normal numbers.' Comment.Single +'\n' Text + +'class' Keyword +' ' Text +'Integer' Name.Class +'\n \n ' Text +'@@romanlist' Name.Variable.Class +' ' Text +'=' Operator +' ' Text +'[' Operator +'[' Operator +'"' Literal.String.Double +'M' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'1000' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'CM' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'900' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'D' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'500' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'CD' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'400' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'C' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'100' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'XC' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'90' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'L' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'50' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'XL' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'40' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'X' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'10' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'IX' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'9' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'V' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'5' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'IV' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'4' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'I' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +']' Operator +'\n \n ' Text +'def' Keyword +' ' Text +'to_roman' Name.Function +'\n ' Text +'remains' Name +' ' Text +'=' Operator +' ' Text +'self' Name.Builtin +'\n ' Text +'roman' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'for' Keyword +' ' Text +'sym' Name +',' Punctuation +' ' Text +'num' Name +' ' Text +'in' Keyword +' ' Text +'@@romanlist' Name.Variable.Class +'\n ' Text +'while' Keyword +' ' Text +'remains' Name +' ' Text +'>' Operator +'=' Operator +' ' Text +'num' Name +'\n ' Text +'remains' Name +' ' Text +'-=' Operator +' ' Text +'num' Name +'\n ' Text +'roman' Name +' ' Text +'<<' Operator +' ' Text +'sym' Name +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n ' Text +'roman' Name +'\n ' Text +'end' Keyword +'\n \n ' Text +'def' Keyword +' ' Text +'Integer' Name.Class +'.' Operator +'from_roman' Name.Function +'(' Punctuation +'roman' Name +')' Punctuation +'\n ' Text +'ustr' Name +' ' Text +'=' Operator +' ' Text +'roman' Name +'.' Operator +'upcase' Name +'\n ' Text +'sum' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'for' Keyword +' ' Text +'entry' Name +' ' Text +'in' Keyword +' ' Text +'@@romanlist' Name.Variable.Class +'\n ' Text +'sym' Name +',' Punctuation +' ' Text +'num' Name +' ' Text +'=' Operator +' ' Text +'entry' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +',' Punctuation +' ' Text +'entry' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +'\n ' Text +'while' Keyword +' ' Text +'sym' Name +' ' Text +'==' Operator +' ' Text +'ustr' Name +'[' Operator +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'sym' Name +'.' Operator +'length' Name +']' Operator +'\n ' Text +'sum' Name +' ' Text +'+=' Operator +' ' Text +'num' Name +'\n ' Text +'ustr' Name +'.' Operator +'slice!' Name +'(' Punctuation +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'sym' Name +'.' Operator +'length' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n ' Text +'sum' Name +'\n ' Text +'end' Keyword +'\n \n' Text + +'end' Keyword +'\n\n\n' Text + +'roman_fifteen' Name +' ' Text +'=' Operator +' ' Text +'15' Literal.Number.Integer +'.' Operator +'to_roman' Name +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Roman for fifteen is ' Literal.String.Double +'#{' Literal.String.Interpol +'roman_fifteen' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n' Text + +'i' Name +' ' Text +'=' Operator +' ' Text +'Integer' Name.Builtin +'.' Operator +'from_roman' Name +'(' Punctuation +'roman_fifteen' Name +')' Punctuation +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Converted back, ' Literal.String.Double +'#{' Literal.String.Interpol +'roman_fifteen' Name +'}' Literal.String.Interpol +' is ' Literal.String.Double +'#{' Literal.String.Interpol +'i' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n\n' Text + +'# check' Comment.Single +'\n' Text + +'for' Keyword +' ' Text +'i' Name +' ' Text +'in' Keyword +' ' Text +'(' Punctuation +'1' Literal.Number.Integer +'..' Operator +'3900' Literal.Number.Integer +')' Punctuation +'\n ' Text +'r' Name +' ' Text +'=' Operator +' ' Text +'i' Name +'.' Operator +'to_roman' Name +'\n ' Text +'j' Name +' ' Text +'=' Operator +' ' Text +'Integer' Name.Builtin +'.' Operator +'from_roman' Name +'(' Punctuation +'r' Name +')' Punctuation +'\n ' Text +'if' Keyword +' ' Text +'i' Name +' ' Text +'!=' Operator +' ' Text +'j' Name +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'error: ' Literal.String.Double +'#{' Literal.String.Interpol +'i' Name +'}' Literal.String.Interpol +' : ' Literal.String.Double +'#{' Literal.String.Interpol +'r' Name +'}' Literal.String.Interpol +' - ' Literal.String.Double +'#{' Literal.String.Interpol +'j' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_2.7' Comment.Single +'\n' Text + +'random' Name +' ' Text +'=' Operator +' ' Text +'rand' Name.Builtin +'(' Punctuation +'y' Name +'-' Operator +'x' Name +'+' Operator +'1' Literal.Number.Integer +')' Punctuation +'+' Operator +'x' Name +'\n\n' Text + +'chars' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +'"' Literal.String.Double +'A' Literal.String.Double +'"' Literal.String.Double +'..' Operator +'"' Literal.String.Double +'Z' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +'"' Literal.String.Double +'a' Literal.String.Double +'"' Literal.String.Double +'..' Operator +'"' Literal.String.Double +'z' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +'"' Literal.String.Double +'0' Literal.String.Double +'"' Literal.String.Double +'..' Operator +'"' Literal.String.Double +'9' Literal.String.Double +'"' Literal.String.Double +']' Operator +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'r' Name +'|' Operator +' ' Text +'r' Name +'.' Operator +'to_a' Name +' ' Text +'}' Punctuation +'.' Operator +'join' Name +' ' Text +'+' Operator +' ' Text +'%q(' Literal.String.Other +'!@$%^&*' Literal.String.Other +')' Literal.String.Other +'\n' Text + +'password' Name +' ' Text +'=' Operator +' ' Text +'(' Punctuation +'1' Literal.Number.Integer +'..' Operator +'8' Literal.Number.Integer +')' Punctuation +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'chars' Name +'[' Operator +'rand' Name.Builtin +'(' Punctuation +'chars' Name +'.' Operator +'size' Name +')' Punctuation +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'pack' Name +'(' Punctuation +'"' Literal.String.Double +'C*' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_2.8' Comment.Single +'\n' Text + +'srand' Name.Builtin +' ' Text +'# uses a combination of the time, the process id, and a sequence number' Comment.Single +'\n' Text + +'srand' Name.Builtin +'(' Punctuation +'val' Name +')' Punctuation +' ' Text +'# for repeatable behaviour' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_2.9' Comment.Single +'\n' Text + +'# from the randomr lib: ' Comment.Single +'\n' Text + +'# http://raa.ruby-lang.org/project/randomr/' Comment.Single +'\n' Text + +'-' Operator +'-' Operator +'-' Operator +'-' Operator +'>' Operator +' ' Text +'http' Literal.String.Symbol +':' Punctuation +'/' Literal.String.Regex +'/' Literal.String.Regex +'raa' Name +'.' Operator +'ruby' Name +'-' Operator +'lang' Name +'.' Operator +'org' Name +'/' Operator +'project' Name +'/' Operator +'randomr' Name +'/' Operator +'\n\n' Text + +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'random/mersenne_twister' Literal.String.Single +"'" Literal.String.Single +'\n' Text + +'mers' Name +' ' Text +'=' Operator +' ' Text +'Random' Name.Constant +'::' Operator +'MersenneTwister' Name.Constant +'.' Operator +'new' Name +' ' Text +'123456789' Literal.Number.Integer +'\n' Text + +'puts' Name.Builtin +' ' Text +'mers' Name +'.' Operator +'rand' Name +'(' Punctuation +'0' Literal.Number.Integer +')' Punctuation +' ' Text +'# 0.550321932544541' Comment.Single +'\n' Text + +'puts' Name.Builtin +' ' Text +'mers' Name +'.' Operator +'rand' Name +'(' Punctuation +'10' Literal.Number.Integer +')' Punctuation +' ' Text +'# 2' Comment.Single +'\n\n' Text + +'# using online sources of random data via the realrand package:' Comment.Single +'\n' Text + +'# http://raa.ruby-lang.org/project/realrand/' Comment.Single +'\n' Text + +'# **Note**' Comment.Single +'\n' Text + +'# The following online services are used in this package:' Comment.Single +'\n' Text + +'# http://www.random.org - source: atmospheric noise ' Comment.Single +'\n' Text + +'# http://www.fourmilab.ch/hotbits - source: radioactive decay timings' Comment.Single +'\n' Text + +'# http://random.hd.org - source: entropy from local and network noise' Comment.Single +'\n' Text + +'# Please visit the sites and respect the rules of each service.' Comment.Single +'\n\n' Text + +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'random/online' Literal.String.Single +"'" Literal.String.Single +'\n\n' Text + +'generator1' Name +' ' Text +'=' Operator +' ' Text +'Random' Name.Constant +'::' Operator +'RandomOrg' Name.Constant +'.' Operator +'new' Name +'\n' Text + +'puts' Name.Builtin +' ' Text +'generator1' Name +'.' Operator +'randbyte' Name +'(' Punctuation +'5' Literal.Number.Integer +')' Punctuation +'.' Operator +'join' Name +'(' Punctuation +'"' Literal.String.Double +',' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'puts' Name.Builtin +' ' Text +'generator1' Name +'.' Operator +'randnum' Name +'(' Punctuation +'10' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'6' Literal.Number.Integer +')' Punctuation +'.' Operator +'join' Name +'(' Punctuation +'"' Literal.String.Double +',' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'# Roll dice 10 times.' Comment.Single +'\n\n' Text + +'generator2' Name +' ' Text +'=' Operator +' ' Text +'Random' Name.Constant +'::' Operator +'FourmiLab' Name.Constant +'.' Operator +'new' Name +'\n' Text + +'puts' Name.Builtin +' ' Text +'generator2' Name +'.' Operator +'randbyte' Name +'(' Punctuation +'5' Literal.Number.Integer +')' Punctuation +'.' Operator +'join' Name +'(' Punctuation +'"' Literal.String.Double +',' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'# randnum is not supported.' Comment.Single +'\n\n' Text + +'generator3' Name +' ' Text +'=' Operator +' ' Text +'Random' Name.Constant +'::' Operator +'EntropyPool' Name.Constant +'.' Operator +'new' Name +'\n' Text + +'puts' Name.Builtin +' ' Text +'generator3' Name +'.' Operator +'randbyte' Name +'(' Punctuation +'5' Literal.Number.Integer +')' Punctuation +'.' Operator +'join' Name +'(' Punctuation +'"' Literal.String.Double +',' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'# randnum is not supported.' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_2.10' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'gaussian_rand' Name.Function +'\n ' Text +'begin' Keyword +'\n ' Text +'u1' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'rand' Name.Builtin +'(' Punctuation +')' Punctuation +' ' Text +'-' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'u2' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'rand' Name.Builtin +'(' Punctuation +')' Punctuation +' ' Text +'-' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'w' Name +' ' Text +'=' Operator +' ' Text +'u1' Name +'*' Operator +'u1' Name +' ' Text +'+' Operator +' ' Text +'u2' Name +'*' Operator +'u2' Name +'\n ' Text +'end' Keyword +' ' Text +'while' Keyword +' ' Text +'(' Punctuation +'w' Name +' ' Text +'>' Operator +'=' Operator +' ' Text +'1' Literal.Number.Integer +')' Punctuation +'\n ' Text +'w' Name +' ' Text +'=' Operator +' ' Text +'Math' Name.Constant +'.' Operator +'sqrt' Name +'(' Punctuation +'(' Punctuation +'-' Operator +'2' Literal.Number.Integer +'*' Operator +'Math' Name.Constant +'.' Operator +'log' Name +'(' Punctuation +'w' Name +')' Punctuation +')' Punctuation +'/' Operator +'w' Name +')' Punctuation +'\n ' Text +'[' Operator +' ' Text +'u2' Name +'*' Operator +'w' Name +',' Punctuation +' ' Text +'u1' Name +'*' Operator +'w' Name +' ' Text +']' Operator +'\n' Text + +'end' Keyword +'\n\n' Text + +'mean' Name +' ' Text +'=' Operator +' ' Text +'25' Literal.Number.Integer +'\n' Text + +'sdev' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'salary' Name +' ' Text +'=' Operator +' ' Text +'gaussian_rand' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'*' Operator +' ' Text +'sdev' Name +' ' Text +'+' Operator +' ' Text +'mean' Name +'\n' Text + +'printf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'You have been hired at ' Literal.String.Double +'\\' Literal.String.Double +'$%.2f' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'salary' Name +')' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_2.11' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'deg2rad' Name.Function +'(' Punctuation +'d' Name +')' Punctuation +'\n ' Text +'(' Punctuation +'d' Name +'/' Operator +'180' Literal.Number.Integer +'.' Operator +'0' Literal.Number.Integer +')' Punctuation +'*' Operator +'Math' Name.Constant +'::' Operator +'PI' Name.Constant +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'rad2deg' Name.Function +'(' Punctuation +'r' Name +')' Punctuation +'\n ' Text +'(' Punctuation +'r' Name +'/' Operator +'Math' Name.Constant +'::' Operator +'PI' Name.Constant +')' Punctuation +'*' Operator +'180' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_2.12' Comment.Single +'\n' Text + +'sin_val' Name +' ' Text +'=' Operator +' ' Text +'Math' Name.Constant +'.' Operator +'sin' Name +'(' Punctuation +'angle' Name +')' Punctuation +'\n' Text + +'cos_val' Name +' ' Text +'=' Operator +' ' Text +'Math' Name.Constant +'.' Operator +'cos' Name +'(' Punctuation +'angle' Name +')' Punctuation +'\n' Text + +'tan_val' Name +' ' Text +'=' Operator +' ' Text +'Math' Name.Constant +'.' Operator +'tan' Name +'(' Punctuation +'angle' Name +')' Punctuation +'\n\n' Text + +"# AFAIK Ruby's Math module doesn't provide acos/asin" Comment.Single +'\n' Text + +"# While we're at it, let's also define missing hyperbolic functions" Comment.Single +'\n' Text + +'module' Keyword +' ' Text +'Math' Name.Namespace +'\n ' Text +'def' Keyword +' ' Text +'Math' Name.Class +'.' Operator +'asin' Name.Function +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'atan2' Name +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'sqrt' Name +'(' Punctuation +'1' Literal.Number.Integer +' ' Text +'-' Operator +' ' Text +'x' Name +'**' Operator +'2' Literal.Number.Integer +')' Punctuation +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'def' Keyword +' ' Text +'Math' Name.Class +'.' Operator +'acos' Name.Function +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'atan2' Name +'(' Punctuation +'sqrt' Name +'(' Punctuation +'1' Literal.Number.Integer +' ' Text +'-' Operator +' ' Text +'x' Name +'**' Operator +'2' Literal.Number.Integer +')' Punctuation +',' Punctuation +' ' Text +'x' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'def' Keyword +' ' Text +'Math' Name.Class +'.' Operator +'atan' Name.Function +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'atan2' Name +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'1' Literal.Number.Integer +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'def' Keyword +' ' Text +'Math' Name.Class +'.' Operator +'sinh' Name.Function +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'(' Punctuation +'exp' Name +'(' Punctuation +'x' Name +')' Punctuation +' ' Text +'-' Operator +' ' Text +'exp' Name +'(' Punctuation +'-' Operator +'x' Name +')' Punctuation +')' Punctuation +' ' Text +'/' Operator +' ' Text +'2' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n ' Text +'def' Keyword +' ' Text +'Math' Name.Class +'.' Operator +'cosh' Name.Function +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'(' Punctuation +'exp' Name +'(' Punctuation +'x' Name +')' Punctuation +' ' Text +'+' Operator +' ' Text +'exp' Name +'(' Punctuation +'-' Operator +'x' Name +')' Punctuation +')' Punctuation +' ' Text +'/' Operator +' ' Text +'2' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n ' Text +'def' Keyword +' ' Text +'Math' Name.Class +'.' Operator +'tanh' Name.Function +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'sinh' Name +'(' Punctuation +'x' Name +')' Punctuation +' ' Text +'/' Operator +' ' Text +'cosh' Name +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'# The support for Complex numbers is not built-in' Comment.Single +'\n' Text + +'y' Name +' ' Text +'=' Operator +' ' Text +'Math' Name.Constant +'.' Operator +'acos' Name +'(' Punctuation +'3' Literal.Number.Integer +'.' Operator +'7' Literal.Number.Integer +')' Punctuation +'\n' Text + +"#=> in `sqrt': square root for negative number (ArgumentError)" Comment.Single +'\n\n' Text + +"# There is an implementation of Complex numbers in 'complex.rb' in current" Comment.Single +'\n' Text + +"# Ruby distro, but it doesn't support atan2 with complex args, so it doesn't" Comment.Single +'\n' Text + +'# solve this problem.' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_2.13' Comment.Single +'\n' Text + +'log_e' Name +' ' Text +'=' Operator +' ' Text +'Math' Name.Constant +'.' Operator +'log' Name +'(' Punctuation +'val' Name +')' Punctuation +'\n' Text + +'log_10' Name +' ' Text +'=' Operator +' ' Text +'Math' Name.Constant +'.' Operator +'log10' Name +'(' Punctuation +'val' Name +')' Punctuation +'\n\n' Text + +'def' Keyword +' ' Text +'log_base' Name.Function +'(' Punctuation +'base' Name +',' Punctuation +' ' Text +'val' Name +')' Punctuation +'\n ' Text +'Math' Name.Constant +'.' Operator +'log' Name +'(' Punctuation +'val' Name +')' Punctuation +'/' Operator +'Math' Name.Constant +'.' Operator +'log' Name +'(' Punctuation +'base' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'answer' Name +' ' Text +'=' Operator +' ' Text +'log_base' Name +'(' Punctuation +'10' Literal.Number.Integer +',' Punctuation +' ' Text +'10_000' Literal.Number.Integer +')' Punctuation +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'log10(10,000) = ' Literal.String.Double +'#{' Literal.String.Interpol +'answer' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_2.14' Comment.Single +'\n' Text + +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'matrix.rb' Literal.String.Single +"'" Literal.String.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'Matrix' Name.Constant +'[' Operator +'[' Operator +'3' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +']' Operator +',' Punctuation +' ' Text +'[' Operator +'5' Literal.Number.Integer +',' Punctuation +' ' Text +'9' Literal.Number.Integer +',' Punctuation +' ' Text +'8' Literal.Number.Integer +']' Operator +']' Operator +'\n' Text + +'b' Name +' ' Text +'=' Operator +' ' Text +'Matrix' Name.Constant +'[' Operator +'[' Operator +'4' Literal.Number.Integer +',' Punctuation +' ' Text +'7' Literal.Number.Integer +']' Operator +',' Punctuation +' ' Text +'[' Operator +'9' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +']' Operator +',' Punctuation +' ' Text +'[' Operator +'8' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +']' Operator +'\n' Text + +'c' Name +' ' Text +'=' Operator +' ' Text +'a' Name +' ' Text +'*' Operator +' ' Text +'b' Name +'\n\n' Text + +'a' Name +'.' Operator +'row_size' Name +'\n' Text + +'a' Name +'.' Operator +'column_size' Name +'\n\n' Text + +'c' Name +'.' Operator +'det' Name +'\n' Text + +'a' Name +'.' Operator +'transpose' Name +'\n\n\n' Text + +'# @@PLEAC@@_2.15' Comment.Single +'\n' Text + +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'complex.rb' Literal.String.Single +"'" Literal.String.Single +'\n' Text + +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'rational.rb' Literal.String.Single +"'" Literal.String.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'Complex' Name.Constant +'(' Punctuation +'3' Literal.Number.Integer +',' Punctuation +' ' Text +'5' Literal.Number.Integer +')' Punctuation +' ' Text +'# 3 + 5i' Comment.Single +'\n' Text + +'b' Name +' ' Text +'=' Operator +' ' Text +'Complex' Name.Constant +'(' Punctuation +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'-' Operator +'2' Literal.Number.Integer +')' Punctuation +' ' Text +'# 2 - 2i' Comment.Single +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'c = ' Literal.String.Double +'#{' Literal.String.Interpol +'a' Name +'*' Operator +'b' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n\n' Text + +'c' Name +' ' Text +'=' Operator +' ' Text +'a' Name +' ' Text +'*' Operator +' ' Text +'b' Name +'\n' Text + +'d' Name +' ' Text +'=' Operator +' ' Text +'3' Literal.Number.Integer +' ' Text +'+' Operator +' ' Text +'4' Literal.Number.Integer +'*' Operator +'Complex' Name.Constant +'::' Operator +'I' Name +'\n\n' Text + +'printf' Name.Builtin +' ' Text +'"' Literal.String.Double +'sqrt(' Literal.String.Double +'#{' Literal.String.Interpol +'d' Name +'}' Literal.String.Interpol +') = %s' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'Math' Name.Constant +'.' Operator +'sqrt' Name +'(' Punctuation +'d' Name +')' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_2.16' Comment.Single +'\n' Text + +'number' Name +' ' Text +'=' Operator +' ' Text +'hexadecimal' Name +'.' Operator +'hex' Name +'\n' Text + +'number' Name +' ' Text +'=' Operator +' ' Text +'octal' Name +'.' Operator +'oct' Name +'\n\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Gimme a number in decimal, octal, or hex: ' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'num' Name +' ' Text +'=' Operator +' ' Text +'gets' Name.Builtin +'.' Operator +'chomp' Name +'\n' Text + +'exit' Name.Builtin +' ' Text +'unless' Keyword +' ' Text +'defined?' Name +'(' Punctuation +'num' Name +')' Punctuation +'\n' Text + +'num' Name +' ' Text +'=' Operator +' ' Text +'num' Name +'.' Operator +'oct' Name +' ' Text +'if' Keyword +' ' Text +'num' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^0' Literal.String.Regex +'/' Literal.String.Regex +' ' Text +'# does both oct and hex ' Comment.Single +'\n' Text + +'printf' Name.Builtin +' ' Text +'"' Literal.String.Double +'%d %x %o' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'num' Name +',' Punctuation +' ' Text +'num' Name +',' Punctuation +' ' Text +'num' Name +'\n\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Enter file permission in octal: ' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'permissions' Name +' ' Text +'=' Operator +' ' Text +'gets' Name.Builtin +'.' Operator +'chomp' Name +'\n' Text + +'raise' Keyword +' ' Text +'"' Literal.String.Double +'Exiting ...' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'unless' Keyword +' ' Text +'defined?' Name +'(' Punctuation +'permissions' Name +')' Punctuation +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'The decimal value is ' Literal.String.Double +'#{' Literal.String.Interpol +'permissions' Name +'.' Operator +'oct' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_2.17' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'commify' Name.Function +'(' Punctuation +'n' Name +')' Punctuation +'\n ' Text +'n' Name +'.' Operator +'to_s' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'([^' Literal.String.Regex +'\\' Literal.String.Regex +'.]*)(' Literal.String.Regex +'\\' Literal.String.Regex +'..*)?' Literal.String.Regex +'/' Literal.String.Regex +'\n ' Text +'int' Name +',' Punctuation +' ' Text +'dec' Name +' ' Text +'=' Operator +' ' Text +'$1' Name.Variable.Global +'.' Operator +'reverse' Name +',' Punctuation +' ' Text +'$2' Name.Variable.Global +' ' Text +'?' Punctuation +' ' Text +'$2' Name.Variable.Global +' ' Text +':' Punctuation +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'while' Keyword +' ' Text +'int' Name +'.' Operator +'gsub!' Name +'(' Punctuation +'/' Literal.String.Regex +'(,|' Literal.String.Regex +'\\' Literal.String.Regex +'.|^)(' Literal.String.Regex +'\\' Literal.String.Regex +'d{3})(' Literal.String.Regex +'\\' Literal.String.Regex +'d)' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +"'" Literal.String.Single +'\\1' Literal.String.Escape +'\\2' Literal.String.Escape +',' Literal.String.Single +'\\3' Literal.String.Escape +"'" Literal.String.Single +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'int' Name +'.' Operator +'reverse' Name +' ' Text +'+' Operator +' ' Text +'dec' Name +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_2.18' Comment.Single +'\n' Text + +'printf' Name.Builtin +' ' Text +'"' Literal.String.Double +'It took %d hour%s' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'time' Name +',' Punctuation +' ' Text +'time' Name +' ' Text +'==' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'?' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +' ' Text +':' Punctuation +' ' Text +'"' Literal.String.Double +'s' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'# dunno if an equivalent to Lingua::EN::Inflect exists...' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_2.19' Comment.Single +'\n' Text + +'#-----------------------------' Comment.Single +'\n' Text + +'#!/usr/bin/ruby' Comment.Single +'\n' Text + +'# bigfact - calculating prime factors' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'factorize' Name.Function +'(' Punctuation +'orig' Name +')' Punctuation +'\n ' Text +'factors' Name +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'}' Punctuation +'\n ' Text +'factors' Name +'.' Operator +'default' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +' ' Text +'# return 0 instead nil if key not found in hash' Comment.Single +'\n ' Text +'n' Name +' ' Text +'=' Operator +' ' Text +'orig' Name +'\n ' Text +'i' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +'\n ' Text +'sqi' Name +' ' Text +'=' Operator +' ' Text +'4' Literal.Number.Integer +' ' Text +'# square of i' Comment.Single +'\n ' Text +'while' Keyword +' ' Text +'sqi' Name +' ' Text +'<' Operator +'=' Operator +' ' Text +'n' Name +' ' Text +'do' Keyword +'\n ' Text +'while' Keyword +' ' Text +'n' Name +'.' Operator +'modulo' Name +'(' Punctuation +'i' Name +')' Punctuation +' ' Text +'==' Operator +' ' Text +'0' Literal.Number.Integer +' ' Text +'do' Keyword +'\n ' Text +'n' Name +' ' Text +'/=' Operator +' ' Text +'i' Name +'\n ' Text +'factors' Name +'[' Operator +'i' Name +']' Operator +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'# puts "Found factor #{i}"' Comment.Single +'\n ' Text +'end' Keyword +'\n ' Text +'# we take advantage of the fact that (i +1)**2 = i**2 + 2*i +1' Comment.Single +'\n ' Text +'sqi' Name +' ' Text +'+=' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'i' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'i' Name +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n \n ' Text +'if' Keyword +' ' Text +'(' Punctuation +'n' Name +' ' Text +'!=' Operator +' ' Text +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'&&' Operator +' ' Text +'(' Punctuation +'n' Name +' ' Text +'!=' Operator +' ' Text +'orig' Name +')' Punctuation +'\n ' Text +'factors' Name +'[' Operator +'n' Name +']' Operator +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n ' Text +'factors' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'printfactorhash' Name.Function +'(' Punctuation +'orig' Name +',' Punctuation +' ' Text +'factorcount' Name +')' Punctuation +'\n ' Text +'print' Name.Builtin +' ' Text +'format' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'%-10d ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'orig' Name +')' Punctuation +'\n ' Text +'if' Keyword +' ' Text +'factorcount' Name +'.' Operator +'length' Name +' ' Text +'==' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'PRIME' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'else' Keyword +'\n ' Text +'# sorts after number, because the hash keys are numbers' Comment.Single +'\n ' Text +'factorcount' Name +'.' Operator +'sort' Name +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'factor' Name +',' Punctuation +'exponent' Name +'|' Operator +'\n ' Text +'print' Name.Builtin +' ' Text +'factor' Name +'\n ' Text +'if' Keyword +' ' Text +'exponent' Name +' ' Text +'>' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'**' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'exponent' Name +'\n ' Text +'end' Keyword +'\n ' Text +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +' ' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'}' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'puts' Name.Builtin +'\n' Text + +'end' Keyword +'\n\n' Text + +'for' Keyword +' ' Text +'arg' Name +' ' Text +'in' Keyword +' ' Text +'ARGV' Name.Constant +'\n ' Text +'n' Name +' ' Text +'=' Operator +' ' Text +'arg' Name +'.' Operator +'to_i' Name +'\n ' Text +'mfactors' Name +' ' Text +'=' Operator +' ' Text +'factorize' Name +'(' Punctuation +'n' Name +')' Punctuation +'\n ' Text +'printfactorhash' Name +'(' Punctuation +'n' Name +',' Punctuation +' ' Text +'mfactors' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n' Text + +'#-----------------------------' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_3.0' Comment.Single +'\n' Text + +'puts' Name.Builtin +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'\n\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Today is day ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'yday' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +' of the current year.' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Today is day ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'day' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +' of the current month.' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_3.1' Comment.Single +'\n' Text + +'day' Name +',' Punctuation +' ' Text +'month' Name +',' Punctuation +' ' Text +'year' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'day' Name +',' Punctuation +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'month' Name +',' Punctuation +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'year' Name +'\n' Text + +'# or' Comment.Single +'\n' Text + +'day' Name +',' Punctuation +' ' Text +'month' Name +',' Punctuation +' ' Text +'year' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'to_a' Name +'[' Operator +'3' Literal.Number.Integer +'..' Operator +'5' Literal.Number.Integer +']' Operator +'\n\n' Text + +'tl' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'localtime' Name +'\n' Text + +'printf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'The current date is %04d %02d %02d' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'tl' Name +'.' Operator +'year' Name +',' Punctuation +' ' Text +'tl' Name +'.' Operator +'month' Name +',' Punctuation +' ' Text +'tl' Name +'.' Operator +'day' Name +')' Punctuation +'\n\n' Text + +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'localtime' Name +'.' Operator +'strftime' Name +'(' Punctuation +'"' Literal.String.Double +'%Y-%m-%d' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_3.2' Comment.Single +'\n' Text + +'Time' Name.Constant +'.' Operator +'local' Name +'(' Punctuation +'year' Name +',' Punctuation +' ' Text +'month' Name +',' Punctuation +' ' Text +'day' Name +',' Punctuation +' ' Text +'hour' Name +',' Punctuation +' ' Text +'minute' Name +',' Punctuation +' ' Text +'second' Name +')' Punctuation +'.' Operator +'tv_sec' Name +'\n' Text + +'Time' Name.Constant +'.' Operator +'gm' Name +'(' Punctuation +'year' Name +',' Punctuation +' ' Text +'month' Name +',' Punctuation +' ' Text +'day' Name +',' Punctuation +' ' Text +'hour' Name +',' Punctuation +' ' Text +'minute' Name +',' Punctuation +' ' Text +'second' Name +')' Punctuation +'.' Operator +'tv_sec' Name +'\n\n\n' Text + +'# @@PLEAC@@_3.3' Comment.Single +'\n' Text + +'sec' Name +',' Punctuation +' ' Text +'min' Name +',' Punctuation +' ' Text +'hour' Name +',' Punctuation +' ' Text +'day' Name +',' Punctuation +' ' Text +'month' Name +',' Punctuation +' ' Text +'year' Name +',' Punctuation +' ' Text +'wday' Name +',' Punctuation +' ' Text +'yday' Name +',' Punctuation +' ' Text +'isdst' Name +',' Punctuation +' ' Text +'zone' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'at' Name +'(' Punctuation +'epoch_secs' Name +')' Punctuation +'.' Operator +'to_a' Name +'\n\n\n' Text + +'# @@PLEAC@@_3.4' Comment.Single +'\n' Text + +'when_' Name +' ' Text +'=' Operator +' ' Text +'now' Name +' ' Text +'+' Operator +' ' Text +'difference' Name +' ' Text +'# now -> Time ; difference -> Numeric (delta in seconds)' Comment.Single +'\n' Text + +'then_' Name +' ' Text +'=' Operator +' ' Text +'now' Name +' ' Text +'-' Operator +' ' Text +'difference' Name +'\n\n\n' Text + +'# @@PLEAC@@_3.5' Comment.Single +'\n' Text + +'bree' Name +' ' Text +'=' Operator +' ' Text +'361535725' Literal.Number.Integer +'\n' Text + +'nat' Name +' ' Text +'=' Operator +' ' Text +'96201950' Literal.Number.Integer +'\n\n' Text + +'difference' Name +' ' Text +'=' Operator +' ' Text +'bree' Name +' ' Text +'-' Operator +' ' Text +'nat' Name +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'There were ' Literal.String.Double +'#{' Literal.String.Interpol +'difference' Name +'}' Literal.String.Interpol +' seconds between Nat and Bree' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'seconds' Name +' ' Text +'=' Operator +' ' Text +'difference' Name +' ' Text +'%' Operator +' ' Text +'60' Literal.Number.Integer +'\n' Text + +'difference' Name +' ' Text +'=' Operator +' ' Text +'(' Punctuation +'difference' Name +' ' Text +'-' Operator +' ' Text +'seconds' Name +')' Punctuation +' ' Text +'/' Operator +' ' Text +'60' Literal.Number.Integer +'\n' Text + +'minutes' Name +' ' Text +'=' Operator +' ' Text +'difference' Name +' ' Text +'%' Operator +' ' Text +'60' Literal.Number.Integer +'\n' Text + +'difference' Name +' ' Text +'=' Operator +' ' Text +'(' Punctuation +'difference' Name +' ' Text +'-' Operator +' ' Text +'minutes' Name +')' Punctuation +' ' Text +'/' Operator +' ' Text +'60' Literal.Number.Integer +'\n' Text + +'hours' Name +' ' Text +'=' Operator +' ' Text +'difference' Name +' ' Text +'%' Operator +' ' Text +'24' Literal.Number.Integer +'\n' Text + +'difference' Name +' ' Text +'=' Operator +' ' Text +'(' Punctuation +'difference' Name +' ' Text +'-' Operator +' ' Text +'hours' Name +')' Punctuation +' ' Text +'/' Operator +' ' Text +'24' Literal.Number.Integer +'\n' Text + +'days' Name +' ' Text +'=' Operator +' ' Text +'difference' Name +' ' Text +'%' Operator +' ' Text +'7' Literal.Number.Integer +'\n' Text + +'weeks' Name +' ' Text +'=' Operator +' ' Text +'(' Punctuation +'difference' Name +' ' Text +'-' Operator +' ' Text +'days' Name +')' Punctuation +' ' Text +'/' Operator +' ' Text +'7' Literal.Number.Integer +'\n\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'(' Literal.String.Double +'#{' Literal.String.Interpol +'weeks' Name +'}' Literal.String.Interpol +' weeks, ' Literal.String.Double +'#{' Literal.String.Interpol +'days' Name +'}' Literal.String.Interpol +' days, ' Literal.String.Double +'#{' Literal.String.Interpol +'hours' Name +'}' Literal.String.Interpol +':' Literal.String.Double +'#{' Literal.String.Interpol +'minutes' Name +'}' Literal.String.Interpol +':' Literal.String.Double +'#{' Literal.String.Interpol +'seconds' Name +'}' Literal.String.Interpol +')' Literal.String.Double +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_3.6' Comment.Single +'\n' Text + +'monthday' Name +',' Punctuation +' ' Text +'weekday' Name +',' Punctuation +' ' Text +'yearday' Name +' ' Text +'=' Operator +' ' Text +'date' Name +'.' Operator +'mday' Name +',' Punctuation +' ' Text +'date' Name +'.' Operator +'wday' Name +',' Punctuation +' ' Text +'date' Name +'.' Operator +'yday' Name +'\n\n' Text + +'# AFAIK the week number is not just a division since week boundaries are on sundays' Comment.Single +'\n' Text + +'weeknum' Name +' ' Text +'=' Operator +' ' Text +'d' Name +'.' Operator +'strftime' Name +'(' Punctuation +'"' Literal.String.Double +'%U' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'.' Operator +'to_i' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +'\n\n' Text + +'year' Name +' ' Text +'=' Operator +' ' Text +'1981' Literal.Number.Integer +'\n' Text + +'month' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'jun' Literal.String.Double +'"' Literal.String.Double +' ' Text +"# or `6' if you want to emulate a broken language" Comment.Single +'\n' Text + +'day' Name +' ' Text +'=' Operator +' ' Text +'16' Literal.Number.Integer +'\n' Text + +'t' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'mktime' Name +'(' Punctuation +'year' Name +',' Punctuation +' ' Text +'month' Name +',' Punctuation +' ' Text +'day' Name +')' Punctuation +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'month' Name +'}' Literal.String.Interpol +'/' Literal.String.Double +'#{' Literal.String.Interpol +'day' Name +'}' Literal.String.Interpol +'/' Literal.String.Double +'#{' Literal.String.Interpol +'year' Name +'}' Literal.String.Interpol +' was a ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'t' Name +'.' Operator +'strftime' Name +'(' Punctuation +'"' Literal.String.Double +'%A' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +',' Punctuation +' ' Text +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_3.7' Comment.Single +'\n' Text + +'yyyy' Name +',' Punctuation +' ' Text +'mm' Name +',' Punctuation +' ' Text +'dd' Name +' ' Text +'=' Operator +' ' Text +'$1' Name.Variable.Global +',' Punctuation +' ' Text +'$2' Name.Variable.Global +',' Punctuation +' ' Text +'$3' Name.Variable.Global +' ' Text +'if' Keyword +' ' Text +'"' Literal.String.Double +'1998-06-25' Literal.String.Double +'"' Literal.String.Double +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'(' Literal.String.Regex +'\\' Literal.String.Regex +'d+)-(' Literal.String.Regex +'\\' Literal.String.Regex +'d+)-(' Literal.String.Regex +'\\' Literal.String.Regex +'d+)' Literal.String.Regex +'/' Literal.String.Regex +'\n\n' Text + +'epoch_seconds' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'mktime' Name +'(' Punctuation +'yyyy' Name +',' Punctuation +' ' Text +'mm' Name +',' Punctuation +' ' Text +'dd' Name +')' Punctuation +'.' Operator +'tv_sec' Name +'\n\n' Text + +'# dunno an equivalent to Date::Manip#ParseDate' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_3.8' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'at' Name +'(' Punctuation +'epoch_secs' Name +')' Punctuation +'\n' Text + +'Time' Name.Constant +'.' Operator +'at' Name +'(' Punctuation +'1234567890' Literal.Number.Integer +')' Punctuation +'.' Operator +'gmtime' Name +' ' Text +'# gives: Fri Feb 13 23:31:30 UTC 2009' Comment.Single +'\n\n' Text + +'time' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'mktime' Name +'(' Punctuation +'1973' Literal.Number.Integer +',' Punctuation +' ' Text +'"' Literal.String.Double +'jan' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'18' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +',' Punctuation +' ' Text +'45' Literal.Number.Integer +',' Punctuation +' ' Text +'50' Literal.Number.Integer +')' Punctuation +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'In localtime it gives: ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'time' Name +'.' Operator +'localtime' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_3.9' Comment.Single +'\n' Text + +'# Ruby provides micro-seconds in Time object' Comment.Single +'\n' Text + +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'usec' Name +'\n\n' Text + +'# Ruby gives the seconds in floating format when substracting two Time objects' Comment.Single +'\n' Text + +'before' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'\n' Text + +'line' Name +' ' Text +'=' Operator +' ' Text +'gets' Name.Builtin +'\n' Text + +'elapsed' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +' ' Text +'-' Operator +' ' Text +'before' Name +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'You took ' Literal.String.Double +'#{' Literal.String.Interpol +'elapsed' Name +'}' Literal.String.Interpol +' seconds.' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'# On my Celeron-400 with Linux-2.2.19-14mdk, average for three execs are:' Comment.Single +'\n' Text + +'# This Ruby version: average 0.00321 sec' Comment.Single +'\n' Text + +"# Cookbook's Perl version: average 0.00981 sec" Comment.Single +'\n' Text + +'size' Name +' ' Text +'=' Operator +' ' Text +'500' Literal.Number.Integer +'\n' Text + +'number_of_times' Name +' ' Text +'=' Operator +' ' Text +'100' Literal.Number.Integer +'\n' Text + +'total_time' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n' Text + +'number_of_times' Name +'.' Operator +'times' Name +' ' Text +'{' Punctuation +'\n ' Text +'# populate array' Comment.Single +'\n ' Text +'array' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +'\n ' Text +'size' Name +'.' Operator +'times' Name +' ' Text +'{' Punctuation +' ' Text +'array' Name +' ' Text +'<<' Operator +' ' Text +'rand' Name.Builtin +' ' Text +'}' Punctuation +'\n ' Text +'# sort it' Comment.Single +'\n ' Text +'begin_' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'\n ' Text +'array' Name +'.' Operator +'sort!' Name +'\n ' Text +'time' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +' ' Text +'-' Operator +' ' Text +'begin_' Name +'\n ' Text +'total_time' Name +' ' Text +'+=' Operator +' ' Text +'time' Name +'\n' Text + +'}' Punctuation +'\n' Text + +'printf' Name.Builtin +' ' Text +'"' Literal.String.Double +'On average, sorting %d random numbers takes %.5f seconds' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +'\n ' Text +'size' Name +',' Punctuation +' ' Text +'(' Punctuation +'total_time' Name +'/' Operator +'Float' Name.Builtin +'(' Punctuation +'number_of_times' Name +')' Punctuation +')' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_3.10' Comment.Single +'\n' Text + +'sleep' Name.Builtin +'(' Punctuation +'0' Literal.Number.Integer +'.' Operator +'005' Literal.Number.Oct +')' Punctuation +' ' Text +'# Ruby is definitely not as broken as Perl :)' Comment.Single +'\n' Text + +'# (may be interrupted by sending the process a SIGALRM)' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_3.11' Comment.Single +'\n' Text + +'#!/usr/bin/ruby -w' Comment.Single +'\n' Text + +'# hopdelta - feed mail header, produce lines' Comment.Single +'\n' Text + +'# showing delay at each hop.' Comment.Single +'\n' Text + +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'time' Literal.String.Single +"'" Literal.String.Single +'\n' Text + +'class' Keyword +' ' Text +'MailHopDelta' Name.Class +'\n\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'mail' Name +')' Punctuation +'\n ' Text +'@head' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'mail' Name +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'n' Literal.String.Regex +'\\' Literal.String.Regex +'s+' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +"'" Literal.String.Single +' ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n ' Text +'@topline' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'%w-Sender Recipient Time Delta-' Literal.String.Other +'\n ' Text +'@start_from' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'mail' Name +'.' Operator +'match' Name +'(' Punctuation +'/' Literal.String.Regex +'^From.*' Literal.String.Regex +'\\' Literal.String.Regex +'@([^' Literal.String.Regex +'\\' Literal.String.Regex +'s>]*)' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'[' Operator +'1' Literal.Number.Integer +']' Operator +'\n ' Text +'@date' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'parse' Name +'(' Punctuation +'mail' Name +'.' Operator +'match' Name +'(' Punctuation +'/' Literal.String.Regex +'^Date:' Literal.String.Regex +'\\' Literal.String.Regex +'s+(.*)' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'[' Operator +'1' Literal.Number.Integer +']' Operator +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'out' Name.Function +'(' Punctuation +'line' Name +')' Punctuation +'\n ' Text +'"' Literal.String.Double +'%-20.20s %-20.20s %-20.20s %s' Literal.String.Double +'"' Literal.String.Double +' ' Text +'%' Operator +' ' Text +'line' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'hop_date' Name.Function +'(' Punctuation +'day' Name +')' Punctuation +'\n ' Text +'day' Name +'.' Operator +'strftime' Name +'(' Punctuation +'"' Literal.String.Double +'%I:%M:%S %Y/%m/%d' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'puts_hops' Name.Function +'\n ' Text +'puts' Name.Builtin +' ' Text +'out' Name +'(' Punctuation +'@topline' Name.Variable.Instance +')' Punctuation +' \n ' Text +'puts' Name.Builtin +' ' Text +'out' Name +'(' Punctuation +'[' Operator +"'" Literal.String.Single +'Start' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +'@start_from' Name.Variable.Instance +',' Punctuation +' ' Text +'hop_date' Name +'(' Punctuation +'@date' Name.Variable.Instance +')' Punctuation +',' Punctuation +"'" Literal.String.Single +"'" Literal.String.Single +']' Operator +')' Punctuation +'\n ' Text +'@head' Name.Variable.Instance +'.' Operator +'split' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'n' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'.' Operator +'reverse' Name +'.' Operator +'grep' Name +'(' Punctuation +'/' Literal.String.Regex +'^Received:' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'.' Operator +'each' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'hop' Name +'|' Operator +'\n ' Text +'hop' Name +'.' Operator +'gsub!' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'bon (.*?) (id.*)' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +"'" Literal.String.Single +'; ' Literal.String.Single +'\\1' Literal.String.Escape +"'" Literal.String.Single +')' Punctuation +'\n ' Text +'whence' Name +' ' Text +'=' Operator +' ' Text +'hop' Name +'.' Operator +'match' Name +'(' Punctuation +'/' Literal.String.Regex +';' Literal.String.Regex +'\\' Literal.String.Regex +'s+(.*)$' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'[' Operator +'1' Literal.Number.Integer +']' Operator +'\n ' Text +'unless' Keyword +' ' Text +'whence' Name +'\n ' Text +'warn' Name.Builtin +' ' Text +'"' Literal.String.Double +'Bad received line: ' Literal.String.Double +'#{' Literal.String.Interpol +'hop' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'next' Keyword +'\n ' Text +'end' Keyword +'\n ' Text +'from' Name +' ' Text +'=' Operator +' ' Text +'$+' Name.Variable.Global +' ' Text +'if' Keyword +' ' Text +'hop' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'from' Literal.String.Regex +'\\' Literal.String.Regex +'s+(' Literal.String.Regex +'\\' Literal.String.Regex +'S+)|' Literal.String.Regex +'\\' Literal.String.Regex +'((.*?)' Literal.String.Regex +'\\' Literal.String.Regex +')' Literal.String.Regex +'/' Literal.String.Regex +'\n ' Text +'by' Name +' ' Text +'=' Operator +' ' Text +'$1' Name.Variable.Global +' ' Text +'if' Keyword +' ' Text +'hop' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'by' Literal.String.Regex +'\\' Literal.String.Regex +'s+(' Literal.String.Regex +'\\' Literal.String.Regex +'S+' Literal.String.Regex +'\\' Literal.String.Regex +'.' Literal.String.Regex +'\\' Literal.String.Regex +'S+)' Literal.String.Regex +'/' Literal.String.Regex +'\n ' Text +'next' Keyword +' ' Text +'unless' Keyword +' ' Text +'now' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'parse' Name +'(' Punctuation +'whence' Name +')' Punctuation +'.' Operator +'localtime' Name +'\n ' Text +'delta' Name +' ' Text +'=' Operator +' ' Text +'now' Name +' ' Text +'-' Operator +' ' Text +'@date' Name.Variable.Instance +'\n ' Text +'puts' Name.Builtin +' ' Text +'out' Name +'(' Punctuation +'[' Operator +'from' Name +',' Punctuation +' ' Text +'by' Name +',' Punctuation +' ' Text +'hop_date' Name +'(' Punctuation +'now' Name +')' Punctuation +',' Punctuation +' ' Text +'hop_time' Name +'(' Punctuation +'delta' Name +')' Punctuation +']' Operator +')' Punctuation +'\n ' Text +'@date' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'now' Name +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'hop_time' Name.Function +'(' Punctuation +'secs' Name +')' Punctuation +'\n ' Text +'sign' Name +' ' Text +'=' Operator +' ' Text +'secs' Name +' ' Text +'<' Operator +' ' Text +'0' Literal.Number.Integer +' ' Text +'?' Operator +' ' Text +'-' Operator +'1' Literal.Number.Integer +' ' Text +':' Punctuation +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'days' Name +',' Punctuation +' ' Text +'secs' Name +' ' Text +'=' Operator +' ' Text +'secs' Name +'.' Operator +'abs' Name +'.' Operator +'divmod' Name +'(' Punctuation +'60' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'60' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'24' Literal.Number.Integer +')' Punctuation +'\n ' Text +'hours' Name +',' Punctuation +'secs' Name +' ' Text +'=' Operator +' ' Text +'secs' Name +'.' Operator +'abs' Name +'.' Operator +'divmod' Name +'(' Punctuation +'60' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'60' Literal.Number.Integer +')' Punctuation +'\n ' Text +'mins' Name +',' Punctuation +' ' Text +'secs' Name +' ' Text +'=' Operator +' ' Text +'secs' Name +'.' Operator +'abs' Name +'.' Operator +'divmod' Name +'(' Punctuation +'60' Literal.Number.Integer +')' Punctuation +'\n ' Text +'rtn' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'%3ds' Literal.String.Double +'"' Literal.String.Double +' ' Text +'%' Operator +' ' Text +'[' Operator +'secs' Name +' ' Text +'*' Operator +' ' Text +'sign' Name +']' Operator +'\n ' Text +'rtn' Name +' ' Text +'<<' Operator +' ' Text +'"' Literal.String.Double +'%3dm' Literal.String.Double +'"' Literal.String.Double +' ' Text +'%' Operator +' ' Text +'[' Operator +'mins' Name +' ' Text +'*' Operator +' ' Text +'sign' Name +']' Operator +' ' Text +'if' Keyword +' ' Text +'mins' Name +' ' Text +'!=' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'rtn' Name +' ' Text +'<<' Operator +' ' Text +'"' Literal.String.Double +'%3dh' Literal.String.Double +'"' Literal.String.Double +' ' Text +'%' Operator +' ' Text +'[' Operator +'hours' Name +' ' Text +'*' Operator +' ' Text +'sign' Name +']' Operator +' ' Text +'if' Keyword +' ' Text +'hours' Name +' ' Text +'!=' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'rtn' Name +' ' Text +'<<' Operator +' ' Text +'"' Literal.String.Double +'%3dd' Literal.String.Double +'"' Literal.String.Double +' ' Text +'%' Operator +' ' Text +'[' Operator +'days' Name +' ' Text +'*' Operator +' ' Text +'sign' Name +']' Operator +' ' Text +'if' Keyword +' ' Text +'days' Name +' ' Text +'!=' Operator +' ' Text +'0' Literal.Number.Integer +' \n ' Text +'rtn' Name +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'$/' Name.Variable.Global +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'mail' Name +' ' Text +'=' Operator +' ' Text +'MailHopDelta' Name.Constant +'.' Operator +'new' Name +'(' Punctuation +'ARGF' Name.Constant +'.' Operator +'gets' Name +')' Punctuation +'.' Operator +'puts_hops' Name +'\n\n\n' Text + +'# @@PLEAC@@_4.0' Comment.Single +'\n' Text + +'single_level' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'this' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'that' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'the' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'other' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +'\n\n' Text + +'# Ruby directly supports nested arrays' Comment.Single +'\n' Text + +'double_level' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'this' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'that' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'the' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'other' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +' ' Text +']' Operator +'\n' Text + +'still_single_level' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'this' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'that' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'the' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'other' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +' ' Text +']' Operator +'.' Operator +'flatten' Name +'\n\n\n' Text + +'# @@PLEAC@@_4.1' Comment.Single +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'quick' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'brown' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'fox' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'%w(' Literal.String.Other +'Why are you teasing me?' Literal.String.Other +')' Literal.String.Other +'\n\n' Text + +'lines' Name +' ' Text +'=' Operator +' ' Text +'<<' Operator +'"' Literal.String.Heredoc +'END_OF_HERE_DOC' Literal.String.Delimiter +'"' Literal.String.Heredoc +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'^' Literal.String.Regex +'\\' Literal.String.Regex +'s*(.+)' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +"'" Literal.String.Single +'\\1' Literal.String.Escape +"'" Literal.String.Single +')' Punctuation +'\n' Text + +' The boy stood on the burning deck,\n' Literal.String.Heredoc + +' It was as hot as glass.\n' Literal.String.Heredoc + +'END_OF_HERE_DOC\n' Literal.String.Delimiter + +'\n' Text + +'bigarray' Name +' ' Text +'=' Operator +' ' Text +'IO' Name.Constant +'.' Operator +'readlines' Name +'(' Punctuation +'"' Literal.String.Double +'mydatafile' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'l' Name +'|' Operator +' ' Text +'l' Name +'.' Operator +'chomp' Name +' ' Text +'}' Punctuation +'\n\n' Text + +'name' Name.Builtin +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'Gandalf' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'banner' Name +' ' Text +'=' Operator +' ' Text +'%Q(' Literal.String.Other +'Speak, ' Literal.String.Other +'#{' Literal.String.Interpol +'name' Name.Builtin +'}' Literal.String.Interpol +', and welcome!' Literal.String.Other +')' Literal.String.Other +'\n\n' Text + +'host_info' Name +' ' Text +'=' Operator +' ' Text +'`' Literal.String.Backtick +'host ' Literal.String.Backtick +'#{' Literal.String.Interpol +'his_host' Name +'}' Literal.String.Interpol +'`' Literal.String.Backtick +'\n\n' Text + +'%x(' Literal.String.Other +'ps ' Literal.String.Other +'#{' Literal.String.Interpol +'$$' Name.Variable.Global +'}' Literal.String.Interpol +')' Literal.String.Other +'\n\n' Text + +'banner' Name +' ' Text +'=' Operator +' ' Text +"'" Literal.String.Single +'Costs only $4.95' Literal.String.Single +"'" Literal.String.Single +'.' Operator +'split' Name +'(' Punctuation +"'" Literal.String.Single +' ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n\n' Text + +'rax' Name +' ' Text +'=' Operator +' ' Text +'%w! ( ) < > { } [ ] !' Literal.String.Other +'\n\n\n' Text + +'# @@PLEAC@@_4.2' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'commify_series' Name.Function +'(' Punctuation +'arr' Name +')' Punctuation +'\n ' Text +'return' Keyword +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +' ' Text +'if' Keyword +' ' Text +'not' Operator.Word +' ' Text +'arr' Name +'\n ' Text +'case' Keyword +' ' Text +'arr' Name +'.' Operator +'size' Name +'\n ' Text +'when' Keyword +' ' Text +'0' Literal.Number.Integer +' ' Text +'then' Keyword +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +'\n ' Text +'when' Keyword +' ' Text +'1' Literal.Number.Integer +' ' Text +'then' Keyword +' ' Text +'arr' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +'\n ' Text +'when' Keyword +' ' Text +'2' Literal.Number.Integer +' ' Text +'then' Keyword +' ' Text +'arr' Name +'.' Operator +'join' Name +'(' Punctuation +"'" Literal.String.Single +' and ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n ' Text +'else' Keyword +' ' Text +'arr' Name +'[' Operator +'0' Literal.Number.Integer +'..' Operator +'-' Operator +'2' Literal.Number.Integer +']' Operator +'.' Operator +'join' Name +'(' Punctuation +"'" Literal.String.Single +', ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +' ' Text +'+' Operator +' ' Text +"'" Literal.String.Single +', and ' Literal.String.Single +"'" Literal.String.Single +' ' Text +'+' Operator +' ' Text +'arr' Name +'[' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'array' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'red' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'yellow' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'green' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +'\n\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'I have ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'array' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +' marbles' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'# -> I have redyellowgreen marbles' Comment.Single +'\n\n' Text + +'# But unlike Perl:' Comment.Single +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'I have ' Literal.String.Double +'#{' Literal.String.Interpol +'array' Name +'}' Literal.String.Interpol +' marbles' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'# -> I have redyellowgreen marbles' Comment.Single +'\n' Text + +'# So, needs:' Comment.Single +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'I have ' Literal.String.Double +'#{' Literal.String.Interpol +'array' Name +'.' Operator +'join' Name +'(' Punctuation +"'" Literal.String.Single +' ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'}' Literal.String.Interpol +' marbles' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'# -> I have red yellow green marbles' Comment.Single +'\n\n' Text + +'#!/usr/bin/ruby' Comment.Single +'\n' Text + +'# communify_series - show proper comma insertion in list output' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'commify_series' Name.Function +'(' Punctuation +'arr' Name +')' Punctuation +'\n ' Text +'return' Keyword +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +' ' Text +'if' Keyword +' ' Text +'not' Operator.Word +' ' Text +'arr' Name +'\n ' Text +'sepchar' Name +' ' Text +'=' Operator +' ' Text +'arr' Name +'.' Operator +'find' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'p' Name.Builtin +'|' Operator +' ' Text +'p' Name.Builtin +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +',' Literal.String.Regex +'/' Literal.String.Regex +' ' Text +'}' Punctuation +' ' Text +'?' Punctuation +' ' Text +"'" Literal.String.Single +'; ' Literal.String.Single +"'" Literal.String.Single +' ' Text +':' Punctuation +' ' Text +"'" Literal.String.Single +', ' Literal.String.Single +"'" Literal.String.Single +'\n ' Text +'case' Keyword +' ' Text +'arr' Name +'.' Operator +'size' Name +'\n ' Text +'when' Keyword +' ' Text +'0' Literal.Number.Integer +' ' Text +'then' Keyword +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +'\n ' Text +'when' Keyword +' ' Text +'1' Literal.Number.Integer +' ' Text +'then' Keyword +' ' Text +'arr' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +'\n ' Text +'when' Keyword +' ' Text +'2' Literal.Number.Integer +' ' Text +'then' Keyword +' ' Text +'arr' Name +'.' Operator +'join' Name +'(' Punctuation +"'" Literal.String.Single +' and ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n ' Text +'else' Keyword +' ' Text +'arr' Name +'[' Operator +'0' Literal.Number.Integer +'..' Operator +'-' Operator +'2' Literal.Number.Integer +']' Operator +'.' Operator +'join' Name +'(' Punctuation +'sepchar' Name +')' Punctuation +' ' Text +'+' Operator +' ' Text +'sepchar' Name +' ' Text +'+' Operator +' ' Text +"'" Literal.String.Single +'and ' Literal.String.Single +"'" Literal.String.Single +' ' Text +'+' Operator +' ' Text +'arr' Name +'[' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'lists' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +'\n ' Text +'[' Operator +' ' Text +"'" Literal.String.Single +'just one thing' Literal.String.Single +"'" Literal.String.Single +' ' Text +']' Operator +',' Punctuation +'\n ' Text +'%w(' Literal.String.Other +'Mutt Jeff' Literal.String.Other +')' Literal.String.Other +',' Punctuation +'\n ' Text +'%w(' Literal.String.Other +'Peter Paul Mary' Literal.String.Other +')' Literal.String.Other +',' Punctuation +'\n ' Text +'[' Operator +' ' Text +"'" Literal.String.Single +'To our parents' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'Mother Theresa' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'God' Literal.String.Single +"'" Literal.String.Single +' ' Text +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +' ' Text +"'" Literal.String.Single +'pastrami' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'ham and cheese' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'peanut butter and jelly' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'tuna' Literal.String.Single +"'" Literal.String.Single +' ' Text +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +' ' Text +"'" Literal.String.Single +'recycle tired, old phrases' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'ponder big, happy thoughts' Literal.String.Single +"'" Literal.String.Single +' ' Text +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +' ' Text +"'" Literal.String.Single +'recycle tired, old phrases' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +'\n ' Text +"'" Literal.String.Single +'ponder big, happy thoughts' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +'\n ' Text +"'" Literal.String.Single +'sleep and dream peacefully' Literal.String.Single +"'" Literal.String.Single +' ' Text +']' Operator +',' Punctuation +'\n' Text + +']' Operator +'\n\n' Text + +'for' Keyword +' ' Text +'list' Name +' ' Text +'in' Keyword +' ' Text +'lists' Name +' ' Text +'do' Keyword +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'The list is: ' Literal.String.Double +'#{' Literal.String.Interpol +'commify_series' Name +'(' Punctuation +'list' Name +')' Punctuation +'}' Literal.String.Interpol +'.' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_4.3' Comment.Single +'\n' Text + +"# (note: AFAIK Ruby doesn't allow gory change of Array length)" Comment.Single +'\n' Text + +'# grow the array by assigning nil to past the end of array' Comment.Single +'\n' Text + +'ary' Name +'[' Operator +'new_size' Name +'-' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Pseudo +'\n' Text + +'# shrink the array by slicing it down' Comment.Single +'\n' Text + +'ary' Name +'.' Operator +'slice!' Name +'(' Punctuation +'new_size' Name +'..' Operator +'-' Operator +'1' Literal.Number.Integer +')' Punctuation +'\n' Text + +'# init the array with given size' Comment.Single +'\n' Text + +'Array' Name.Builtin +'.' Operator +'new' Name +'(' Punctuation +'number_of_elems' Name +')' Punctuation +'\n' Text + +'# assign to an element past the original end enlarges the array' Comment.Single +'\n' Text + +'ary' Name +'[' Operator +'index_new_last_elem' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'value' Name +'\n\n' Text + +'def' Keyword +' ' Text +'what_about_that_array' Name.Function +'(' Punctuation +'a' Name +')' Punctuation +'\n ' Text +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'The array now has ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'a' Name +'.' Operator +'size' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +' elements.' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n ' Text +'# Index of last element is not really interesting in Ruby' Comment.Single +'\n ' Text +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Element ' Literal.String.Double +'#' Literal.String.Double +'3 is `' Literal.String.Double +'#{' Literal.String.Interpol +'a' Name +'[' Operator +'3' Literal.Number.Integer +']' Operator +'}' Literal.String.Interpol +"'." Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n' Text + +'people' Name +' ' Text +'=' Operator +' ' Text +'%w(' Literal.String.Other +'Crosby Stills Nash Young' Literal.String.Other +')' Literal.String.Other +'\n' Text + +'what_about_that_array' Name +'(' Punctuation +'people' Name +')' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_4.4' Comment.Single +'\n' Text + +'# OO style' Comment.Single +'\n' Text + +'bad_users' Name +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'user' Name +'|' Operator +'\n ' Text +'complain' Name +'(' Punctuation +'user' Name +')' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'# or, functional style' Comment.Single +'\n' Text + +'for' Keyword +' ' Text +'user' Name +' ' Text +'in' Keyword +' ' Text +'bad_users' Name +'\n ' Text +'complain' Name +'(' Punctuation +'user' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'for' Keyword +' ' Text +'var' Name +' ' Text +'in' Keyword +' ' Text +'ENV' Name.Constant +'.' Operator +'keys' Name +'.' Operator +'sort' Name +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'var' Name +'}' Literal.String.Interpol +'=' Literal.String.Double +'#{' Literal.String.Interpol +'ENV' Name.Constant +'[' Operator +'var' Name +']' Operator +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'for' Keyword +' ' Text +'user' Name +' ' Text +'in' Keyword +' ' Text +'all_users' Name +'\n ' Text +'disk_space' Name +' ' Text +'=' Operator +' ' Text +'get_usage' Name +'(' Punctuation +'user' Name +')' Punctuation +'\n ' Text +'if' Keyword +' ' Text +'(' Punctuation +'disk_space' Name +' ' Text +'>' Operator +' ' Text +'MAX_QUOTA' Name.Constant +')' Punctuation +'\n ' Text +'complain' Name +'(' Punctuation +'user' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'for' Keyword +' ' Text +'l' Name +' ' Text +'in' Keyword +' ' Text +'IO' Name.Constant +'.' Operator +'popen' Name +'(' Punctuation +'"' Literal.String.Double +'who' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'.' Operator +'readlines' Name +'\n ' Text +'print' Name.Builtin +' ' Text +'l' Name +' ' Text +'if' Keyword +' ' Text +'l' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^gc' Literal.String.Regex +'/' Literal.String.Regex +' \n' Text + +'end' Keyword +'\n\n' Text + +'# we can mimic the obfuscated Perl way' Comment.Single +'\n' Text + +'while' Keyword +' ' Text +'fh' Name +'.' Operator +'gets' Name +' ' Text +'# $_ is set to the line just read' Comment.Single +'\n ' Text +'chomp' Name.Builtin +' ' Text +'# $_ has a trailing \\n removed, if it had one' Comment.Single +'\n ' Text +'split' Name.Builtin +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'w' Name +'|' Operator +' ' Text +'# $_ is split on whitespace' Comment.Single +'\n ' Text +'# but $_ is not set to each chunk as in Perl' Comment.Single +'\n ' Text +'print' Name.Builtin +' ' Text +'w' Name +'.' Operator +'reverse' Name +'\n ' Text +'}' Punctuation +'\n' Text + +'end' Keyword +'\n' Text + +'# ...or use a cleaner way' Comment.Single +'\n' Text + +'for' Keyword +' ' Text +'l' Name +' ' Text +'in' Keyword +' ' Text +'fh' Name +'.' Operator +'readlines' Name +'\n ' Text +'l' Name +'.' Operator +'chomp' Name +'.' Operator +'split' Name +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'w' Name +'|' Operator +' ' Text +'print' Name.Builtin +' ' Text +'w' Name +'.' Operator +'reverse' Name +' ' Text +'}' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +"# same drawback as in problem 1.4, we can't mutate a Numeric..." Comment.Single +'\n' Text + +'array' Name +'.' Operator +'collect!' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'v' Name +'|' Operator +' ' Text +'v' Name +' ' Text +'-' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'}' Punctuation +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'.' Operator +'5' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +' ' Text +']' Operator +';' Punctuation +' ' Text +'b' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +' ' Text +']' Operator +'\n' Text + +'for' Keyword +' ' Text +'ary' Name +' ' Text +'in' Keyword +' ' Text +'[' Operator +' ' Text +'a' Name +',' Punctuation +' ' Text +'b' Name +' ' Text +']' Operator +'\n ' Text +'ary' Name +'.' Operator +'collect!' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'v' Name +'|' Operator +' ' Text +'v' Name +' ' Text +'*' Operator +' ' Text +'7' Literal.Number.Integer +' ' Text +'}' Punctuation +'\n' Text + +'end' Keyword +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'a' Name +'.' Operator +'join' Name +'(' Punctuation +"'" Literal.String.Single +' ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'}' Literal.String.Interpol +' ' Literal.String.Double +'#{' Literal.String.Interpol +'b' Name +'.' Operator +'join' Name +'(' Punctuation +"'" Literal.String.Single +' ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n\n' Text + +'# we can mutate Strings, cool; we need a trick for the scalar' Comment.Single +'\n' Text + +'for' Keyword +' ' Text +'ary' Name +' ' Text +'in' Keyword +' ' Text +'[' Operator +' ' Text +'[' Operator +' ' Text +'scalar' Name +' ' Text +']' Operator +',' Punctuation +' ' Text +'array' Name +',' Punctuation +' ' Text +'hash' Name.Builtin +'.' Operator +'values' Name +' ' Text +']' Operator +'\n ' Text +'ary' Name +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'v' Name +'|' Operator +' ' Text +'v' Name +'.' Operator +'strip!' Name +' ' Text +'}' Punctuation +' ' Text +'# String#strip rules :)' Comment.Single +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_4.5' Comment.Single +'\n' Text + +'# not relevant in Ruby since we have always references' Comment.Single +'\n' Text + +'for' Keyword +' ' Text +'item' Name +' ' Text +'in' Keyword +' ' Text +'array' Name +'\n ' Text +'# do somethingh with item' Comment.Single +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_4.6' Comment.Single +'\n' Text + +'unique' Name +' ' Text +'=' Operator +' ' Text +'list' Name +'.' Operator +'uniq' Name +'\n\n' Text + +'# generate a list of users logged in, removing duplicates' Comment.Single +'\n' Text + +'users' Name +' ' Text +'=' Operator +' ' Text +'`' Literal.String.Backtick +'who' Literal.String.Backtick +'`' Literal.String.Backtick +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'l' Name +'|' Operator +' ' Text +'l' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'(' Literal.String.Regex +'\\' Literal.String.Regex +'w+)' Literal.String.Regex +'/' Literal.String.Regex +';' Punctuation +' ' Text +'$1' Name.Variable.Global +' ' Text +'}' Punctuation +'.' Operator +'sort' Name +'.' Operator +'uniq' Name +'\n' Text + +'puts' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'users logged in: ' Literal.String.Double +'#{' Literal.String.Interpol +'commify_series' Name +'(' Punctuation +'users' Name +')' Punctuation +'}' Literal.String.Interpol +'"' Literal.String.Double +')' Punctuation +' ' Text +'# see 4.2 for commify_series' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_4.7' Comment.Single +'\n' Text + +'a' Name +' ' Text +'-' Operator +' ' Text +'b' Name +'\n' Text + +'# [ 1, 1, 2, 2, 3, 3, 3, 4, 5 ] - [ 1, 2, 4 ] -> [3, 5]' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_4.8' Comment.Single +'\n' Text + +'union' Name +' ' Text +'=' Operator +' ' Text +'a' Name +' ' Text +'|' Operator +' ' Text +'b' Name +'\n' Text + +'intersection' Name +' ' Text +'=' Operator +' ' Text +'a' Name +' ' Text +'&' Operator +' ' Text +'b' Name +'\n' Text + +'difference' Name +' ' Text +'=' Operator +' ' Text +'a' Name +' ' Text +'-' Operator +' ' Text +'b' Name +'\n\n\n' Text + +'# @@PLEAC@@_4.9' Comment.Single +'\n' Text + +'array1' Name +'.' Operator +'concat' Name +'(' Punctuation +'array2' Name +')' Punctuation +'\n' Text + +'# if you will assign to another object, better use:' Comment.Single +'\n' Text + +'new_ary' Name +' ' Text +'=' Operator +' ' Text +'array1' Name +' ' Text +'+' Operator +' ' Text +'array2' Name +'\n\n' Text + +'members' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'Time' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'Flies' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +'\n' Text + +'initiates' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'An' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'Arrow' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +'\n' Text + +'members' Name +' ' Text +'+=' Operator +' ' Text +'initiates' Name +'\n\n' Text + +'members' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'Time' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'Flies' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +'\n' Text + +'initiates' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'An' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'Arrow' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +'\n' Text + +'members' Name +'[' Operator +'2' Literal.Number.Integer +',' Punctuation +'0' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'Like' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'initiates' Name +' ' Text +']' Operator +'.' Operator +'flatten' Name +'\n\n' Text + +'members' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'Fruit' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'members' Name +'[' Operator +'3' Literal.Number.Integer +',' Punctuation +'2' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'A' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'Banana' Literal.String.Double +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_4.10' Comment.Single +'\n' Text + +'reversed' Name +' ' Text +'=' Operator +' ' Text +'ary' Name +'.' Operator +'reverse' Name +'\n\n' Text + +'ary' Name +'.' Operator +'reverse_each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +'\n ' Text +'# do something with e' Comment.Single +'\n' Text + +'}' Punctuation +'\n\n' Text + +'descending' Name +' ' Text +'=' Operator +' ' Text +'ary' Name +'.' Operator +'sort' Name +'.' Operator +'reverse' Name +'\n' Text + +'descending' Name +' ' Text +'=' Operator +' ' Text +'ary' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'b' Name +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'a' Name +' ' Text +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_4.11' Comment.Single +'\n' Text + +'# remove n elements from front of ary (shift n)' Comment.Single +'\n' Text + +'front' Name +' ' Text +'=' Operator +' ' Text +'ary' Name +'.' Operator +'slice!' Name +'(' Punctuation +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'n' Name +')' Punctuation +'\n\n' Text + +'# remove n elements from the end of ary (pop n)' Comment.Single +'\n' Text + +'end_' Name +' ' Text +'=' Operator +' ' Text +'ary' Name +'.' Operator +'slice!' Name +'(' Punctuation +'-' Operator +'n' Name +' ' Text +'..' Operator +' ' Text +'-' Operator +'1' Literal.Number.Integer +')' Punctuation +'\n\n' Text + +"# let's extend the Array class, to make that useful" Comment.Single +'\n' Text + +'class' Keyword +' ' Text +'Array' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'shift2' Name.Function +'(' Punctuation +')' Punctuation +'\n ' Text +'slice!' Name +'(' Punctuation +'0' Literal.Number.Integer +' ' Text +'..' Operator +' ' Text +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'# more symetric with pop2...' Comment.Single +'\n ' Text +'end' Keyword +'\n ' Text +'def' Keyword +' ' Text +'pop2' Name.Function +'(' Punctuation +')' Punctuation +'\n ' Text +'slice!' Name +'(' Punctuation +'-' Operator +'2' Literal.Number.Integer +' ' Text +'..' Operator +' ' Text +'-' Operator +'1' Literal.Number.Integer +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'friends' Name +' ' Text +'=' Operator +' ' Text +'%w(' Literal.String.Other +'Peter Paul Mary Jim Tim' Literal.String.Other +')' Literal.String.Other +'\n' Text + +'this' Name +',' Punctuation +' ' Text +'that' Name +' ' Text +'=' Operator +' ' Text +'friends' Name +'.' Operator +'shift2' Name +'\n\n' Text + +'beverages' Name +' ' Text +'=' Operator +' ' Text +'%w(' Literal.String.Other +'Dew Jolt Cola Sprite Fresca' Literal.String.Other +')' Literal.String.Other +'\n' Text + +'pair' Name +' ' Text +'=' Operator +' ' Text +'beverages' Name +'.' Operator +'pop2' Name +'\n\n\n' Text + +'# @@PLEAC@@_4.12' Comment.Single +'\n' Text + +'# use Enumerable#detect (or the synonym Enumerable#find)' Comment.Single +'\n' Text + +'highest_eng' Name +' ' Text +'=' Operator +' ' Text +'employees' Name +'.' Operator +'detect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'emp' Name +'|' Operator +' ' Text +'emp' Name +'.' Operator +'category' Name +' ' Text +'==' Operator +' ' Text +"'" Literal.String.Single +'engineer' Literal.String.Single +"'" Literal.String.Single +' ' Text +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_4.13' Comment.Single +'\n' Text + +'# use Enumerable#select (or the synonym Enumerable#find_all)' Comment.Single +'\n' Text + +'bigs' Name +' ' Text +'=' Operator +' ' Text +'nums' Name +'.' Operator +'select' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +' ' Text +'i' Name +' ' Text +'>' Operator +' ' Text +'1_000_000' Literal.Number.Integer +' ' Text +'}' Punctuation +'\n' Text + +'pigs' Name +' ' Text +'=' Operator +' ' Text +'users' Name +'.' Operator +'keys' Name +'.' Operator +'select' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'k' Name +'|' Operator +' ' Text +'users' Name +'[' Operator +'k' Name +']' Operator +' ' Text +'>' Operator +' ' Text +'1' Literal.Number.Integer +'e7' Name +' ' Text +'}' Punctuation +'\n\n' Text + +'matching' Name +' ' Text +'=' Operator +' ' Text +'`' Literal.String.Backtick +'who' Literal.String.Backtick +'`' Literal.String.Backtick +'.' Operator +'select' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'u' Name +'|' Operator +' ' Text +'u' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^gnat ' Literal.String.Regex +'/' Literal.String.Regex +' ' Text +'}' Punctuation +'\n\n' Text + +'engineers' Name +' ' Text +'=' Operator +' ' Text +'employees' Name +'.' Operator +'select' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'e' Name +'.' Operator +'position' Name +' ' Text +'==' Operator +' ' Text +"'" Literal.String.Single +'Engineer' Literal.String.Single +"'" Literal.String.Single +' ' Text +'}' Punctuation +'\n\n' Text + +'secondary_assistance' Name +' ' Text +'=' Operator +' ' Text +'applicants' Name +'.' Operator +'select' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +'|' Operator +'\n ' Text +'a' Name +'.' Operator +'income' Name +' ' Text +'>' Operator +'=' Operator +' ' Text +'26_000' Literal.Number.Integer +' ' Text +'&&' Operator +' ' Text +'a' Name +'.' Operator +'income' Name +' ' Text +'<' Operator +' ' Text +'30_000' Literal.Number.Integer +'\n' Text + +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_4.14' Comment.Single +'\n' Text + +'# normally you would have an array of Numeric (Float or' Comment.Single +'\n' Text + +'# Fixnum or Bignum), so you would use:' Comment.Single +'\n' Text + +'sorted' Name +' ' Text +'=' Operator +' ' Text +'unsorted' Name +'.' Operator +'sort' Name +'\n' Text + +'# if you have strings representing Integers or Floats' Comment.Single +'\n' Text + +'# you may specify another sort method:' Comment.Single +'\n' Text + +'sorted' Name +' ' Text +'=' Operator +' ' Text +'unsorted' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'.' Operator +'to_f' Name +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'.' Operator +'to_f' Name +' ' Text +'}' Punctuation +'\n\n' Text + +"# let's use the list of my own PID's" Comment.Single +'\n' Text + +'`' Literal.String.Backtick +'ps ux' Literal.String.Backtick +'`' Literal.String.Backtick +'.' Operator +'split' Name +'(' Punctuation +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +')' Punctuation +'[' Operator +'1' Literal.Number.Integer +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +'.' Operator +'\n ' Text +'select' Name.Builtin +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +' ' Text +'i' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^' Literal.String.Regex +'#{' Literal.String.Interpol +'ENV' Name.Constant +'[' Operator +"'" Literal.String.Single +'USER' Literal.String.Single +"'" Literal.String.Single +']' Operator +'}' Literal.String.Interpol +'/' Literal.String.Regex +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +' ' Text +'i' Name +'.' Operator +'split' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'.' Operator +'to_i' Name +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'.' Operator +'to_i' Name +' ' Text +'}' Punctuation +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +' ' Text +'puts' Name.Builtin +' ' Text +'i' Name +' ' Text +'}' Punctuation +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Select a process ID to kill:' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'pid' Name +' ' Text +'=' Operator +' ' Text +'gets' Name.Builtin +'.' Operator +'chomp' Name +'\n' Text + +'raise' Keyword +' ' Text +'"' Literal.String.Double +'Exiting ... ' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'unless' Keyword +' ' Text +'pid' Name +' ' Text +'&&' Operator +' ' Text +'pid' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^' Literal.String.Regex +'\\' Literal.String.Regex +'d+$' Literal.String.Regex +'/' Literal.String.Regex +'\n' Text + +'Process' Name.Constant +'.' Operator +'kill' Name +'(' Punctuation +"'" Literal.String.Single +'TERM' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +'pid' Name +'.' Operator +'to_i' Name +')' Punctuation +'\n' Text + +'sleep' Name.Builtin +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'Process' Name.Constant +'.' Operator +'kill' Name +'(' Punctuation +"'" Literal.String.Single +'KILL' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +'pid' Name +'.' Operator +'to_i' Name +')' Punctuation +'\n\n' Text + +'descending' Name +' ' Text +'=' Operator +' ' Text +'unsorted' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'b' Name +'.' Operator +'to_f' Name +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'a' Name +'.' Operator +'to_f' Name +' ' Text +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_4.15' Comment.Single +'\n' Text + +'ordered' Name +' ' Text +'=' Operator +' ' Text +'unordered' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'compare' Name +'(' Punctuation +'a' Name +',' Punctuation +'b' Name +')' Punctuation +' ' Text +'}' Punctuation +'\n\n' Text + +'precomputed' Name +' ' Text +'=' Operator +' ' Text +'unordered' Name +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'[' Operator +'compute' Name +',' Punctuation +' ' Text +'e' Name +']' Operator +' ' Text +'}' Punctuation +'\n' Text + +'ordered_precomputed' Name +' ' Text +'=' Operator +' ' Text +'precomputed' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'\n' Text + +'ordered' Name +' ' Text +'=' Operator +' ' Text +'ordered_precomputed' Name +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'e' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'\n\n' Text + +'ordered' Name +' ' Text +'=' Operator +' ' Text +'unordered' Name +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'[' Operator +'compute' Name +',' Punctuation +' ' Text +'e' Name +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'e' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'\n\n' Text + +'for' Keyword +' ' Text +'employee' Name +' ' Text +'in' Keyword +' ' Text +'employees' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'.' Operator +'name' Name +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'.' Operator +'name' Name +' ' Text +'}' Punctuation +'\n ' Text +'print' Name.Builtin +' ' Text +'employee' Name +'.' Operator +'name' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +' earns ' Literal.String.Double +'\\' Literal.String.Double +'$ ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'employee' Name +'.' Operator +'salary' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +"# Beware! `0' is true in Ruby." Comment.Single +'\n' Text + +'# For chaining comparisons, you may use Numeric#nonzero?, which' Comment.Single +'\n' Text + +'# returns num if num is not zero, nil otherwise' Comment.Single +'\n' Text + +'sorted' Name +' ' Text +'=' Operator +' ' Text +'employees' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'(' Punctuation +'a' Name +'.' Operator +'name' Name +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'.' Operator +'name' Name +')' Punctuation +'.' Operator +'nonzero?' Name +' ' Text +'||' Operator +' ' Text +'b' Name +'.' Operator +'age' Name +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'a' Name +'.' Operator +'age' Name +' ' Text +'}' Punctuation +'\n\n' Text + +'users' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +'\n' Text + +"# getpwent is not wrapped in Ruby... let's fallback" Comment.Single +'\n' Text + +'IO' Name.Constant +'.' Operator +'readlines' Name +'(' Punctuation +"'" Literal.String.Single +'/etc/passwd' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'u' Name +'|' Operator +' ' Text +'users' Name +' ' Text +'<<' Operator +' ' Text +'u' Name +'.' Operator +'split' Name +'(' Punctuation +"'" Literal.String.Single +':' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'users' Name +'.' Operator +'sort!' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'\n' Text + +'for' Keyword +' ' Text +'user' Name +' ' Text +'in' Keyword +' ' Text +'users' Name +'\n ' Text +'puts' Name.Builtin +' ' Text +'user' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +'\n' Text + +'end' Keyword +'\n\n' Text + +'sorted' Name +' ' Text +'=' Operator +' ' Text +'names' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'\n' Text + +'sorted' Name +' ' Text +'=' Operator +' ' Text +'strings' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'.' Operator +'length' Name +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'.' Operator +'length' Name +' ' Text +'}' Punctuation +'\n\n' Text + +"# let's show only the compact version" Comment.Single +'\n' Text + +'ordered' Name +' ' Text +'=' Operator +' ' Text +'strings' Name +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'[' Operator +'e' Name +'.' Operator +'length' Name +',' Punctuation +' ' Text +'e' Name +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'e' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'\n\n' Text + +'ordered' Name +' ' Text +'=' Operator +' ' Text +'strings' Name +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'[' Operator +'/' Literal.String.Regex +'\\' Literal.String.Regex +'d+' Literal.String.Regex +'/' Literal.String.Regex +'.' Operator +'match' Name +'(' Punctuation +'e' Name +')' Punctuation +'[' Operator +'0' Literal.Number.Integer +']' Operator +'.' Operator +'to_i' Name +',' Punctuation +' ' Text +'e' Name +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'e' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'\n\n' Text + +'print' Name.Builtin +' ' Text +'`' Literal.String.Backtick +'cat /etc/passwd' Literal.String.Backtick +'`' Literal.String.Backtick +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'[' Operator +'e' Name +',' Punctuation +' ' Text +'e' Name +'.' Operator +'split' Name +'(' Punctuation +"'" Literal.String.Single +':' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'.' Operator +'indexes' Name +'(' Punctuation +'3' Literal.Number.Integer +',' Punctuation +'2' Literal.Number.Integer +',' Punctuation +'0' Literal.Number.Integer +')' Punctuation +']' Operator +'.' Operator +'flatten' Name +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'(' Punctuation +'a' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +')' Punctuation +'.' Operator +'nonzero?' Name +' ' Text +'||' Operator +' ' Text +'(' Punctuation +'a' Name +'[' Operator +'2' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'2' Literal.Number.Integer +']' Operator +')' Punctuation +'.' Operator +'nonzero?' Name +' ' Text +'||' Operator +' ' Text +'a' Name +'[' Operator +'3' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'3' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'e' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_4.16' Comment.Single +'\n' Text + +'circular' Name +'.' Operator +'unshift' Name +'(' Punctuation +'circular' Name +'.' Operator +'pop' Name +')' Punctuation +' ' Text +'# the last shall be first' Comment.Single +'\n' Text + +'circular' Name +'.' Operator +'push' Name +'(' Punctuation +'circular' Name +'.' Operator +'shift' Name +')' Punctuation +' ' Text +'# and vice versa' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'grab_and_rotate' Name.Function +'(' Punctuation +'l' Name +')' Punctuation +'\n ' Text +'l' Name +'.' Operator +'push' Name +'(' Punctuation +'ret' Name +' ' Text +'=' Operator +' ' Text +'l' Name +'.' Operator +'shift' Name +')' Punctuation +'\n ' Text +'ret' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'processes' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +',' Punctuation +' ' Text +'4' Literal.Number.Integer +',' Punctuation +' ' Text +'5' Literal.Number.Integer +']' Operator +'\n' Text + +'while' Keyword +' ' Text +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +'\n ' Text +'process' Name +' ' Text +'=' Operator +' ' Text +'grab_and_rotate' Name +'(' Punctuation +'processes' Name +')' Punctuation +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Handling process ' Literal.String.Double +'#{' Literal.String.Interpol +'process' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'sleep' Name.Builtin +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_4.17' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'fisher_yates_shuffle' Name.Function +'(' Punctuation +'a' Name +')' Punctuation +'\n ' Text +'(' Punctuation +'a' Name +'.' Operator +'size' Name +'-' Operator +'1' Literal.Number.Integer +')' Punctuation +'.' Operator +'downto' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'j' Name +' ' Text +'=' Operator +' ' Text +'rand' Name.Builtin +'(' Punctuation +'i' Name +'+' Operator +'1' Literal.Number.Integer +')' Punctuation +'\n ' Text +'a' Name +'[' Operator +'i' Name +']' Operator +',' Punctuation +' ' Text +'a' Name +'[' Operator +'j' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'a' Name +'[' Operator +'j' Name +']' Operator +',' Punctuation +' ' Text +'a' Name +'[' Operator +'i' Name +']' Operator +' ' Text +'if' Keyword +' ' Text +'i' Name +' ' Text +'!=' Operator +' ' Text +'j' Name +'\n ' Text +'}' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'naive_shuffle' Name.Function +'(' Punctuation +'a' Name +')' Punctuation +'\n ' Text +'for' Keyword +' ' Text +'i' Name +' ' Text +'in' Keyword +' ' Text +'0' Literal.Number.Integer +'...' Operator +'a' Name +'.' Operator +'size' Name +'\n ' Text +'j' Name +' ' Text +'=' Operator +' ' Text +'rand' Name.Builtin +'(' Punctuation +'a' Name +'.' Operator +'size' Name +')' Punctuation +'\n ' Text +'a' Name +'[' Operator +'i' Name +']' Operator +',' Punctuation +' ' Text +'a' Name +'[' Operator +'j' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'a' Name +'[' Operator +'j' Name +']' Operator +',' Punctuation +' ' Text +'a' Name +'[' Operator +'i' Name +']' Operator +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n' Text diff --git a/tests/lexers/rb/example6.txt b/tests/lexers/rb/example6.txt new file mode 100644 index 00000000..8e3fbc51 --- /dev/null +++ b/tests/lexers/rb/example6.txt @@ -0,0 +1,373 @@ +---input--- +# Server: ruby p2p.rb password server server-uri merge-servers +# Sample: ruby p2p.rb foobar server druby://localhost:1337 druby://foo.bar:1337 +# Client: ruby p2p.rb password client server-uri download-pattern +# Sample: ruby p2p.rb foobar client druby://localhost:1337 *.rb +require'drb';F,D,C,P,M,U,*O=File,Class,Dir,*ARGV;def s(p)F.split(p[/[^|].*/])[-1 +]end;def c(u);DRbObject.new((),u)end;def x(u)[P,u].hash;end;M=="client"&&c(U).f( +x(U)).each{|n|p,c=x(n),c(n);(c.f(p,O[0],0).map{|f|s f}-D["*"]).each{|f|F.open(f, +"w"){|o|o<<c.f(p,f,1)}}}||(DRb.start_service U,C.new{def f(c,a=[],t=2)c==x(U)&&( +t==0&&D[s(a)]||t==1&&F.read(s(a))||p(a))end;def y()(p(U)+p).each{|u|c(u).f(x(u), +p(U))rescue()};self;end;private;def p(x=[]);O.push(*x).uniq!;O;end}.new.y;sleep) + +---tokens--- +'# Server: ruby p2p.rb password server server-uri merge-servers' Comment.Single +'\n' Text + +'# Sample: ruby p2p.rb foobar server druby://localhost:1337 druby://foo.bar:1337' Comment.Single +'\n' Text + +'# Client: ruby p2p.rb password client server-uri download-pattern' Comment.Single +'\n' Text + +'# Sample: ruby p2p.rb foobar client druby://localhost:1337 *.rb' Comment.Single +'\n' Text + +'require' Name.Builtin +"'" Literal.String.Single +'drb' Literal.String.Single +"'" Literal.String.Single +';' Punctuation +'F' Name +',' Punctuation +'D' Name +',' Punctuation +'C' Name +',' Punctuation +'P' Name +',' Punctuation +'M' Name +',' Punctuation +'U' Name +',' Punctuation +'*' Operator +'O' Name +'=' Operator +'File' Name.Constant +',' Punctuation +'Class' Name.Constant +',' Punctuation +'Dir' Name.Constant +',' Punctuation +'*' Operator +'ARGV' Name.Constant +';' Punctuation +'def' Keyword +' ' Text +'s' Name.Function +'(' Punctuation +'p' Name.Builtin +')' Punctuation +'F' Name +'.' Operator +'split' Name +'(' Punctuation +'p' Name.Builtin +'[' Operator +'/' Literal.String.Regex +'[^|].*' Literal.String.Regex +'/' Literal.String.Regex +']' Operator +')' Punctuation +'[' Operator +'-' Operator +'1' Literal.Number.Integer +'\n' Text + +']' Operator +'end' Keyword +';' Punctuation +'def' Keyword +' ' Text +'c' Name.Function +'(' Punctuation +'u' Name +')' Punctuation +';' Punctuation +'DRbObject' Name.Constant +'.' Operator +'new' Name +'(' Punctuation +'(' Punctuation +')' Punctuation +',' Punctuation +'u' Name +')' Punctuation +'end' Keyword +';' Punctuation +'def' Keyword +' ' Text +'x' Name.Function +'(' Punctuation +'u' Name +')' Punctuation +'[' Operator +'P' Name +',' Punctuation +'u' Name +']' Operator +'.' Operator +'hash' Name +';' Punctuation +'end' Keyword +';' Punctuation +'M' Name +'==' Operator +'"' Literal.String.Double +'client' Literal.String.Double +'"' Literal.String.Double +'&&' Operator +'c' Name +'(' Punctuation +'U' Name +')' Punctuation +'.' Operator +'f' Name +'(' Punctuation +'\n' Text + +'x' Name +'(' Punctuation +'U' Name +')' Punctuation +')' Punctuation +'.' Operator +'each' Name +'{' Punctuation +'|' Operator +'n' Name +'|' Operator +'p' Name.Builtin +',' Punctuation +'c' Name +'=' Operator +'x' Name +'(' Punctuation +'n' Name +')' Punctuation +',' Punctuation +'c' Name +'(' Punctuation +'n' Name +')' Punctuation +';' Punctuation +'(' Punctuation +'c' Name +'.' Operator +'f' Name +'(' Punctuation +'p' Name.Builtin +',' Punctuation +'O' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +',' Punctuation +'0' Literal.Number.Integer +')' Punctuation +'.' Operator +'map' Name +'{' Punctuation +'|' Operator +'f' Name +'|' Operator +'s' Name +' ' Text +'f' Name +'}' Punctuation +'-' Operator +'D' Name +'[' Operator +'"' Literal.String.Double +'*' Literal.String.Double +'"' Literal.String.Double +']' Operator +')' Punctuation +'.' Operator +'each' Name +'{' Punctuation +'|' Operator +'f' Name +'|' Operator +'F' Name +'.' Operator +'open' Name +'(' Punctuation +'f' Name +',' Punctuation +'\n' Text + +'"' Literal.String.Double +'w' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'{' Punctuation +'|' Operator +'o' Name +'|' Operator +'o' Name +'<<' Operator +'c' Name +'.' Operator +'f' Name +'(' Punctuation +'p' Name.Builtin +',' Punctuation +'f' Name +',' Punctuation +'1' Literal.Number.Integer +')' Punctuation +'}' Punctuation +'}' Punctuation +'}' Punctuation +'||' Operator +'(' Punctuation +'DRb' Name.Constant +'.' Operator +'start_service' Name +' ' Text +'U' Name +',' Punctuation +'C' Name +'.' Operator +'new' Name +'{' Punctuation +'def' Keyword +' ' Text +'f' Name.Function +'(' Punctuation +'c' Name +',' Punctuation +'a' Name +'=' Operator +'[' Operator +']' Operator +',' Punctuation +'t' Name +'=' Operator +'2' Literal.Number.Integer +')' Punctuation +'c' Name +'==' Operator +'x' Name +'(' Punctuation +'U' Name +')' Punctuation +'&&' Operator +'(' Punctuation +'\n' Text + +'t' Name +'==' Operator +'0' Literal.Number.Integer +'&&' Operator +'D' Name +'[' Operator +'s' Name +'(' Punctuation +'a' Name +')' Punctuation +']' Operator +'||' Operator +'t' Name +'==' Operator +'1' Literal.Number.Integer +'&&' Operator +'F' Name +'.' Operator +'read' Name +'(' Punctuation +'s' Name +'(' Punctuation +'a' Name +')' Punctuation +')' Punctuation +'||' Operator +'p' Name.Builtin +'(' Punctuation +'a' Name +')' Punctuation +')' Punctuation +'end' Keyword +';' Punctuation +'def' Keyword +' ' Text +'y' Name.Function +'(' Punctuation +')' Punctuation +'(' Punctuation +'p' Name.Builtin +'(' Punctuation +'U' Name +')' Punctuation +'+' Operator +'p' Name.Builtin +')' Punctuation +'.' Operator +'each' Name +'{' Punctuation +'|' Operator +'u' Name +'|' Operator +'c' Name +'(' Punctuation +'u' Name +')' Punctuation +'.' Operator +'f' Name +'(' Punctuation +'x' Name +'(' Punctuation +'u' Name +')' Punctuation +',' Punctuation +'\n' Text + +'p' Name.Builtin +'(' Punctuation +'U' Name +')' Punctuation +')' Punctuation +'rescue' Keyword +'(' Punctuation +')' Punctuation +'}' Punctuation +';' Punctuation +'self' Name.Builtin +';' Punctuation +'end' Keyword +';' Punctuation +'private' Keyword.Pseudo +';' Punctuation +'def' Keyword +' ' Text +'p' Name.Function +'(' Punctuation +'x' Name +'=' Operator +'[' Operator +']' Operator +')' Punctuation +';' Punctuation +'O' Name +'.' Operator +'push' Name +'(' Punctuation +'*' Operator +'x' Name +')' Punctuation +'.' Operator +'uniq!' Name +';' Punctuation +'O' Name +';' Punctuation +'end' Keyword +'}' Punctuation +'.' Operator +'new' Name +'.' Operator +'y' Name +';' Punctuation +'sleep' Name.Builtin +')' Punctuation +'\n' Text diff --git a/tests/lexers/rb/example7.txt b/tests/lexers/rb/example7.txt new file mode 100644 index 00000000..7a0da905 --- /dev/null +++ b/tests/lexers/rb/example7.txt @@ -0,0 +1,86 @@ +---input--- +class (get_foo("blub"))::Foo + def (foo("bar") + bar("baz")).something argh, aaahaa + 42 + end +end + +class get_the_fuck("out")::Of::My + def parser_definition + ruby! + end +end + +---tokens--- +'class' Keyword +' ' Text +'(' Punctuation +'get_foo' Name +'(' Operator +'"' Literal.String.Double +'blub' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +')' Punctuation +'::' Operator +'Foo' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'(' Punctuation +'foo' Name +'(' Operator +'"' Literal.String.Double +'bar' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'+' Operator +' ' Text +'bar' Name +'(' Operator +'"' Literal.String.Double +'baz' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +')' Punctuation +'.' Operator +'something' Name.Function +' ' Text +'argh' Name +',' Punctuation +' ' Text +'aaahaa' Name +'\n ' Text +'42' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'class' Keyword +' ' Text +'get_the_fuck' Name +'(' Punctuation +'"' Literal.String.Double +'out' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'::' Operator +'Of' Name.Constant +'::' Operator +'My' Name.Constant +'\n ' Text +'def' Keyword +' ' Text +'parser_definition' Name.Function +'\n ' Text +'ruby!' Name +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n' Text diff --git a/tests/lexers/rb/example8.txt b/tests/lexers/rb/example8.txt new file mode 100644 index 00000000..43814cd0 --- /dev/null +++ b/tests/lexers/rb/example8.txt @@ -0,0 +1,1375 @@ +---input--- +a.each{|el|anz[el]=anz[el]?anz[el]+1:1} +while x<10000 +#a bis f dienen dazu die Nachbarschaft festzulegen. Man stelle sich die #Zahl von 1 bis 64 im Binärcode vor 1 bedeutet an 0 aus + b=(p[x]%32)/16<1 ? 0 : 1 + + (x-102>=0? n[x-102].to_i : 0)*a+(x-101>=0?n[x-101].to_i : 0)*e+n[x-100].to_i+(x-99>=0? n[x-99].to_i : 0)*f+(x-98>=0? n[x-98].to_i : 0)*a+ + n[x+199].to_i*b+n[x+200].to_i*d+n[x+201].to_i*b + +#und die Ausgabe folgt +g=%w{} +x=0 + +#leere regex +test //, 123 + +while x<100 + puts"#{g[x]}" + x+=1 +end + +puts"" +sleep(10) + +1E1E1 +puts 30.send(:/, 5) # prints 6 + +# fun with class attributes +class Foo + def self.blub x + if not x.nil? + self.new + end + end + def another_way_to_get_class + self.class + end +end + +# ruby 1.9 "call operator" +a = Proc.new { 42 } +a.() + +"instance variables can be #@included, #@@class_variables\n and #$globals as well." +`instance variables can be #@included, #@@class_variables\n and #$globals as well.` +'instance variables can be #@included, #@@class_variables\n and #$globals as well.' +/instance variables can be #@included, #@@class_variables\n and #$globals as well./mousenix +:"instance variables can be #@included, #@@class_variables\n and #$globals as well." +:'instance variables can be #@included, #@@class_variables\n and #$globals as well.' +%'instance variables can be #@included, #@@class_variables\n and #$globals as well.' +%q'instance variables can be #@included, #@@class_variables\n and #$globals as well.' +%Q'instance variables can be #@included, #@@class_variables\n and #$globals as well.' +%w'instance variables can be #@included, #@@class_variables\n and #$globals as well.' +%W'instance variables can be #@included, #@@class_variables\n and #$globals as well.' +%s'instance variables can be #@included, #@@class_variables\n and #$globals as well.' +%r'instance variables can be #@included, #@@class_variables\n and #$globals as well.' +%x'instance variables can be #@included, #@@class_variables\n and #$globals as well.' + +#%W[ but #@0illegal_values look strange.] + +%s#ruby allows strange#{constructs} +%s#ruby allows strange#$constructs +%s#ruby allows strange#@@constructs + +################################################################## +# HEREDOCS +foo(<<-A, <<-B) +this is the text of a +A +and this is the text of b +B + +a = <<"EOF" +This is a multiline #$here document +terminated by EOF on a line by itself +EOF + +a = <<'EOF' +This is a multiline #$here document +terminated by EOF on a line by itself +EOF + +b=(p[x] %32)/16<1 ? 0 : 1 + +<<"" +#{test} +#@bla +#die suppe!!! +\xfffff + + +super <<-EOE % [ + foo +EOE + +<<X +X +X + +%s(uninter\)pre\ted) # comment here +%q(uninter\)pre\ted) # comment here +%Q(inter\)pre\ted) # comment here +:"inter\)pre\ted" # comment here +:'uninter\'pre\ted' # comment here + +%q[haha! [nesting [rocks] ! ] ] # commeht here + + +################################################################## +class NP +def initialize a=@p=[], b=@b=[]; end +def +@;@b<<1;b2c end;def-@;@b<<0;b2c end +def b2c;if @b.size==8;c=0;@b.each{|b|c<<=1;c|=b};send( + 'lave'.reverse,(@p.join))if c==0;@p<< c.chr;@b=[] end + self end end ; begin _ = NP.new end + + +# Regexes +/ +this is a +mutliline +regex +/ + +this /is a +multiline regex too/ + +also /4 +is one/ + +this(/ +too +/) + +# this not +2 /4 +asfsadf/ + + +#from: http://coderay.rubychan.de/rays/show/383 +class Object + alias :xeq :` + def `(cmd, p2) + self.method(cmd.to_sym).call(p2) + end +end +p [1,2,3].`('concat', [4,5,6]) # => [1, 2, 3, 4, 5, 6] +p [1,2,3].`(:concat, [4,5,6]) # => [1, 2, 3, 4, 5, 6] +p "Hurra! ".`(:*, 3) # => "Hurra! Hurra! Hurra! " +p "Hurra! ".`('*', 3) # => "Hurra! Hurra! Hurra! " +# Leider geht nicht die Wunschform +# [1,2,3] `concat` [4,5,6] + +class Object + @@infixops = [] + alias :xeq :` + def addinfix(operator) + @@infixops << operator + end + def `(expression) + @@infixops.each{|op|break if expression.match(/^(.*?) (#{op}) (.*)$/)} + raise "unknown infix operator in expression: #{expression}" if $2 == nil + eval($1).method($2.to_sym).call(eval($3)) + end +end +addinfix("concat") +p `[1,2,3] concat [4,5,6]` # => [1, 2, 3, 4, 5, 6] + + +# HEREDOC FUN!!!!!!!1111 +foo(<<A, <<-B, <<C) +this is the text of a + A!!!! +A +and this is text of B!!!!!!111 + B +and here some C +C + +---tokens--- +'a' Name +'.' Operator +'each' Name +'{' Punctuation +'|' Operator +'el' Name +'|' Operator +'anz' Name +'[' Operator +'el' Name +']' Operator +'=' Operator +'anz' Name +'[' Operator +'el' Name +']' Operator +'?' Punctuation +'anz' Name +'[' Operator +'el' Name +']' Operator +'+' Operator +'1' Literal.Number.Integer +':' Punctuation +'1' Literal.Number.Integer +'}' Punctuation +'\n' Text + +'while' Keyword +' ' Text +'x' Name +'<' Operator +'10000' Literal.Number.Integer +'\n' Text + +'#a bis f dienen dazu die Nachbarschaft festzulegen. Man stelle sich die #Zahl von 1 bis 64 im Binärcode vor 1 bedeutet an 0 aus' Comment.Single +'\n ' Text +'b' Name +'=' Operator +'(' Punctuation +'p' Name.Builtin +'[' Operator +'x' Name +']' Operator +'%' Operator +'32' Literal.Number.Integer +')' Punctuation +'/' Operator +'16' Literal.Number.Integer +'<' Operator +'1' Literal.Number.Integer +' ' Text +'?' Operator +' ' Text +'0' Literal.Number.Integer +' ' Text +':' Punctuation +' ' Text +'1' Literal.Number.Integer +'\n\n ' Text +'(' Punctuation +'x' Name +'-' Operator +'102' Literal.Number.Integer +'>' Operator +'=' Operator +'0' Literal.Number.Integer +'?' Operator +' ' Text +'n' Name +'[' Operator +'x' Name +'-' Operator +'102' Literal.Number.Integer +']' Operator +'.' Operator +'to_i' Name +' ' Text +':' Punctuation +' ' Text +'0' Literal.Number.Integer +')' Punctuation +'*' Operator +'a' Name +'+' Operator +'(' Punctuation +'x' Name +'-' Operator +'101' Literal.Number.Integer +'>' Operator +'=' Operator +'0' Literal.Number.Integer +'?' Operator +'n' Name +'[' Operator +'x' Name +'-' Operator +'101' Literal.Number.Integer +']' Operator +'.' Operator +'to_i' Name +' ' Text +':' Punctuation +' ' Text +'0' Literal.Number.Integer +')' Punctuation +'*' Operator +'e' Name +'+' Operator +'n' Name +'[' Operator +'x' Name +'-' Operator +'100' Literal.Number.Integer +']' Operator +'.' Operator +'to_i' Name +'+' Operator +'(' Punctuation +'x' Name +'-' Operator +'99' Literal.Number.Integer +'>' Operator +'=' Operator +'0' Literal.Number.Integer +'?' Operator +' ' Text +'n' Name +'[' Operator +'x' Name +'-' Operator +'99' Literal.Number.Integer +']' Operator +'.' Operator +'to_i' Name +' ' Text +':' Punctuation +' ' Text +'0' Literal.Number.Integer +')' Punctuation +'*' Operator +'f' Name +'+' Operator +'(' Punctuation +'x' Name +'-' Operator +'98' Literal.Number.Integer +'>' Operator +'=' Operator +'0' Literal.Number.Integer +'?' Operator +' ' Text +'n' Name +'[' Operator +'x' Name +'-' Operator +'98' Literal.Number.Integer +']' Operator +'.' Operator +'to_i' Name +' ' Text +':' Punctuation +' ' Text +'0' Literal.Number.Integer +')' Punctuation +'*' Operator +'a' Name +'+' Operator +'\n ' Text +'n' Name +'[' Operator +'x' Name +'+' Operator +'199' Literal.Number.Integer +']' Operator +'.' Operator +'to_i' Name +'*' Operator +'b' Name +'+' Operator +'n' Name +'[' Operator +'x' Name +'+' Operator +'200' Literal.Number.Integer +']' Operator +'.' Operator +'to_i' Name +'*' Operator +'d' Name +'+' Operator +'n' Name +'[' Operator +'x' Name +'+' Operator +'201' Literal.Number.Integer +']' Operator +'.' Operator +'to_i' Name +'*' Operator +'b' Name +'\n\n' Text + +'#und die Ausgabe folgt' Comment.Single +'\n' Text + +'g' Name +'=' Operator +'%w{' Literal.String.Other +'}' Literal.String.Other +'\n' Text + +'x' Name +'=' Operator +'0' Literal.Number.Integer +'\n\n' Text + +'#leere regex' Comment.Single +'\n' Text + +'test' Name.Builtin +' ' Text +'/' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +'123' Literal.Number.Integer +'\n\n' Text + +'while' Keyword +' ' Text +'x' Name +'<' Operator +'100' Literal.Number.Integer +'\n ' Text +'puts' Name.Builtin +'"' Literal.String.Double +'#{' Literal.String.Interpol +'g' Name +'[' Operator +'x' Name +']' Operator +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'x' Name +'+=' Operator +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n' Text + +'puts' Name.Builtin +'"' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'sleep' Name.Builtin +'(' Punctuation +'10' Literal.Number.Integer +')' Punctuation +'\n\n' Text + +'1' Literal.Number.Integer +'E1E1' Name.Constant +'\n' Text + +'puts' Name.Builtin +' ' Text +'30' Literal.Number.Integer +'.' Operator +'send' Name +'(' Punctuation +':/' Literal.String.Symbol +',' Punctuation +' ' Text +'5' Literal.Number.Integer +')' Punctuation +' ' Text +'# prints 6' Comment.Single +'\n\n' Text + +'# fun with class attributes' Comment.Single +'\n' Text + +'class' Keyword +' ' Text +'Foo' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'self' Name.Class +'.' Operator +'blub' Name.Function +' ' Text +'x' Name +'\n ' Text +'if' Keyword +' ' Text +'not' Operator.Word +' ' Text +'x' Name +'.' Operator +'nil?' Name +'\n ' Text +'self' Name.Builtin +'.' Operator +'new' Name +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n ' Text +'def' Keyword +' ' Text +'another_way_to_get_class' Name.Function +'\n ' Text +'self' Name.Builtin +'.' Operator +'class' Name +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'# ruby 1.9 "call operator"' Comment.Single +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'Proc' Name.Constant +'.' Operator +'new' Name +' ' Text +'{' Punctuation +' ' Text +'42' Literal.Number.Integer +' ' Text +'}' Punctuation +'\n' Text + +'a' Name +'.' Operator +'(' Punctuation +')' Punctuation +'\n\n' Text + +'"' Literal.String.Double +'instance variables can be ' Literal.String.Double +'#@included' Literal.String.Interpol +', ' Literal.String.Double +'#@@class_variables' Literal.String.Interpol +'\\n' Literal.String.Escape +' and ' Literal.String.Double +'#$globals' Literal.String.Interpol +' as well.' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'`' Literal.String.Backtick +'instance variables can be ' Literal.String.Backtick +'#@included' Literal.String.Interpol +', ' Literal.String.Backtick +'#@@class_variables' Literal.String.Interpol +'\\n' Literal.String.Escape +' and ' Literal.String.Backtick +'#$globals' Literal.String.Interpol +' as well.' Literal.String.Backtick +'`' Literal.String.Backtick +'\n' Text + +"'" Literal.String.Single +'instance variables can be ' Literal.String.Single +'#@included' Literal.String.Interpol +', ' Literal.String.Single +'#@@class_variables' Literal.String.Interpol +'\\n' Literal.String.Escape +' and ' Literal.String.Single +'#$globals' Literal.String.Interpol +' as well.' Literal.String.Single +"'" Literal.String.Single +'\n' Text + +'/' Literal.String.Regex +'instance variables can be ' Literal.String.Regex +'#@included' Literal.String.Interpol +', ' Literal.String.Regex +'#@@class_variables' Literal.String.Interpol +'\\' Literal.String.Regex +'n and ' Literal.String.Regex +'#$globals' Literal.String.Interpol +' as well.' Literal.String.Regex +'/mousenix' Literal.String.Regex +'\n' Text + +':"' Literal.String.Symbol +'instance variables can be ' Literal.String.Symbol +'#@included' Literal.String.Interpol +', ' Literal.String.Symbol +'#@@class_variables' Literal.String.Interpol +'\\n' Literal.String.Escape +' and ' Literal.String.Symbol +'#$globals' Literal.String.Interpol +' as well.' Literal.String.Symbol +'"' Literal.String.Symbol +'\n' Text + +":'instance variables can be #@included, #@@class_variables\\n and #$globals as well.'" Literal.String.Symbol +'\n' Text + +"%'" Literal.String.Other +'instance variables can be ' Literal.String.Other +'#@included' Literal.String.Interpol +', ' Literal.String.Other +'#@@class_variables' Literal.String.Interpol +'\\' Literal.String.Other +'n and ' Literal.String.Other +'#$globals' Literal.String.Interpol +' as well.' Literal.String.Other +"'" Literal.String.Other +'\n' Text + +"%q'instance variables can be #@included, #@@class_variables\\n and #$globals as well.'" Literal.String.Other +'\n' Text + +"%Q'" Literal.String.Other +'instance variables can be ' Literal.String.Other +'#@included' Literal.String.Interpol +', ' Literal.String.Other +'#@@class_variables' Literal.String.Interpol +'\\' Literal.String.Other +'n and ' Literal.String.Other +'#$globals' Literal.String.Interpol +' as well.' Literal.String.Other +"'" Literal.String.Other +'\n' Text + +"%w'instance variables can be #@included, #@@class_variables\\n and #$globals as well.'" Literal.String.Other +'\n' Text + +"%W'" Literal.String.Other +'instance variables can be ' Literal.String.Other +'#@included' Literal.String.Interpol +', ' Literal.String.Other +'#@@class_variables' Literal.String.Interpol +'\\' Literal.String.Other +'n and ' Literal.String.Other +'#$globals' Literal.String.Interpol +' as well.' Literal.String.Other +"'" Literal.String.Other +'\n' Text + +"%s'instance variables can be #@included, #@@class_variables\\n and #$globals as well.'" Literal.String.Other +'\n' Text + +"%r'" Literal.String.Regex +'instance variables can be ' Literal.String.Regex +'#@included' Literal.String.Interpol +', ' Literal.String.Regex +'#@@class_variables' Literal.String.Interpol +'\\' Literal.String.Regex +'n and ' Literal.String.Regex +'#$globals' Literal.String.Interpol +' as well.' Literal.String.Regex +"'" Literal.String.Regex +'\n' Text + +"%x'" Literal.String.Other +'instance variables can be ' Literal.String.Other +'#@included' Literal.String.Interpol +', ' Literal.String.Other +'#@@class_variables' Literal.String.Interpol +'\\' Literal.String.Other +'n and ' Literal.String.Other +'#$globals' Literal.String.Interpol +' as well.' Literal.String.Other +"'" Literal.String.Other +'\n\n' Text + +'#%W[ but #@0illegal_values look strange.]' Comment.Single +'\n\n' Text + +'%s#ruby allows strange#' Literal.String.Other +'{' Punctuation +'constructs' Name +'}' Punctuation +'\n' Text + +'%s#ruby allows strange#' Literal.String.Other +'$constructs' Name.Variable.Global +'\n' Text + +'%s#ruby allows strange#' Literal.String.Other +'@@constructs' Name.Variable.Class +'\n\n' Text + +'##################################################################' Comment.Single +'\n' Text + +'# HEREDOCS' Comment.Single +'\n' Text + +'foo' Name +'(' Punctuation +'<<-' Operator +'' Literal.String.Heredoc +'A' Literal.String.Delimiter +'' Literal.String.Heredoc +',' Punctuation +' ' Text +'<<-' Operator +'' Literal.String.Heredoc +'B' Literal.String.Delimiter +'' Literal.String.Heredoc +')' Punctuation +'\n' Text + +'this is the text of a\n' Literal.String.Heredoc + +'A\n' Literal.String.Delimiter + +'and this is the text of b\n' Literal.String.Heredoc + +'B\n' Literal.String.Delimiter + +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'<<' Operator +'"' Literal.String.Heredoc +'EOF' Literal.String.Delimiter +'"' Literal.String.Heredoc +'\n' Text + +'This is a multiline #$here document\n' Literal.String.Heredoc + +'terminated by EOF on a line by itself\n' Literal.String.Heredoc + +'EOF\n' Literal.String.Delimiter + +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'<<' Operator +"'" Literal.String.Heredoc +'EOF' Literal.String.Delimiter +"'" Literal.String.Heredoc +'\n' Text + +'This is a multiline #$here document\n' Literal.String.Heredoc + +'terminated by EOF on a line by itself\n' Literal.String.Heredoc + +'EOF\n' Literal.String.Delimiter + +'\n' Text + +'b' Name +'=' Operator +'(' Punctuation +'p' Name.Builtin +'[' Operator +'x' Name +']' Operator +' ' Text +'%' Operator +'32' Literal.Number.Integer +')' Punctuation +'/' Operator +'16' Literal.Number.Integer +'<' Operator +'1' Literal.Number.Integer +' ' Text +'?' Operator +' ' Text +'0' Literal.Number.Integer +' ' Text +':' Punctuation +' ' Text +'1' Literal.Number.Integer +'\n\n' Text + +'<<' Operator +'"' Literal.String.Heredoc +'' Literal.String.Delimiter +'"' Literal.String.Heredoc +'\n' Text + +'#{test}\n' Literal.String.Heredoc + +'#@bla\n' Literal.String.Heredoc + +'#die suppe!!!\n' Literal.String.Heredoc + +'\\xfffff\n' Literal.String.Heredoc + +'\n' Literal.String.Delimiter + +'\n' Text + +'super' Keyword +' ' Text +'<<-' Operator +'' Literal.String.Heredoc +'EOE' Literal.String.Delimiter +'' Literal.String.Heredoc +' ' Text +'%' Operator +' ' Text +'[' Operator +'\n' Text + +' foo\n' Literal.String.Heredoc + +'EOE\n' Literal.String.Delimiter + +'\n' Text + +'<<' Operator +'' Literal.String.Heredoc +'X' Literal.String.Delimiter +'' Literal.String.Heredoc +'\n' Text + +'X\n' Literal.String.Delimiter + +'X' Name +'\n\n' Text + +'%s(' Literal.String.Other +'uninter' Literal.String.Other +'\\)' Literal.String.Other +'pre' Literal.String.Other +'\\' Literal.String.Other +'ted' Literal.String.Other +')' Literal.String.Other +' ' Text +'# comment here' Comment.Single +'\n' Text + +'%q(' Literal.String.Other +'uninter' Literal.String.Other +'\\)' Literal.String.Other +'pre' Literal.String.Other +'\\' Literal.String.Other +'ted' Literal.String.Other +')' Literal.String.Other +' ' Text +'# comment here' Comment.Single +'\n' Text + +'%Q(' Literal.String.Other +'inter' Literal.String.Other +'\\)' Literal.String.Other +'pre' Literal.String.Other +'\\t' Literal.String.Escape +'ed' Literal.String.Other +')' Literal.String.Other +' ' Text +'# comment here' Comment.Single +'\n' Text + +':"' Literal.String.Symbol +'inter' Literal.String.Symbol +'\\' Literal.String.Symbol +')pre' Literal.String.Symbol +'\\t' Literal.String.Escape +'ed' Literal.String.Symbol +'"' Literal.String.Symbol +' ' Text +'# comment here' Comment.Single +'\n' Text + +":'uninter\\'pre\\ted'" Literal.String.Symbol +' ' Text +'# comment here' Comment.Single +'\n\n' Text + +'%q[' Literal.String.Other +'haha! ' Literal.String.Other +'[' Literal.String.Other +'nesting ' Literal.String.Other +'[' Literal.String.Other +'rocks' Literal.String.Other +']' Literal.String.Other +' ! ' Literal.String.Other +']' Literal.String.Other +' ' Literal.String.Other +']' Literal.String.Other +' ' Text +'# commeht here' Comment.Single +'\n\n\n' Text + +'##################################################################' Comment.Single +'\n' Text + +'class' Keyword +' ' Text +'NP' Name.Class +'\n' Text + +'def' Keyword +' ' Text +'initialize' Name.Function +' ' Text +'a' Name +'=' Operator +'@p' Name.Variable.Instance +'=' Operator +'[' Operator +']' Operator +',' Punctuation +' ' Text +'b' Name +'=' Operator +'@b' Name.Variable.Instance +'=' Operator +'[' Operator +']' Operator +';' Punctuation +' ' Text +'end' Keyword +'\n' Text + +'def' Keyword +' ' Text +'+@' Name.Function +';' Punctuation +'@b' Name.Variable.Instance +'<<' Operator +'1' Literal.Number.Integer +';' Punctuation +'b2c' Name +' ' Text +'end' Keyword +';' Punctuation +'def' Keyword +'-@' Name.Function +';' Punctuation +'@b' Name.Variable.Instance +'<<' Operator +'0' Literal.Number.Integer +';' Punctuation +'b2c' Name +' ' Text +'end' Keyword +'\n' Text + +'def' Keyword +' ' Text +'b2c' Name.Function +';' Punctuation +'if' Keyword +' ' Text +'@b' Name.Variable.Instance +'.' Operator +'size' Name +'==' Operator +'8' Literal.Number.Integer +';' Punctuation +'c' Name +'=' Operator +'0' Literal.Number.Integer +';' Punctuation +'@b' Name.Variable.Instance +'.' Operator +'each' Name +'{' Punctuation +'|' Operator +'b' Name +'|' Operator +'c' Name +'<<' Operator +'=' Operator +'1' Literal.Number.Integer +';' Punctuation +'c' Name +'|=' Operator +'b' Name +'}' Punctuation +';' Punctuation +'send' Name.Builtin +'(' Punctuation +'\n ' Text +"'" Literal.String.Single +'lave' Literal.String.Single +"'" Literal.String.Single +'.' Operator +'reverse' Name +',' Punctuation +'(' Punctuation +'@p' Name.Variable.Instance +'.' Operator +'join' Name +')' Punctuation +')' Punctuation +'if' Keyword +' ' Text +'c' Name +'==' Operator +'0' Literal.Number.Integer +';' Punctuation +'@p' Name.Variable.Instance +'<<' Operator +' ' Text +'c' Name +'.' Operator +'chr' Name +';' Punctuation +'@b' Name.Variable.Instance +'=' Operator +'[' Operator +']' Operator +' ' Text +'end' Keyword +'\n ' Text +'self' Name.Builtin +' ' Text +'end' Keyword +' ' Text +'end' Keyword +' ' Text +';' Punctuation +' ' Text +'begin' Keyword +' ' Text +'_' Name +' ' Text +'=' Operator +' ' Text +'NP' Name.Constant +'.' Operator +'new' Name +' ' Text +'end' Keyword +'\n\n\n' Text + +'# Regexes' Comment.Single +'\n' Text + +'/' Literal.String.Regex +'\nthis is a\nmutliline\nregex\n' Literal.String.Regex + +'/' Literal.String.Regex +'\n\n' Text + +'this' Name +' ' Text +'/' Literal.String.Regex +'is a\nmultiline regex too' Literal.String.Regex +'/' Literal.String.Regex +'\n\n' Text + +'also' Name +' ' Text +'/' Literal.String.Regex +'4\nis one' Literal.String.Regex +'/' Literal.String.Regex +'\n\n' Text + +'this' Name +'(' Punctuation +'/' Literal.String.Regex +'\ntoo\n' Literal.String.Regex + +'/' Literal.String.Regex +')' Punctuation +'\n\n' Text + +'# this not' Comment.Single +'\n' Text + +'2' Literal.Number.Integer +' ' Text +'/' Operator +'4' Literal.Number.Integer +'\n' Text + +'asfsadf' Name +'/' Operator +'\n\n\n' Text + +'#from: http://coderay.rubychan.de/rays/show/383' Comment.Single +'\n' Text + +'class' Keyword +' ' Text +'Object' Name.Class +'\n ' Text +'alias' Keyword +' ' Text +':xeq' Literal.String.Symbol +' ' Text +':`' Literal.String.Symbol +'\n ' Text +'def' Keyword +' ' Text +'`' Name.Function +'(' Punctuation +'cmd' Name +',' Punctuation +' ' Text +'p2' Name +')' Punctuation +'\n ' Text +'self' Name.Builtin +'.' Operator +'method' Name +'(' Punctuation +'cmd' Name +'.' Operator +'to_sym' Name +')' Punctuation +'.' Operator +'call' Name +'(' Punctuation +'p2' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n' Text + +'p' Name.Builtin +' ' Text +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +'2' Literal.Number.Integer +',' Punctuation +'3' Literal.Number.Integer +']' Operator +'.' Operator +'`' Name.Operator +'(' Punctuation +"'" Literal.String.Single +'concat' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +'[' Operator +'4' Literal.Number.Integer +',' Punctuation +'5' Literal.Number.Integer +',' Punctuation +'6' Literal.Number.Integer +']' Operator +')' Punctuation +' ' Text +'# => [1, 2, 3, 4, 5, 6]' Comment.Single +'\n' Text + +'p' Name.Builtin +' ' Text +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +'2' Literal.Number.Integer +',' Punctuation +'3' Literal.Number.Integer +']' Operator +'.' Operator +'`' Name.Operator +'(' Punctuation +':concat' Literal.String.Symbol +',' Punctuation +' ' Text +'[' Operator +'4' Literal.Number.Integer +',' Punctuation +'5' Literal.Number.Integer +',' Punctuation +'6' Literal.Number.Integer +']' Operator +')' Punctuation +' ' Text +'# => [1, 2, 3, 4, 5, 6]' Comment.Single +'\n' Text + +'p' Name.Builtin +' ' Text +'"' Literal.String.Double +'Hurra! ' Literal.String.Double +'"' Literal.String.Double +'.' Operator +'`' Name.Operator +'(' Punctuation +':*' Literal.String.Symbol +',' Punctuation +' ' Text +'3' Literal.Number.Integer +')' Punctuation +' ' Text +'# => "Hurra! Hurra! Hurra! "' Comment.Single +'\n' Text + +'p' Name.Builtin +' ' Text +'"' Literal.String.Double +'Hurra! ' Literal.String.Double +'"' Literal.String.Double +'.' Operator +'`' Name.Operator +'(' Punctuation +"'" Literal.String.Single +'*' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +'3' Literal.Number.Integer +')' Punctuation +' ' Text +'# => "Hurra! Hurra! Hurra! "' Comment.Single +'\n' Text + +'# Leider geht nicht die Wunschform' Comment.Single +'\n' Text + +'# [1,2,3] `concat` [4,5,6]' Comment.Single +'\n\n' Text + +'class' Keyword +' ' Text +'Object' Name.Class +'\n ' Text +'@@infixops' Name.Variable.Class +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +'\n ' Text +'alias' Keyword +' ' Text +':xeq' Literal.String.Symbol +' ' Text +':`' Literal.String.Symbol +'\n ' Text +'def' Keyword +' ' Text +'addinfix' Name.Function +'(' Punctuation +'operator' Name +')' Punctuation +'\n ' Text +'@@infixops' Name.Variable.Class +' ' Text +'<<' Operator +' ' Text +'operator' Name +'\n ' Text +'end' Keyword +'\n ' Text +'def' Keyword +' ' Text +'`' Name.Function +'(' Punctuation +'expression' Name +')' Punctuation +'\n ' Text +'@@infixops' Name.Variable.Class +'.' Operator +'each' Name +'{' Punctuation +'|' Operator +'op' Name +'|' Operator +'break' Keyword +' ' Text +'if' Keyword +' ' Text +'expression' Name +'.' Operator +'match' Name +'(' Punctuation +'/' Literal.String.Regex +'^(.*?) (' Literal.String.Regex +'#{' Literal.String.Interpol +'op' Name +'}' Literal.String.Interpol +') (.*)$' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'}' Punctuation +'\n ' Text +'raise' Keyword +' ' Text +'"' Literal.String.Double +'unknown infix operator in expression: ' Literal.String.Double +'#{' Literal.String.Interpol +'expression' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +' ' Text +'if' Keyword +' ' Text +'$2' Name.Variable.Global +' ' Text +'==' Operator +' ' Text +'nil' Keyword.Pseudo +'\n ' Text +'eval' Name.Builtin +'(' Punctuation +'$1' Name.Variable.Global +')' Punctuation +'.' Operator +'method' Name +'(' Punctuation +'$2' Name.Variable.Global +'.' Operator +'to_sym' Name +')' Punctuation +'.' Operator +'call' Name +'(' Punctuation +'eval' Name.Builtin +'(' Punctuation +'$3' Name.Variable.Global +')' Punctuation +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n' Text + +'addinfix' Name +'(' Punctuation +'"' Literal.String.Double +'concat' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'p' Name.Builtin +' ' Text +'`' Literal.String.Backtick +'[1,2,3] concat [4,5,6]' Literal.String.Backtick +'`' Literal.String.Backtick +' ' Text +'# => [1, 2, 3, 4, 5, 6]' Comment.Single +'\n\n\n' Text + +'# HEREDOC FUN!!!!!!!1111' Comment.Single +'\n' Text + +'foo' Name +'(' Punctuation +'<<' Operator +'' Literal.String.Heredoc +'A' Literal.String.Delimiter +'' Literal.String.Heredoc +',' Punctuation +' ' Text +'<<-' Operator +'' Literal.String.Heredoc +'B' Literal.String.Delimiter +'' Literal.String.Heredoc +',' Punctuation +' ' Text +'<<' Operator +'' Literal.String.Heredoc +'C' Literal.String.Delimiter +'' Literal.String.Heredoc +')' Punctuation +'\n' Text + +'this is the text of a\n' Literal.String.Heredoc + +' A!!!!\n' Literal.String.Heredoc + +'A\n' Literal.String.Delimiter + +'and this is text of B!!!!!!111\n' Literal.String.Heredoc + +' B\n' Literal.String.Delimiter + +'and here some C\n' Literal.String.Heredoc + +'C\n' Literal.String.Delimiter |
