Class: NScript::LiteralNode
- Inherits:
-
Node
- Object
- Node
- NScript::LiteralNode
show all
- Defined in:
- lib/nscript/parser/nodes.rb
Constant Summary
collapse
- STATEMENTS =
['break', 'continue']
Constants inherited
from Node
Node::TAB
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Node
#children, children, #compile, #compile_closure, #contains?, #idt, statement, statement_only, top_sensitive, #top_sensitive?, #unwrap, #write
Constructor Details
Returns a new instance of LiteralNode.
155
156
157
|
# File 'lib/nscript/parser/nodes.rb', line 155
def initialize(value)
@value = value
end
|
Class Method Details
.wrap(string) ⇒ Object
151
152
153
|
# File 'lib/nscript/parser/nodes.rb', line 151
def self.wrap(string)
self.new(Value.new(string))
end
|
Instance Method Details
#compile_node(o) ⇒ Object
164
165
166
167
168
|
# File 'lib/nscript/parser/nodes.rb', line 164
def compile_node(o)
indent = statement? ? idt : ''
ending = statement? ? ';' : ''
"#{indent}#{@value}#{ending}"
end
|
#statement? ⇒ Boolean
Also known as:
statement_only?
159
160
161
|
# File 'lib/nscript/parser/nodes.rb', line 159
def statement?
STATEMENTS.include?(@value.to_s)
end
|