Sha256: 9bcc790ef21842d2ddce5b719061682d6f63bf471af2d95f2713a4f19dd7c847
Contents?: true
Size: 919 Bytes
Versions: 1
Compression:
Stored size: 919 Bytes
Contents
# -*- coding: utf-8 -*- # # ノードとノード間遷移 # # (self) pat dest # ■ ----------> □ # ----------> □ # ----------> □ # 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 :accept, true attr :pars, true 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
re_expand-0.0.1 | lib/Node.rb |