Class: Platform::IEL::SexpParser::Node
- Inherits:
-
Object
- Object
- Platform::IEL::SexpParser::Node
- Includes:
- Comparable
- Defined in:
- lib/introhive_expression_language/iel/sexp_parser.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
- .boolean(boolean_value, source = 0, context = nil) ⇒ Object
- .list(contents, source = 0, context = nil) ⇒ Object
- .nan(source = 0, context = nil) ⇒ Object
- .nil(source = 0, context = nil) ⇒ Object
- .numeric_literal(n, source = 0, context = nil) ⇒ Object
- .string_literal(str, source = 0, context = nil) ⇒ Object
- .symbol(symbol_name, source = 0, context = nil) ⇒ Object
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(kind, source, value = nil, context = nil) ⇒ Node
constructor
A new instance of Node.
- #inspect ⇒ Object
- #source_desc ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(kind, source, value = nil, context = nil) ⇒ Node
Returns a new instance of Node.
97 98 99 100 101 102 |
# File 'lib/introhive_expression_language/iel/sexp_parser.rb', line 97 def initialize(kind, source, value=nil, context=nil) @kind = kind @source = source @value = value @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
95 96 97 |
# File 'lib/introhive_expression_language/iel/sexp_parser.rb', line 95 def context @context end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
95 96 97 |
# File 'lib/introhive_expression_language/iel/sexp_parser.rb', line 95 def kind @kind end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
95 96 97 |
# File 'lib/introhive_expression_language/iel/sexp_parser.rb', line 95 def source @source end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
95 96 97 |
# File 'lib/introhive_expression_language/iel/sexp_parser.rb', line 95 def value @value end |
Class Method Details
.boolean(boolean_value, source = 0, context = nil) ⇒ Object
154 155 156 |
# File 'lib/introhive_expression_language/iel/sexp_parser.rb', line 154 def self.boolean(boolean_value, source = 0, context = nil) new(:boolean, source, boolean_value) end |
.list(contents, source = 0, context = nil) ⇒ Object
146 147 148 |
# File 'lib/introhive_expression_language/iel/sexp_parser.rb', line 146 def self.list(contents, source = 0, context = nil) new(:list, source, contents) end |
.nan(source = 0, context = nil) ⇒ Object
142 143 144 |
# File 'lib/introhive_expression_language/iel/sexp_parser.rb', line 142 def self.nan(source = 0, context = nil) new(:nan, source) end |
.nil(source = 0, context = nil) ⇒ Object
150 151 152 |
# File 'lib/introhive_expression_language/iel/sexp_parser.rb', line 150 def self.nil(source = 0, context = nil) new(:nil, source) end |
.numeric_literal(n, source = 0, context = nil) ⇒ Object
138 139 140 |
# File 'lib/introhive_expression_language/iel/sexp_parser.rb', line 138 def self.numeric_literal(n, source = 0, context = nil) new(:numeric_literal, source, n) end |
.string_literal(str, source = 0, context = nil) ⇒ Object
134 135 136 |
# File 'lib/introhive_expression_language/iel/sexp_parser.rb', line 134 def self.string_literal(str, source = 0, context = nil) new(:string_literal, source, str) end |
.symbol(symbol_name, source = 0, context = nil) ⇒ Object
130 131 132 |
# File 'lib/introhive_expression_language/iel/sexp_parser.rb', line 130 def self.symbol(symbol_name, source = 0, context = nil) new(:symbol, source, symbol_name) end |
Instance Method Details
#<=>(other) ⇒ Object
112 113 114 |
# File 'lib/introhive_expression_language/iel/sexp_parser.rb', line 112 def <=>(other) [kind, value] <=> [other.kind, other.value] end |
#inspect ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/introhive_expression_language/iel/sexp_parser.rb', line 116 def inspect if value.is_a? Array "[#{value.map { |item| item.inspect}.join(', ')}]" elsif kind == :symbol ":#{value}" elsif kind == :nil 'nil' elsif kind == :nan 'nan' else value.inspect end end |
#source_desc ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/introhive_expression_language/iel/sexp_parser.rb', line 104 def source_desc if context context.code_line(@source) else " Offset #{@source}" end end |
#to_s ⇒ Object
158 159 160 |
# File 'lib/introhive_expression_language/iel/sexp_parser.rb', line 158 def to_s value end |