Class: Python::FileInterpreter
- Inherits:
-
Object
- Object
- Python::FileInterpreter
- Defined in:
- lib/python/file_interpreter.rb
Constant Summary collapse
- ParsingError =
Class.new(RuntimeError)
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(code, bind = {}) ⇒ FileInterpreter
constructor
A new instance of FileInterpreter.
- #parse ⇒ Object
Constructor Details
#initialize(code, bind = {}) ⇒ FileInterpreter
Returns a new instance of FileInterpreter.
9 10 11 12 |
# File 'lib/python/file_interpreter.rb', line 9 def initialize(code, bind={}) @code = code @bind = bind end |
Instance Method Details
#execute ⇒ Object
25 26 27 |
# File 'lib/python/file_interpreter.rb', line 25 def execute parse().eval(Environment.new(@bind)) end |
#parse ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/python/file_interpreter.rb', line 14 def parse parser = Parser::StatementParser.file_input result = parser.parse(Parser::IndentConverter.new.convert(@code)) if result.is_a?(Parser::Succeeded) && result.rest == "" result.parsed else raise ParsingError.new end end |