ruby-graphviz 0.9.18 → 0.9.19

Sign up to get free protection for your applications and to get access to all the features.
data/AUTHORS CHANGED
@@ -10,6 +10,7 @@ hipe <http://github.com/hipe>
10
10
  Stefan Huber <http://github.com/MSNexploder>
11
11
  Nigel Thorne <http://github.com/NigelThorne>
12
12
  Rolf Timmermans <http://github.com/rolftimmermans>
13
+ Jonas Elfström <http://github.com/jonelf>
13
14
 
14
15
  Thanks to :
15
16
 
data/README.rdoc CHANGED
@@ -16,6 +16,18 @@ Interface to the GraphViz graphing tool
16
16
 
17
17
  == CHANGELOG
18
18
 
19
+ === 0.9.19 :
20
+ * Add strict digraph support (by Jonas Elfström) (see sample58.rb)
21
+ g = GraphViz.new(:G, :type => "strict digraph")
22
+ # or
23
+ g = GraphViz.new(:G, :type => "digraph", :strict => true)
24
+ # or
25
+ g = GraphViz.digraph(:G, :strict => true)
26
+ # or
27
+ g = GraphViz.strict_digraph(:G)
28
+ * Add GraphViz#root_graph, Node#root_graph, Edge#root_graph
29
+ * The GraphML parser now accept a graphml file or string
30
+
19
31
  === 0.9.18 :
20
32
  * JRuby bug correction (by Nigel Thorne)
21
33
  * Fix autoload problem for Rubinius (by Rolf Timmermans)
@@ -0,0 +1,24 @@
1
+ graph A
2
+ {
3
+ graph [nodesep="0.10", size="7,5", bb="0,0,737,832"];
4
+ node [fontsize="12.00", shape=circle, height = 0.4 width = 0.4 fixedsize="true"];
5
+ 779 -- 780 [label = 6.5 style = "bold" ];
6
+ 522 -- 523 [label = 6.2 style = "bold" ];
7
+ 527 -- 528 [label = 6.0 style = "bold" ];
8
+ 752 -- 753 [label = 5.1 style = "solid"];
9
+ 576 -- 577 [label = 5.1 style = "solid"];
10
+ 578 -- 579 [label = 4.8 style = "dashed"];
11
+ 757 -- 758 [label = 4.6 style = "dashed"];
12
+ 696 -- 697 [label = 4.5 style = "dashed"];
13
+ 542 -- 543 [label = 4.4 style = "dashed"];
14
+ 723 -- 724 [label = 4.4 style = "dashed"];
15
+ 495 -- 496 [label = 4.4 style = "dashed"];
16
+ 459 -- 460 [label = 4.3 style = "dashed"];
17
+ 784 -- 785 [label = 4.2 style = "dashed"];
18
+ 518 -- 519 [label = 4.2 style = "dashed"];
19
+ 894 -- 895 [label = 4.1 style = "dashed"];
20
+ 435 -- 436 [label = 4.1 style = "dashed"];
21
+ 322 -- 323 [label = 4.1 style = "dashed"];
22
+ 545 -- 546 [label = 4.1 style = "dashed"];
23
+ 513 -- 514 [label = 4.0 style = "dashed"];
24
+ }
data/examples/sample57.rb CHANGED
@@ -2,5 +2,6 @@ $:.unshift( "../lib" )
2
2
 
3
3
  require 'graphviz/graphml'
4
4
 
5
- g = GraphViz::GraphML.new( "graphml/cluster.graphml" )
6
- g.graph.output( :path => "/usr/local/bin", :png => "#{$0}.png" )
5
+ graphml = File.join( File.dirname( File.expand_path( __FILE__ ) ), "graphml", "cluster.graphml" )
6
+ g = GraphViz::GraphML.new( graphml )
7
+ g.graph.output( :png => "#{$0}.png" )
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # By Jonas Elfström - http://github.com/jonelf
4
+ $:.unshift( "../lib" )
5
+ require 'graphviz'
6
+
7
+ @min_level=1
8
+ @max_level=12
9
+ @max_depth=10
10
+ start_level=6
11
+
12
+ @g = GraphViz.new(:G, :type => "strict digraph")
13
+ # or @g = GraphViz.new(:G, :type => "digraph", :strict => true)
14
+ # or @g = GraphViz.digraph(:G, :strict => true)
15
+ # or @g = GraphViz.strict_digraph(:G)
16
+
17
+ def add_node(level, depth, parent)
18
+ if depth<@max_depth
19
+ current=[level, depth].join(",")
20
+
21
+ sub=level<=>@min_level
22
+ add=@max_level<=>level
23
+ add_node(level-sub, depth+1, current)
24
+ add_node(level+add, depth+1, current)
25
+
26
+ @g.add_node(current).label=level.to_s
27
+ @g.add_edge(parent, current) unless parent=="00"
28
+ end
29
+ end
30
+
31
+ add_node(start_level, 0, "00")
32
+
33
+ @g.output( :png => "#{$0}.png" )
data/lib/graphviz.rb CHANGED
@@ -479,7 +479,8 @@ class GraphViz
479
479
 
480
480
  @output = hOutput if hOutput.size > 0
481
481
 
482
- xDOTScript = ("#{@oGraphType} #{GraphViz.escape(@name)} {\n" << xDOTScript).gsub( "\0", "" )
482
+ xStict = ((@strict && @oGraphType == "digraph") ? "strict " : "")
483
+ xDOTScript = ("#{xStict}#{@oGraphType} #{GraphViz.escape(@name)} {\n" << xDOTScript).gsub( "\0", "" )
483
484
 
484
485
  xOutputString = (@filename == String ||
485
486
  @output.any? {|format, file| file == String })
@@ -599,6 +600,13 @@ class GraphViz
599
600
  @oParentGraph
600
601
  end
601
602
 
603
+ #
604
+ # Return the root graph
605
+ #
606
+ def root_graph
607
+ return( (self.pg.nil?) ? self : self.pg.root_graph )
608
+ end
609
+
602
610
  def self.commonGraph( o1, o2 ) #:nodoc:
603
611
  g1 = o1.pg
604
612
  g2 = o2.pg
@@ -685,10 +693,10 @@ class GraphViz
685
693
  #
686
694
  # Options :
687
695
  # * :output : Output format (Constants::FORMATS) (default : dot)
688
- # * :file : Output file name (default : none)
696
+ # * :file : Output file name (default : nil)
689
697
  # * :use : Program to use (Constants::PROGRAMS) (default : dot)
690
698
  # * :path : Program PATH
691
- # * :parent : Parent graph (default : none)
699
+ # * :parent : Parent graph (default : nil)
692
700
  # * :type : Graph type (Constants::GRAPHTYPE) (default : digraph)
693
701
  # * :errors : DOT error level (default 1)
694
702
  # * 0 = Error + Warning
@@ -705,6 +713,7 @@ class GraphViz
705
713
  @extlibs = @@extlibs
706
714
  @output = {}
707
715
  @nothugly = false
716
+ @strict = false
708
717
 
709
718
  @elements_order = GraphViz::Elements::new()
710
719
 
@@ -744,6 +753,8 @@ class GraphViz
744
753
  @oGraphType = xValue.to_s
745
754
  when "path"
746
755
  @path = xValue.split( "," ).map{ |x| x.strip }
756
+ when "strict"
757
+ @strict = (xValue ? true : false)
747
758
  when "errors"
748
759
  @errors = xValue
749
760
  when "extlibs"
@@ -756,13 +767,33 @@ class GraphViz
756
767
  yield( self ) if( block )
757
768
  end
758
769
 
770
+ #
771
+ # Create a new undirected graph
772
+ #
773
+ # See also GraphViz::new
774
+ #
759
775
  def self.graph( xGraphName, hOpts = {}, &block )
760
776
  new( xGraphName, hOpts.symbolize_keys.merge( {:type => "graph"} ), &block )
761
777
  end
778
+
779
+ #
780
+ # Create a new directed graph
781
+ #
782
+ # See also GraphViz::new
783
+ #
762
784
  def self.digraph( xGraphName, hOpts = {}, &block )
763
785
  new( xGraphName, hOpts.symbolize_keys.merge( {:type => "digraph"} ), &block )
764
786
  end
765
787
 
788
+ #
789
+ # Create a new strict directed graph
790
+ #
791
+ # See also GraphViz::new
792
+ #
793
+ def self.strict_digraph( xGraphName, hOpts = {}, &block )
794
+ new( xGraphName, hOpts.symbolize_keys.merge( {:type => "digraph", :strict => true} ), &block )
795
+ end
796
+
766
797
  #
767
798
  # Escape a string to be acceptable as a node name in a graphviz input file
768
799
  #
@@ -40,7 +40,7 @@
40
40
  # C => cluster
41
41
  #
42
42
  module Constants
43
- RGV_VERSION = "0.9.18"
43
+ RGV_VERSION = "0.9.19"
44
44
 
45
45
  ## Const: Output formats
46
46
  FORMATS = [
@@ -103,7 +103,8 @@ module Constants
103
103
  ## Const: graphs type
104
104
  GRAPHTYPE = [
105
105
  "digraph",
106
- "graph"
106
+ "graph",
107
+ "strict digraph"
107
108
  ]
108
109
 
109
110
  def self.getAttrsFor( x )
data/lib/graphviz/edge.rb CHANGED
@@ -35,7 +35,7 @@ class GraphViz
35
35
  # * vNodeTwo : Second node (can be a GraphViz::Node or a node ID)
36
36
  # * oGParrent : Graph
37
37
  #
38
- def initialize( vNodeOne, vNodeTwo, oGParrent = nil )
38
+ def initialize( vNodeOne, vNodeTwo, oGParrent )
39
39
  @xNodeOne, @xNodeOnePort = getNodeNameAndPort( vNodeOne )
40
40
  # if vNodeOne.class == String
41
41
  # @xNodeOne = vNodeOne
@@ -64,7 +64,8 @@ class GraphViz
64
64
  GraphViz.escape(@xNodeOne, true) + ":#{@xNodeOnePort}"
65
65
  end
66
66
  end
67
-
67
+ alias :tail_node :node_one
68
+
68
69
  # Return the node two as string (so with port if any)
69
70
  def node_two( with_port = true )
70
71
  if @xNodeTwoPort.nil? or with_port == false
@@ -73,7 +74,7 @@ class GraphViz
73
74
  GraphViz.escape(@xNodeTwo, true) + ":#{@xNodeTwoPort}"
74
75
  end
75
76
  end
76
-
77
+ alias :head_node :node_two
77
78
  #
78
79
  # Return the index of the edge
79
80
  #
@@ -120,6 +121,17 @@ class GraphViz
120
121
  alias :- :<< #:nodoc:
121
122
  alias :>> :<< #:nodoc:
122
123
 
124
+ #
125
+ # Return the root graph
126
+ #
127
+ def root_graph
128
+ return( (self.pg.nil?) ? nil : self.pg.root_graph )
129
+ end
130
+
131
+ def pg #:nodoc:
132
+ @oGParrent
133
+ end
134
+
123
135
  #
124
136
  # Set edge attributs
125
137
  #
@@ -35,8 +35,9 @@ class GraphViz
35
35
  'undirected' => :graph
36
36
  }
37
37
 
38
- def initialize( xFile )
39
- @xmlDoc = REXML::Document::new( File::new( xFile ) )
38
+ def initialize( file_or_str )
39
+ data = ((File.file?( file_or_str )) ? File::new(file_or_str) : file_or_str)
40
+ @xmlDoc = REXML::Document::new( data )
40
41
  @attributs = {
41
42
  :nodes => {},
42
43
  :edges => {},
data/lib/graphviz/node.rb CHANGED
@@ -31,7 +31,7 @@ class GraphViz
31
31
  # * xNodeName : ID of the node
32
32
  # * oGParrent : Graph
33
33
  #
34
- def initialize( xNodeName, oGParrent = nil )
34
+ def initialize( xNodeName, oGParrent )
35
35
  @xNodeName = xNodeName
36
36
  @oGParrent = oGParrent
37
37
  @oAttrNode = GraphViz::Attrs::new( nil, "node", NODESATTRS )
@@ -54,7 +54,7 @@ class GraphViz
54
54
  end
55
55
 
56
56
  #
57
- # Return the index of the node
57
+ # Return the node index
58
58
  #
59
59
  def index
60
60
  @index
@@ -62,7 +62,14 @@ class GraphViz
62
62
  def index=(i) #:nodoc:
63
63
  @index = i if @index == nil
64
64
  end
65
-
65
+
66
+ #
67
+ # Return the root graph
68
+ #
69
+ def root_graph
70
+ return( (self.pg.nil?) ? nil : self.pg.root_graph )
71
+ end
72
+
66
73
  #
67
74
  # Set value +xAttrValue+ to the node attribut +xAttrName+
68
75
  #
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-graphviz
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 18
10
- version: 0.9.18
9
+ - 19
10
+ version: 0.9.19
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gregoire Lejeune
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-07 00:00:00 +02:00
18
+ date: 2010-11-02 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -58,6 +58,7 @@ files:
58
58
  - examples/dot/siblings.dot
59
59
  - examples/dot/test.dot
60
60
  - examples/dot/test_parse.rb
61
+ - examples/dot/this_crach_with_dot_2.20.dot
61
62
  - examples/dot/unix.dot
62
63
  - examples/graphml/attributes.ext.graphml
63
64
  - examples/graphml/attributes.graphml
@@ -127,6 +128,7 @@ files:
127
128
  - examples/sample55.rb
128
129
  - examples/sample56.rb
129
130
  - examples/sample57.rb
131
+ - examples/sample58.rb
130
132
  - examples/sample99.rb
131
133
  - examples/sdlshapes/README
132
134
  - examples/sdlshapes/sdl.ps
@@ -162,9 +164,6 @@ files:
162
164
  - lib/graphviz/utils.rb
163
165
  - lib/graphviz/xml.rb
164
166
  - lib/graphviz.rb
165
- - lib/src/html_string_parser.gv
166
- - lib/src/html_string_parser.rb
167
- - lib/src/html_string_parser.rl
168
167
  - test/support.rb
169
168
  - test/test_examples.rb
170
169
  - test/test_init.rb
@@ -1,43 +0,0 @@
1
- digraph html_string_lexer {
2
- rankdir=LR;
3
- node [ shape = point ];
4
- ENTRY;
5
- en_22;
6
- node [ shape = circle, height = 0.2 ];
7
- node [ fixedsize = true, height = 0.65, shape = doublecircle ];
8
- 22;
9
- node [ shape = circle ];
10
- 1 -> 2 [ label = "'/'" ];
11
- 1 -> 10 [ label = "'B'" ];
12
- 1 -> 13 [ label = "'F'" ];
13
- 1 -> 18 [ label = "'b'" ];
14
- 1 -> 19 [ label = "'f'" ];
15
- 2 -> 3 [ label = "'F'" ];
16
- 2 -> 7 [ label = "'f'" ];
17
- 3 -> 4 [ label = "'O'" ];
18
- 4 -> 5 [ label = "'N'" ];
19
- 5 -> 6 [ label = "'T'" ];
20
- 6 -> 22 [ label = "'>' / last3, initts" ];
21
- 7 -> 8 [ label = "'o'" ];
22
- 8 -> 9 [ label = "'n'" ];
23
- 9 -> 6 [ label = "'t'" ];
24
- 10 -> 11 [ label = "'R'" ];
25
- 11 -> 12 [ label = "'\\t'..'\\r', SP" ];
26
- 11 -> 22 [ label = "'>' / last1, initts" ];
27
- 12 -> 22 [ label = "'>' / last1, initts" ];
28
- 12 -> 12 [ label = "DEF" ];
29
- 13 -> 14 [ label = "'O'" ];
30
- 14 -> 15 [ label = "'N'" ];
31
- 15 -> 16 [ label = "'T'" ];
32
- 16 -> 17 [ label = "'\\t'..'\\r', SP" ];
33
- 16 -> 22 [ label = "'>' / last2, initts" ];
34
- 17 -> 22 [ label = "'>' / last2, initts" ];
35
- 17 -> 17 [ label = "DEF" ];
36
- 18 -> 11 [ label = "'r'" ];
37
- 19 -> 20 [ label = "'o'" ];
38
- 20 -> 21 [ label = "'n'" ];
39
- 21 -> 16 [ label = "'t'" ];
40
- 22 -> 1 [ label = "'<' / ts" ];
41
- ENTRY -> 22 [ label = "IN" ];
42
- en_22 -> 22 [ label = "main" ];
43
- }
@@ -1,422 +0,0 @@
1
-
2
- # line 1 "html_string_parser.rl"
3
-
4
- # line 20 "html_string_parser.rl"
5
-
6
-
7
-
8
- # line 9 "html_string_parser.rb"
9
- class << self
10
- attr_accessor :_html_string_lexer_actions
11
- private :_html_string_lexer_actions, :_html_string_lexer_actions=
12
- end
13
- self._html_string_lexer_actions = [
14
- 0, 1, 0, 1, 1, 1, 8, 1,
15
- 9, 2, 2, 3, 2, 2, 4, 2,
16
- 2, 5, 2, 2, 6, 2, 2, 7
17
- ]
18
-
19
- class << self
20
- attr_accessor :_html_string_lexer_key_offsets
21
- private :_html_string_lexer_key_offsets, :_html_string_lexer_key_offsets=
22
- end
23
- self._html_string_lexer_key_offsets = [
24
- 0, 1, 1, 6, 8, 9, 10, 11,
25
- 12, 13, 14, 15, 16, 20, 21, 22,
26
- 23, 24, 27, 28, 39, 51, 64, 76,
27
- 88, 100, 112, 113, 114, 115, 116, 117,
28
- 118, 119
29
- ]
30
-
31
- class << self
32
- attr_accessor :_html_string_lexer_trans_keys
33
- private :_html_string_lexer_trans_keys, :_html_string_lexer_trans_keys=
34
- end
35
- self._html_string_lexer_trans_keys = [
36
- 60, 47, 66, 70, 98, 102, 70, 102,
37
- 79, 78, 84, 62, 111, 110, 116, 82,
38
- 32, 62, 9, 13, 62, 79, 78, 84,
39
- 32, 9, 13, 62, 60, 95, 97, 99,
40
- 108, 101, 103, 110, 111, 115, 116, 47,
41
- 60, 95, 97, 99, 108, 101, 103, 110,
42
- 111, 115, 116, 60, 70, 95, 97, 99,
43
- 102, 108, 101, 103, 110, 111, 115, 116,
44
- 60, 79, 95, 97, 99, 108, 101, 103,
45
- 110, 111, 115, 116, 60, 78, 95, 97,
46
- 99, 108, 101, 103, 110, 111, 115, 116,
47
- 60, 84, 95, 97, 99, 108, 101, 103,
48
- 110, 111, 115, 116, 60, 62, 95, 97,
49
- 99, 108, 101, 103, 110, 111, 115, 116,
50
- 111, 110, 116, 62, 114, 111, 110, 116,
51
- 0
52
- ]
53
-
54
- class << self
55
- attr_accessor :_html_string_lexer_single_lengths
56
- private :_html_string_lexer_single_lengths, :_html_string_lexer_single_lengths=
57
- end
58
- self._html_string_lexer_single_lengths = [
59
- 1, 0, 5, 2, 1, 1, 1, 1,
60
- 1, 1, 1, 1, 2, 1, 1, 1,
61
- 1, 1, 1, 5, 6, 7, 6, 6,
62
- 6, 6, 1, 1, 1, 1, 1, 1,
63
- 1, 1
64
- ]
65
-
66
- class << self
67
- attr_accessor :_html_string_lexer_range_lengths
68
- private :_html_string_lexer_range_lengths, :_html_string_lexer_range_lengths=
69
- end
70
- self._html_string_lexer_range_lengths = [
71
- 0, 0, 0, 0, 0, 0, 0, 0,
72
- 0, 0, 0, 0, 1, 0, 0, 0,
73
- 0, 1, 0, 3, 3, 3, 3, 3,
74
- 3, 3, 0, 0, 0, 0, 0, 0,
75
- 0, 0
76
- ]
77
-
78
- class << self
79
- attr_accessor :_html_string_lexer_index_offsets
80
- private :_html_string_lexer_index_offsets, :_html_string_lexer_index_offsets=
81
- end
82
- self._html_string_lexer_index_offsets = [
83
- 0, 2, 3, 9, 12, 14, 16, 18,
84
- 20, 22, 24, 26, 28, 32, 34, 36,
85
- 38, 40, 43, 45, 54, 64, 75, 85,
86
- 95, 105, 115, 117, 119, 121, 123, 125,
87
- 127, 129
88
- ]
89
-
90
- class << self
91
- attr_accessor :_html_string_lexer_indicies
92
- private :_html_string_lexer_indicies, :_html_string_lexer_indicies=
93
- end
94
- self._html_string_lexer_indicies = [
95
- 1, 0, 0, 4, 5, 6, 7, 8,
96
- 0, 9, 10, 0, 11, 0, 12, 0,
97
- 13, 0, 14, 0, 15, 0, 16, 0,
98
- 13, 0, 17, 0, 18, 19, 18, 0,
99
- 19, 18, 20, 0, 21, 0, 22, 0,
100
- 23, 23, 0, 24, 23, 26, 0, 0,
101
- 0, 0, 0, 0, 0, 25, 27, 26,
102
- 0, 0, 0, 0, 0, 0, 0, 25,
103
- 26, 28, 0, 0, 0, 29, 0, 0,
104
- 0, 0, 25, 26, 30, 0, 0, 0,
105
- 0, 0, 0, 0, 25, 26, 31, 0,
106
- 0, 0, 0, 0, 0, 0, 25, 26,
107
- 32, 0, 0, 0, 0, 0, 0, 0,
108
- 25, 26, 33, 0, 0, 0, 0, 0,
109
- 0, 0, 25, 34, 0, 35, 0, 36,
110
- 0, 37, 0, 17, 0, 38, 0, 39,
111
- 0, 22, 0, 0
112
- ]
113
-
114
- class << self
115
- attr_accessor :_html_string_lexer_trans_targs
116
- private :_html_string_lexer_trans_targs, :_html_string_lexer_trans_targs=
117
- end
118
- self._html_string_lexer_trans_targs = [
119
- 1, 2, 0, 0, 3, 11, 14, 30,
120
- 31, 4, 8, 5, 6, 7, 1, 9,
121
- 10, 12, 13, 1, 15, 16, 17, 18,
122
- 19, 19, 20, 21, 22, 26, 23, 24,
123
- 25, 19, 27, 28, 29, 1, 32, 33
124
- ]
125
-
126
- class << self
127
- attr_accessor :_html_string_lexer_trans_actions
128
- private :_html_string_lexer_trans_actions, :_html_string_lexer_trans_actions=
129
- end
130
- self._html_string_lexer_trans_actions = [
131
- 21, 0, 7, 5, 0, 0, 0, 0,
132
- 0, 0, 0, 0, 0, 0, 18, 0,
133
- 0, 0, 0, 9, 0, 0, 0, 0,
134
- 15, 21, 0, 0, 0, 0, 0, 0,
135
- 0, 12, 0, 0, 0, 12, 0, 0
136
- ]
137
-
138
- class << self
139
- attr_accessor :_html_string_lexer_to_state_actions
140
- private :_html_string_lexer_to_state_actions, :_html_string_lexer_to_state_actions=
141
- end
142
- self._html_string_lexer_to_state_actions = [
143
- 1, 0, 0, 0, 0, 0, 0, 0,
144
- 0, 0, 0, 0, 0, 0, 0, 0,
145
- 0, 0, 0, 0, 0, 0, 0, 0,
146
- 0, 0, 0, 0, 0, 0, 0, 0,
147
- 0, 0
148
- ]
149
-
150
- class << self
151
- attr_accessor :_html_string_lexer_from_state_actions
152
- private :_html_string_lexer_from_state_actions, :_html_string_lexer_from_state_actions=
153
- end
154
- self._html_string_lexer_from_state_actions = [
155
- 3, 0, 0, 0, 0, 0, 0, 0,
156
- 0, 0, 0, 0, 0, 0, 0, 0,
157
- 0, 0, 0, 0, 0, 0, 0, 0,
158
- 0, 0, 0, 0, 0, 0, 0, 0,
159
- 0, 0
160
- ]
161
-
162
- class << self
163
- attr_accessor :_html_string_lexer_eof_trans
164
- private :_html_string_lexer_eof_trans, :_html_string_lexer_eof_trans=
165
- end
166
- self._html_string_lexer_eof_trans = [
167
- 0, 3, 4, 4, 4, 4, 4, 4,
168
- 4, 4, 4, 4, 4, 4, 4, 4,
169
- 4, 4, 4, 3, 4, 4, 4, 4,
170
- 4, 4, 4, 4, 4, 4, 4, 4,
171
- 4, 4
172
- ]
173
-
174
- class << self
175
- attr_accessor :html_string_lexer_start
176
- end
177
- self.html_string_lexer_start = 0;
178
- class << self
179
- attr_accessor :html_string_lexer_first_final
180
- end
181
- self.html_string_lexer_first_final = 0;
182
- class << self
183
- attr_accessor :html_string_lexer_error
184
- end
185
- self.html_string_lexer_error = -1;
186
-
187
- class << self
188
- attr_accessor :html_string_lexer_en_main
189
- end
190
- self.html_string_lexer_en_main = 0;
191
-
192
-
193
- # line 23 "html_string_parser.rl"
194
-
195
- # ---------- %
196
-
197
- def test( data )
198
- puts "Check : #{data}"
199
- data = data.unpack("c*") if(data.is_a?(String))
200
- eof = data.length
201
-
202
-
203
- # line 204 "html_string_parser.rb"
204
- begin
205
- p ||= 0
206
- pe ||= data.length
207
- cs = html_string_lexer_start
208
- ts = nil
209
- te = nil
210
- act = 0
211
- end
212
-
213
- # line 32 "html_string_parser.rl"
214
-
215
- # line 216 "html_string_parser.rb"
216
- begin
217
- _klen, _trans, _keys, _acts, _nacts = nil
218
- _goto_level = 0
219
- _resume = 10
220
- _eof_trans = 15
221
- _again = 20
222
- _test_eof = 30
223
- _out = 40
224
- while true
225
- _trigger_goto = false
226
- if _goto_level <= 0
227
- if p == pe
228
- _goto_level = _test_eof
229
- next
230
- end
231
- end
232
- if _goto_level <= _resume
233
- _acts = _html_string_lexer_from_state_actions[cs]
234
- _nacts = _html_string_lexer_actions[_acts]
235
- _acts += 1
236
- while _nacts > 0
237
- _nacts -= 1
238
- _acts += 1
239
- case _html_string_lexer_actions[_acts - 1]
240
- when 1 then
241
- # line 1 "NONE"
242
- begin
243
- ts = p
244
- end
245
- # line 246 "html_string_parser.rb"
246
- end # from state action switch
247
- end
248
- if _trigger_goto
249
- next
250
- end
251
- _keys = _html_string_lexer_key_offsets[cs]
252
- _trans = _html_string_lexer_index_offsets[cs]
253
- _klen = _html_string_lexer_single_lengths[cs]
254
- _break_match = false
255
-
256
- begin
257
- if _klen > 0
258
- _lower = _keys
259
- _upper = _keys + _klen - 1
260
-
261
- loop do
262
- break if _upper < _lower
263
- _mid = _lower + ( (_upper - _lower) >> 1 )
264
-
265
- if data[p] < _html_string_lexer_trans_keys[_mid]
266
- _upper = _mid - 1
267
- elsif data[p] > _html_string_lexer_trans_keys[_mid]
268
- _lower = _mid + 1
269
- else
270
- _trans += (_mid - _keys)
271
- _break_match = true
272
- break
273
- end
274
- end # loop
275
- break if _break_match
276
- _keys += _klen
277
- _trans += _klen
278
- end
279
- _klen = _html_string_lexer_range_lengths[cs]
280
- if _klen > 0
281
- _lower = _keys
282
- _upper = _keys + (_klen << 1) - 2
283
- loop do
284
- break if _upper < _lower
285
- _mid = _lower + (((_upper-_lower) >> 1) & ~1)
286
- if data[p] < _html_string_lexer_trans_keys[_mid]
287
- _upper = _mid - 2
288
- elsif data[p] > _html_string_lexer_trans_keys[_mid+1]
289
- _lower = _mid + 2
290
- else
291
- _trans += ((_mid - _keys) >> 1)
292
- _break_match = true
293
- break
294
- end
295
- end # loop
296
- break if _break_match
297
- _trans += _klen
298
- end
299
- end while false
300
- _trans = _html_string_lexer_indicies[_trans]
301
- end
302
- if _goto_level <= _eof_trans
303
- cs = _html_string_lexer_trans_targs[_trans]
304
- if _html_string_lexer_trans_actions[_trans] != 0
305
- _acts = _html_string_lexer_trans_actions[_trans]
306
- _nacts = _html_string_lexer_actions[_acts]
307
- _acts += 1
308
- while _nacts > 0
309
- _nacts -= 1
310
- _acts += 1
311
- case _html_string_lexer_actions[_acts - 1]
312
- when 2 then
313
- # line 1 "NONE"
314
- begin
315
- te = p+1
316
- end
317
- when 3 then
318
- # line 12 "html_string_parser.rl"
319
- begin
320
- act = 1; end
321
- when 4 then
322
- # line 13 "html_string_parser.rl"
323
- begin
324
- act = 2; end
325
- when 5 then
326
- # line 14 "html_string_parser.rl"
327
- begin
328
- act = 3; end
329
- when 6 then
330
- # line 15 "html_string_parser.rl"
331
- begin
332
- act = 4; end
333
- when 7 then
334
- # line 16 "html_string_parser.rl"
335
- begin
336
- act = 5; end
337
- when 8 then
338
- # line 16 "html_string_parser.rl"
339
- begin
340
- te = p
341
- p = p - 1; begin puts "\t =>string" end
342
- end
343
- when 9 then
344
- # line 1 "NONE"
345
- begin
346
- case act
347
- when 1 then
348
- begin begin p = ((te))-1; end
349
- puts "\t =><BR>" end
350
- when 2 then
351
- begin begin p = ((te))-1; end
352
- puts "\t =><FONT>...</FONT>"end
353
- when 3 then
354
- begin begin p = ((te))-1; end
355
- puts "\t =><FONT>"end
356
- when 4 then
357
- begin begin p = ((te))-1; end
358
- puts "\t =></FONT>"end
359
- when 5 then
360
- begin begin p = ((te))-1; end
361
- puts "\t =>string" end
362
- end
363
- end
364
- # line 365 "html_string_parser.rb"
365
- end # action switch
366
- end
367
- end
368
- if _trigger_goto
369
- next
370
- end
371
- end
372
- if _goto_level <= _again
373
- _acts = _html_string_lexer_to_state_actions[cs]
374
- _nacts = _html_string_lexer_actions[_acts]
375
- _acts += 1
376
- while _nacts > 0
377
- _nacts -= 1
378
- _acts += 1
379
- case _html_string_lexer_actions[_acts - 1]
380
- when 0 then
381
- # line 1 "NONE"
382
- begin
383
- ts = nil; end
384
- # line 385 "html_string_parser.rb"
385
- end # to state action switch
386
- end
387
- if _trigger_goto
388
- next
389
- end
390
- p += 1
391
- if p != pe
392
- _goto_level = _resume
393
- next
394
- end
395
- end
396
- if _goto_level <= _test_eof
397
- if p == eof
398
- if _html_string_lexer_eof_trans[cs] > 0
399
- _trans = _html_string_lexer_eof_trans[cs] - 1;
400
- _goto_level = _eof_trans
401
- next;
402
- end
403
- end
404
- end
405
- if _goto_level <= _out
406
- break
407
- end
408
- end
409
- end
410
-
411
- # line 33 "html_string_parser.rl"
412
- end
413
-
414
- # ----------
415
-
416
- test "<BRRR ALIGN=\"LEFT\">"
417
- test "<BR ALIGN=\"LEFT\">"
418
- test "\\<BR ALIGN=\"LEFT\"\\>"
419
- test "simple test"
420
- test "<FONT COLOR=\"blue\">"
421
- test "</FONT>"
422
- test "<font>simple test</font>"
@@ -1,43 +0,0 @@
1
- %%{
2
-
3
- machine html_string_lexer;
4
-
5
- br_tag = '<'('br'|'BR')(space{1,}[^>]*)*'>';
6
- font_open_tag = '<'('font'|'FONT')(space{1,}[^>]*)'>';
7
- font_close_tag = '</font>'|'</FONT>';
8
- font_tag = font_open_tag [^font_close_tag]* font_close_tag;
9
- string = any*;
10
-
11
- main := |*
12
- br_tag => { puts "\t =><BR>" };
13
- font_tag => { puts "\t =><FONT>...</FONT>"};
14
- font_open_tag => { puts "\t =><FONT>"};
15
- font_close_tag => { puts "\t =></FONT>"};
16
- string => { puts "\t =>string" };
17
- space;
18
- *|;
19
-
20
- }%%
21
-
22
- %% write data;
23
-
24
- # ---------- %
25
-
26
- def test( data )
27
- puts "Check : #{data}"
28
- data = data.unpack("c*") if(data.is_a?(String))
29
- eof = data.length
30
-
31
- %% write init;
32
- %% write exec;
33
- end
34
-
35
- # ----------
36
-
37
- test "<BRRR ALIGN=\"LEFT\">"
38
- test "<BR ALIGN=\"LEFT\">"
39
- test "\\<BR ALIGN=\"LEFT\"\\>"
40
- test "simple test"
41
- test "<FONT COLOR=\"blue\">"
42
- test "</FONT>"
43
- test "<font>simple test</font>"