Module: Resyma
- Defined in:
- lib/resyma.rb,
lib/resyma/version.rb,
lib/resyma/language.rb,
lib/resyma/parsetree.rb,
lib/resyma/core/utilities.rb,
lib/resyma/core/algorithm/tuple.rb,
lib/resyma/core/automaton/state.rb,
lib/resyma/core/algorithm/engine.rb,
lib/resyma/core/automaton/regexp.rb,
lib/resyma/core/parsetree/source.rb,
lib/resyma/core/algorithm/matcher.rb,
lib/resyma/core/automaton/builder.rb,
lib/resyma/core/parsetree/builder.rb,
lib/resyma/core/automaton/matchable.rb,
lib/resyma/core/automaton/visualize.rb,
lib/resyma/core/parsetree/converter.rb,
lib/resyma/core/parsetree/traversal.rb,
lib/resyma/core/automaton/definition.rb,
lib/resyma/core/automaton/transition.rb,
lib/resyma/core/parsetree/definition.rb,
lib/resyma/core/automaton/epsilon_NFA.rb,
lib/resyma/core/parsetree/default_converter.rb
Overview
Interfaces of Resyma services
Defined Under Namespace
Modules: Core Classes: ActionEnvironment, Error, Evaluator, IllegalLanguageDefinitionError, IllegalRegexError, Language, LanguageSyntaxError, MonoLanguage, NoASTError, RegexBuildVistor, UnsupportedError
Constant Summary collapse
- VERSION =
"0.1.2"
Class Method Summary collapse
-
.body_parsetree_of(procedure) ⇒ [Resyma::Core::ParseTree, Binding, filename, lino]
Derive the parse tree of a function body.
-
.extract_body(procedure_ast) ⇒ Parser::AST::Node
Extract body part from AST of a procedure-like object.
-
.source_of(procedure) ⇒ [Parser::AST::Node, Binding, filename, lino]
Derive an AST from a procedure-like object.
Class Method Details
.body_parsetree_of(procedure) ⇒ [Resyma::Core::ParseTree, Binding, filename, lino]
Derive the parse tree of a function body
51 52 53 54 55 |
# File 'lib/resyma/parsetree.rb', line 51 def self.body_parsetree_of(procedure) ast, bd, filename, lino = source_of(procedure) body_ast = extract_body(ast) [Core::DEFAULT_CONVERTER.convert(body_ast), bd, filename, lino] end |
.extract_body(procedure_ast) ⇒ Parser::AST::Node
Extract body part from AST of a procedure-like object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/resyma/parsetree.rb', line 31 def self.extract_body(procedure_ast) case procedure_ast.type when :block then procedure_ast.children[2] when :def then procedure_ast.children[2] when :defs then procedure_ast.children[3] else raise UnsupportedError, "Not a supported type of procedure: #{procedure_ast.type}" end end |
.source_of(procedure) ⇒ [Parser::AST::Node, Binding, filename, lino]
Derive an AST from a procedure-like object
16 17 18 19 20 21 22 |
# File 'lib/resyma/parsetree.rb', line 16 def self.source_of(procedure) procedure = procedure.to_proc ast = Core.locate(procedure) raise UnsupportedError, "Cannot locate the source of #{ast}" if ast.nil? [ast, procedure.binding, *procedure.source_location] end |