Sha256: cdb506f0e1450851cf48ad9b52e703b273a82c0e9026af4f7d87bc5786121d37
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
# -*- coding: utf-8 -*- # # ノードとノード間遷移 # # (self) pat dest # ■ ----------> □ # ----------> □ # ----------> □ # module ReExpand class Trans def initialize(pat,dest) # pat にマッチしたら dest に遷移 @pat = pat @dest = dest end attr_reader :pat, :dest def str @pat.split(/\t/)[0].to_s end def arg if @pat =~ /^(.*)\t(.*)$/ then return $2 else return @pat end end end class Node @@id = 1 @@nodes = {} def initialize @accept = nil @trans = [] @id = @@id @@nodes[@id] = self @@id += 1 @pars = [] end attr_reader :id attr_reader :trans attr_accessor :accept,:pars def addTrans(pat,dest) t = Trans.new(pat,dest) @trans << t end def Node.node(id) # ノードidからノードを取得 @@nodes[id.to_i] end def Node.nodes @@nodes.values end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
re_expand-0.0.6 | lib/Node.rb |
re_expand-0.0.4 | lib/Node.rb |