lib/textpow/syntax.rb in textpow1x-1.2.1 vs lib/textpow/syntax.rb in textpow1x-1.2.2
- old
+ new
@@ -54,18 +54,18 @@
attr_accessor :beginCaptures
attr_accessor :endCaptures
attr_accessor :repository
attr_accessor :patterns
- def self.load(file, name_space = :default)
+ def self.load(file, options={})
table = convert_file_to_table(file)
- SyntaxNode.new(table, nil, name_space)
+ SyntaxNode.new(table, options)
end
- def initialize(table, syntax = nil, name_space = :default)
- @syntax = syntax || self
- @name_space = name_space
+ def initialize(table, options={})
+ @syntax = options[:syntax] || self
+ @name_space = options[:name_space]
register_in_syntaxes(table["scopeName"])
parse_and_store_syntax_info(table)
end
@@ -132,26 +132,26 @@
else
YAML.load_file(file)
end
end
- def parse_repository repository
+ def parse_repository(repository)
@repository = {}
repository.each do |key, value|
if value["include"]
@repository[key] = SyntaxProxy.new(value["include"], syntax)
else
- @repository[key] = SyntaxNode.new(value, syntax, @name_space)
+ @repository[key] = SyntaxNode.new(value, :syntax => syntax, :name_space => @name_space)
end
end
end
- def create_children patterns
+ def create_children(patterns)
@patterns = patterns.map do |pattern|
if pattern["include"]
SyntaxProxy.new(pattern["include"], syntax)
else
- SyntaxNode.new(pattern, syntax, @name_space)
+ SyntaxNode.new(pattern, :syntax => syntax, :name_space => @name_space)
end
end
end
def parse_captures name, pattern, match, processor