Class MCollective::Matcher::Scanner
In: lib/mcollective/matcher/scanner.rb
Parent: Object

Methods

get_token   new  

Attributes

arguments  [RW] 
token_index  [RW] 

Public Class methods

[Source]

    # File lib/mcollective/matcher/scanner.rb, line 6
 6:       def initialize(arguments)
 7:         @token_index = 0
 8:         @arguments = arguments.split("")
 9:         @seperation_counter = 0
10:         @white_spaces = 0
11:       end

Public Instance methods

Scans the input string and identifies single language tokens

[Source]

    # File lib/mcollective/matcher/scanner.rb, line 14
14:       def get_token
15:         if @token_index >= @arguments.size
16:           return nil
17:         end
18: 
19:         case @arguments[@token_index]
20:         when "("
21:           return "(", "("
22: 
23:         when ")"
24:           return ")", ")"
25: 
26:         when "n"
27:           if (@arguments[@token_index + 1] == "o") && (@arguments[@token_index + 2] == "t") && ((@arguments[@token_index + 3] == " ") || (@arguments[@token_index + 3] == "("))
28:             @token_index += 2
29:             return "not", "not"
30:           else
31:             gen_statement
32:           end
33: 
34:         when "!"
35:           return "not", "not"
36: 
37:         when "a"
38:           if (@arguments[@token_index + 1] == "n") && (@arguments[@token_index + 2] == "d") && ((@arguments[@token_index + 3] == " ") || (@arguments[@token_index + 3] == "("))
39:             @token_index += 2
40:             return "and", "and"
41:           else
42:             gen_statement
43:           end
44: 
45:         when "o"
46:           if (@arguments[@token_index + 1] == "r") && ((@arguments[@token_index + 2] == " ") || (@arguments[@token_index + 2] == "("))
47:             @token_index += 1
48:             return "or", "or"
49:           else
50:             gen_statement
51:           end
52: 
53:         when " "
54:           return " ", " "
55: 
56:         else
57:           gen_statement
58:         end
59:       end

[Validate]