Class: CodeBreaker::Parser
- Inherits:
-
Object
- Object
- CodeBreaker::Parser
- Includes:
- CodeBreaker::Parsable::Assignments, CodeBreaker::Parsable::DataTypes, CodeBreaker::Parsable::Keywords, CodeBreaker::Parsable::LanguageElements, CodeBreaker::Parsable::Ranges, CodeBreaker::Parsable::VariableTypes, CodeBreaker::Parsable::Wrappers
- Defined in:
- lib/code_breaker/parser.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
-
#initialize(code) ⇒ Parser
constructor
A new instance of Parser.
- #run ⇒ Object (also: #output)
Methods included from CodeBreaker::Parsable::LanguageElements
#parse_block_pass_node, #parse_splat_node
Methods included from CodeBreaker::Parsable::Node
#method_missing, #not_implemented_message, #parse, #parse_as_hash, #parse_as_last_child_hash, #parse_as_node_type, #parse_children
Methods included from CodeBreaker::Parsable::Keywords
#parse_case_node, #parse_for_node, #parse_if_node, #parse_kwbegin_node, #parse_loop_node, #parse_module_node, #parse_return_node, #parse_when_node
Methods included from CodeBreaker::Parsable::Assignments
#parse_casgn_node, #parse_masgn_node, #parse_mlhs_node
Methods included from CodeBreaker::Parsable::DataTypes
#parse_dstr_node, #parse_false_node, #parse_float_node, #parse_int_node, #parse_nil_node, #parse_pair_node, #parse_regexp_node, #parse_str_node, #parse_sym_node, #parse_true_node, #parse_xstr_node
Methods included from CodeBreaker::Parsable::Wrappers
Constructor Details
#initialize(code) ⇒ Parser
Returns a new instance of Parser.
16 17 18 |
# File 'lib/code_breaker/parser.rb', line 16 def initialize(code) @input = code.to_s.strip end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CodeBreaker::Parsable::Node
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
14 15 16 |
# File 'lib/code_breaker/parser.rb', line 14 def input @input end |
Instance Method Details
#run ⇒ Object Also known as: output
20 21 22 23 24 25 26 27 |
# File 'lib/code_breaker/parser.rb', line 20 def run unless @output ast = ::Parser::CurrentRuby.parse(input) @output = ast.nil? ? [] : parse(ast.loc.node) end @output end |