Module: Resyma::Core
- Defined in:
- 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
Defined Under Namespace
Modules: Matchable, RegexpOp, Utils
Classes: Automaton, AutomatonBuilder, ConversionError, Converter, Engine, EpsilonClass, Field, MultipleProcedureError, PTNodeMatcher, ParseTree, ParseTreeBuilder, Regexp, RegexpConcat, RegexpNothing, RegexpRepeat, RegexpSelect, RegexpSomething, SourceLocator, State, TransitionTable, Tuple2, Tuple4
Constant Summary
collapse
- SOURCE_LOCATORS =
[]
- CALLABLE_TYPES =
- Epsilon =
EpsilonClass.new
- DEFAULT_CONVERTER =
Converter.new
- CONST_TOKEN_TABLE =
{
"(" => :round_left,
")" => :round_right,
"begin" => :kwd_begin,
"end" => :kwd_end,
"," => :comma,
"[" => :square_left,
"]" => :square_right,
"*" => :star,
"**" => :star2,
":" => :colon,
"=>" => :arrow,
"{" => :curly_left,
"}" => :curly_right,
".." => :dot2,
"..." => :dot3,
"defined?" => :kwd_defined?,
"." => :dot,
"&." => :and_dot,
"do" => :kwd_do,
"&" => :ampersand,
"|" => :tube,
"=" => :eq,
"true" => :the_true,
"false" => :the_false,
"nil" => :the_nil
}.freeze
Class Method Summary
collapse
Class Method Details
.def_source_locator(regexp, &block) ⇒ Object
10
11
12
|
# File 'lib/resyma/core/parsetree/source.rb', line 10
def self.def_source_locator(regexp, &block)
SOURCE_LOCATORS.unshift SourceLocator.new(regexp, block)
end
|
.line_number_of_callable(ast) ⇒ Object
38
39
40
41
42
43
|
# File 'lib/resyma/core/parsetree/source.rb', line 38
def self.line_number_of_callable(ast)
case ast.type
when Set[:def, :defs] then ast.loc.keyword.line
when :block then ast.loc.begin.line
end
end
|
.locate(procedure) ⇒ nil, Parser::AST::Node
Locate the AST of a callable object
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/resyma/core/parsetree/source.rb', line 23
def self.locate(procedure)
if procedure.respond_to? :source_location
filename, lino = procedure.source_location
SOURCE_LOCATORS.each do |locator|
if locator.matcher.match?(filename)
return locator.locate.call(procedure, filename, lino)
end
end
end
nil
end
|
.locate_possible_procedures(ast, lino) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/resyma/core/parsetree/source.rb', line 45
def self.locate_possible_procedures(ast, lino)
return [] unless ast.is_a?(Parser::AST::Node)
procs = []
if CALLABLE_TYPES.include?(ast.type) &&
line_number_of_callable(ast) == lino
procs.push ast
end
ast.children.each do |sub|
procs += locate_possible_procedures(sub, lino)
end
procs
end
|