kwartz 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. data/ChangeLog +36 -1
  2. data/LGPL +504 -0
  3. data/README.txt +16 -2
  4. data/bin/kwartz +1 -1
  5. data/doc-api/classes/Kwartz.html +47 -1
  6. data/doc-api/classes/Kwartz/Assertion.html +6 -6
  7. data/doc-api/classes/Kwartz/AssertionError.html +6 -6
  8. data/doc-api/classes/Kwartz/AttrInfo.html +42 -42
  9. data/doc-api/classes/Kwartz/BaseError.html +12 -12
  10. data/doc-api/classes/Kwartz/BaseTranslator.html +210 -43
  11. data/doc-api/classes/Kwartz/CharacterType.html +24 -24
  12. data/doc-api/classes/Kwartz/CommandOptionError.html +7 -7
  13. data/doc-api/classes/Kwartz/CommandOptions.html +49 -49
  14. data/doc-api/classes/Kwartz/Config.html +6 -1
  15. data/doc-api/classes/Kwartz/ConvertError.html +14 -14
  16. data/doc-api/classes/Kwartz/Converter.html +31 -30
  17. data/doc-api/classes/Kwartz/CssStyleParser.html +79 -57
  18. data/doc-api/classes/Kwartz/Defun.html +313 -0
  19. data/doc-api/classes/Kwartz/DocumentRuleset.html +58 -58
  20. data/doc-api/classes/Kwartz/ElementExpander.html +32 -32
  21. data/doc-api/classes/Kwartz/ElementInfo.html +29 -29
  22. data/doc-api/classes/Kwartz/ElementRuleset.html +126 -96
  23. data/doc-api/classes/Kwartz/EperlHandler.html +108 -84
  24. data/doc-api/classes/Kwartz/EperlTranslator.html +7 -7
  25. data/doc-api/classes/Kwartz/ErubisHandler.html +2 -2
  26. data/doc-api/classes/Kwartz/ErubisTranslator.html +8 -8
  27. data/doc-api/classes/Kwartz/ErubyHandler.html +2 -220
  28. data/doc-api/classes/Kwartz/ErubyTranslator.html +7 -7
  29. data/doc-api/classes/Kwartz/ExpandStatement.html +20 -20
  30. data/doc-api/classes/Kwartz/Handler.html +122 -117
  31. data/doc-api/classes/Kwartz/HandlerArgument.html +215 -0
  32. data/doc-api/classes/Kwartz/Helper.html +112 -0
  33. data/doc-api/classes/Kwartz/Helper/ActionViewHelper.html +221 -0
  34. data/doc-api/classes/Kwartz/Helper/RailsTemplate.html +630 -0
  35. data/doc-api/classes/Kwartz/JstlHandler.html +208 -193
  36. data/doc-api/classes/Kwartz/JstlTranslator.html +15 -15
  37. data/doc-api/classes/Kwartz/KwartzError.html +6 -6
  38. data/doc-api/classes/Kwartz/Main.html +39 -23
  39. data/doc-api/classes/Kwartz/NativeExpression.html +18 -18
  40. data/doc-api/classes/Kwartz/NativeStatement.html +25 -25
  41. data/doc-api/classes/Kwartz/Node.html +6 -6
  42. data/doc-api/classes/Kwartz/PIErubisHandler.html +113 -0
  43. data/doc-api/classes/Kwartz/PIErubisTranslator.html +200 -0
  44. data/doc-api/classes/Kwartz/ParseError.html +6 -6
  45. data/doc-api/classes/Kwartz/PhpHandler.html +102 -83
  46. data/doc-api/classes/Kwartz/PhpTranslator.html +14 -14
  47. data/doc-api/classes/Kwartz/PresentationLogicParser.html +136 -128
  48. data/doc-api/classes/Kwartz/PrintStatement.html +19 -19
  49. data/doc-api/classes/Kwartz/RailsHandler.html +121 -118
  50. data/doc-api/classes/Kwartz/RailsTranslator.html +7 -7
  51. data/doc-api/classes/Kwartz/RubyHandler.html +349 -0
  52. data/doc-api/classes/Kwartz/RubyStyleParser.html +85 -85
  53. data/doc-api/classes/Kwartz/RubyTranslator.html +218 -0
  54. data/doc-api/classes/Kwartz/StatementHelper.html +479 -0
  55. data/doc-api/classes/Kwartz/StrutsTranslator.html +12 -12
  56. data/doc-api/classes/Kwartz/TagInfo.html +28 -28
  57. data/doc-api/classes/Kwartz/TextConverter.html +28 -28
  58. data/doc-api/classes/Kwartz/Translator.html +42 -42
  59. data/doc-api/classes/Kwartz/Util.html +284 -0
  60. data/doc-api/created.rid +1 -1
  61. data/doc-api/files/__/README_txt.html +30 -3
  62. data/doc-api/files/kwartz/assert_rb.html +1 -1
  63. data/doc-api/files/kwartz/binding/eperl_rb.html +2 -2
  64. data/doc-api/files/kwartz/binding/erubis_rb.html +3 -3
  65. data/doc-api/files/kwartz/binding/eruby_rb.html +3 -2
  66. data/doc-api/files/kwartz/binding/jstl_rb.html +2 -2
  67. data/doc-api/files/kwartz/binding/php_rb.html +2 -2
  68. data/doc-api/files/kwartz/binding/pierubis_rb.html +116 -0
  69. data/doc-api/files/kwartz/binding/rails_rb.html +2 -2
  70. data/doc-api/files/kwartz/binding/ruby_rb.html +115 -0
  71. data/doc-api/files/kwartz/binding/struts_rb.html +1 -1
  72. data/doc-api/files/kwartz/config_rb.html +2 -2
  73. data/doc-api/files/kwartz/converter_rb.html +3 -2
  74. data/doc-api/files/kwartz/defun_rb.html +116 -0
  75. data/doc-api/files/kwartz/error_rb.html +1 -1
  76. data/doc-api/files/kwartz/helper/rails_rb.html +123 -0
  77. data/doc-api/files/kwartz/main_rb.html +5 -2
  78. data/doc-api/files/kwartz/node_rb.html +2 -2
  79. data/doc-api/files/kwartz/parser_rb.html +2 -2
  80. data/doc-api/files/kwartz/translator_rb.html +2 -2
  81. data/doc-api/files/kwartz/util/assert-text-equal_rb.html +1 -1
  82. data/doc-api/files/kwartz/util/testcase-helper_rb.html +2 -2
  83. data/doc-api/files/kwartz/util_rb.html +107 -0
  84. data/doc-api/files/kwartz_rb.html +3 -2
  85. data/doc-api/fr_class_index.html +11 -0
  86. data/doc-api/fr_file_index.html +5 -0
  87. data/doc-api/fr_method_index.html +242 -190
  88. data/doc/p-pattern.html +94 -94
  89. data/doc/reference.html +847 -612
  90. data/doc/users-guide.html +744 -241
  91. data/examples/rails1/README +2 -2
  92. data/examples/rails1/application_helper.rb +2 -27
  93. data/examples/rails1/link_to.plogic +5 -5
  94. data/examples/rails1/list.plogic +2 -2
  95. data/examples/rails2/app/controllers/application.rb +14 -0
  96. data/examples/rails2/app/controllers/groups_controller.rb +47 -0
  97. data/examples/rails2/app/controllers/members_controller.rb +56 -0
  98. data/examples/rails2/app/helpers/application_helper.rb +6 -0
  99. data/examples/rails2/app/helpers/groups_helper.rb +2 -0
  100. data/examples/rails2/app/helpers/members_helper.rb +2 -0
  101. data/examples/rails2/app/models/group.rb +2 -0
  102. data/examples/rails2/app/models/member.rb +3 -0
  103. data/examples/rails2/app/views/groups/_form.html +30 -0
  104. data/examples/rails2/app/views/groups/_form.plogic +11 -0
  105. data/examples/rails2/app/views/groups/_link.plogic +19 -0
  106. data/examples/rails2/app/views/groups/_read.plogic +7 -0
  107. data/examples/rails2/app/views/groups/edit.cfg.yaml +2 -0
  108. data/examples/rails2/app/views/groups/edit.html +26 -0
  109. data/examples/rails2/app/views/groups/edit.plogic +9 -0
  110. data/examples/rails2/app/views/groups/list.html +48 -0
  111. data/examples/rails2/app/views/groups/list.plogic +32 -0
  112. data/examples/rails2/app/views/groups/new.cfg.yaml +2 -0
  113. data/examples/rails2/app/views/groups/new.html +27 -0
  114. data/examples/rails2/app/views/groups/new.plogic +9 -0
  115. data/examples/rails2/app/views/groups/show.html +27 -0
  116. data/examples/rails2/app/views/groups/show.plogic +2 -0
  117. data/examples/rails2/app/views/layouts/groups.html +23 -0
  118. data/examples/rails2/app/views/layouts/groups.plogic +11 -0
  119. data/examples/rails2/app/views/layouts/members.html +23 -0
  120. data/examples/rails2/app/views/layouts/members.plogic +11 -0
  121. data/examples/rails2/app/views/layouts/members2.html +24 -0
  122. data/examples/rails2/app/views/layouts/members2.plogic +11 -0
  123. data/examples/rails2/app/views/members/_form.plogic +27 -0
  124. data/examples/rails2/app/views/members/_link.plogic +19 -0
  125. data/examples/rails2/app/views/members/_read.plogic +29 -0
  126. data/examples/rails2/app/views/members/edit.cfg.yaml +6 -0
  127. data/examples/rails2/app/views/members/edit.html +27 -0
  128. data/examples/rails2/app/views/members/edit.plogic +10 -0
  129. data/examples/rails2/app/views/members/list.html +53 -0
  130. data/examples/rails2/app/views/members/list.plogic +32 -0
  131. data/examples/rails2/app/views/members/new.html +61 -0
  132. data/examples/rails2/app/views/members/new.plogic +17 -0
  133. data/examples/rails2/app/views/members/show.html +41 -0
  134. data/examples/rails2/app/views/members/show.plogic +3 -0
  135. data/examples/rails2/db/create-tables.mysql.sql +27 -0
  136. data/examples/rails2/db/create-tables.pgsql.sql +27 -0
  137. data/examples/rails2/db/insert-data.sql +21 -0
  138. data/examples/rails2/db/tabledef.yaml +51 -0
  139. data/kwartz.gemspec +4 -4
  140. data/lib/kwartz.rb +10 -2
  141. data/lib/kwartz/assert.rb +1 -1
  142. data/lib/kwartz/binding/eperl.rb +85 -61
  143. data/lib/kwartz/binding/erubis.rb +6 -8
  144. data/lib/kwartz/binding/eruby.rb +5 -120
  145. data/lib/kwartz/binding/jstl.rb +116 -101
  146. data/lib/kwartz/binding/php.rb +79 -60
  147. data/lib/kwartz/binding/pierubis.rb +58 -0
  148. data/lib/kwartz/binding/rails.rb +45 -42
  149. data/lib/kwartz/binding/ruby.rb +193 -0
  150. data/lib/kwartz/binding/struts.rb +1 -1
  151. data/lib/kwartz/config.rb +4 -3
  152. data/lib/kwartz/converter.rb +231 -68
  153. data/lib/kwartz/defun.rb +126 -0
  154. data/lib/kwartz/error.rb +1 -1
  155. data/lib/kwartz/helper/rails.rb +437 -0
  156. data/lib/kwartz/main.rb +30 -38
  157. data/lib/kwartz/node.rb +46 -31
  158. data/lib/kwartz/parser.rb +43 -15
  159. data/lib/kwartz/translator.rb +104 -6
  160. data/lib/kwartz/util.rb +113 -0
  161. data/lib/kwartz/util/assert-text-equal.rb +1 -1
  162. data/lib/kwartz/util/testcase-helper.rb +26 -8
  163. data/test/test-compile.rb +3 -3
  164. data/test/test-compile.yaml +135 -5
  165. data/test/test-converter.rb +16 -8
  166. data/test/test-converter.yaml +307 -76
  167. data/test/test-directives.rb +1 -1
  168. data/test/test-directives.yaml +964 -979
  169. data/test/test-main.rb +61 -146
  170. data/test/test-main.yaml +235 -0
  171. data/test/test-parser.rb +10 -12
  172. data/test/test-parser.yaml +484 -326
  173. data/test/test-rails.rb +1 -1
  174. data/test/test-rails.yaml +37 -37
  175. data/test/test-ruleset.rb +1 -1
  176. data/test/test-ruleset.yaml +34 -40
  177. data/test/test.rb +1 -1
  178. metadata +82 -3
  179. data/COPYING +0 -340
@@ -1,6 +1,6 @@
1
1
  ###
2
- ### $Rev: 117 $
3
- ### $Release: 3.0.0 $
2
+ ### $Rev: 122 $
3
+ ### $Release: 3.1.0 $
4
4
  ### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -11,7 +11,7 @@ class ParserTest < Test::Unit::TestCase
11
11
 
12
12
  ## define test methods
13
13
  filename = __FILE__.sub(/\.rb$/, '.yaml')
14
- load_yaml_testdata(filename)
14
+ load_yaml_testdata(filename, :lang=>'ruby')
15
15
 
16
16
  def _test
17
17
  begin
@@ -23,29 +23,27 @@ class ParserTest < Test::Unit::TestCase
23
23
  end
24
24
 
25
25
  def __test
26
- case @parser
27
- when 'RubyStyleParser'
26
+ case @style
27
+ when 'ruby'
28
28
  parser = Kwartz::RubyStyleParser.new()
29
- when 'CssStyleParser'
29
+ when 'css'
30
30
  parser = Kwartz::CssStyleParser.new()
31
31
  else
32
- raise "*** invalid parser class: #{@parser}"
32
+ raise "*** invalid parser style: #{@style}"
33
33
  end
34
34
  if @name =~ /scan/
35
35
  actual = ''
36
- parser.__send__ :reset, @input
36
+ parser.__send__ :reset, @plogic
37
37
  while (ret = parser.scan()) != nil
38
38
  actual << "#{parser.linenum}:#{parser.column}:"
39
39
  actual << " token=#{parser.token.inspect}, value=#{parser.value.inspect}\n"
40
40
  break if ret == :error
41
41
  end
42
42
  else
43
- rulesets = parser.parse(@input)
43
+ rulesets = parser.parse(@plogic)
44
44
  actual = ''
45
45
  rulesets.each do |ruleset|
46
- s = ruleset._inspect(1)
47
- s[0] = '-'
48
- actual << s
46
+ actual << ruleset._inspect()
49
47
  end if rulesets
50
48
  end
51
49
  assert_text_equal(@expected, actual)
@@ -1,394 +1,552 @@
1
- ---
1
+ ## $Rev: 132 $
2
+ ## $Release: 3.1.0 $
3
+ ## copyright(c) 2004-2006 kuwata-lab.com all rights reserved
4
+
5
+ ###
2
6
  - name: scanner1_css
3
- parser: CssStyleParser
4
- input: |
5
- /* comment */
6
- #list {
7
- value
8
- attrs
9
- append
10
- logic {
11
- }
12
- }
13
- expected: |
14
- 2:2: token=35, value="#"
15
- 2:6: token=:ident, value="list"
16
- 2:8: token=:"{", value="{"
17
- 3:8: token=:value, value="value"
18
- 4:8: token=:attrs, value="attrs"
19
- 5:9: token=:append, value="append"
20
- 6:8: token=:logic, value="logic"
21
- 6:10: token=:"{", value="{"
22
- 7:4: token=:"}", value="}"
23
- 8:2: token=:"}", value="}"
7
+ style: css
8
+ plogic: |
9
+ /* comment */
10
+ #list {
11
+ value
12
+ attrs
13
+ append
14
+ logic {
15
+ }
16
+ }
17
+ expected*:
18
+ ruby: |
19
+ 2:2: token=35, value="#"
20
+ 2:6: token=:ident, value="list"
21
+ 2:8: token=:"{", value="{"
22
+ 3:8: token=:value, value="value"
23
+ 4:8: token=:attrs, value="attrs"
24
+ 5:9: token=:append, value="append"
25
+ 6:8: token=:logic, value="logic"
26
+ 6:10: token=:"{", value="{"
27
+ 7:4: token=:"}", value="}"
28
+ 8:2: token=:"}", value="}"
29
+ php: |
30
+ 2:2: token=#, value="#"
31
+ 2:6: token=:ident, value="list"
32
+ 2:8: token={, value="{"
33
+ 3:8: token=value, value="value"
34
+ 4:8: token=attrs, value="attrs"
35
+ 5:9: token=append, value="append"
36
+ 6:8: token=logic, value="logic"
37
+ 6:10: token={, value="{"
38
+ 7:4: token=}, value="}"
39
+ 8:2: token=}, value="}"
24
40
 
25
41
  - name: scanner1_ruby
26
- parser: RubyStyleParser
27
- input: |
28
- # comment
29
- element "list" {
30
- value
31
- attrs
32
- append
33
- logic {
34
- }
35
- }
42
+ style: ruby
43
+ plogic: |
44
+ # comment
45
+ element "list" {
46
+ value
47
+ attrs
48
+ append
49
+ logic {
50
+ }
51
+ }
36
52
  expected: |
37
- 2:8: token=:element, value="element"
38
- 2:15: token=:string, value="list"
39
- 2:17: token=:"{", value="{"
40
- 3:8: token=:value, value="value"
41
- 4:8: token=:attrs, value="attrs"
42
- 5:9: token=:append, value="append"
43
- 6:8: token=:logic, value="logic"
44
- 6:10: token=:"{", value="{"
45
- 7:4: token=:"}", value="}"
46
- 8:2: token=:"}", value="}"
53
+ 2:8: token=:element, value="element"
54
+ 2:15: token=:string, value="list"
55
+ 2:17: token=:"{", value="{"
56
+ 3:8: token=:value, value="value"
57
+ 4:8: token=:attrs, value="attrs"
58
+ 5:9: token=:append, value="append"
59
+ 6:8: token=:logic, value="logic"
60
+ 6:10: token=:"{", value="{"
61
+ 7:4: token=:"}", value="}"
62
+ 8:2: token=:"}", value="}"
47
63
 
48
- ---
64
+ ###
49
65
  - name: parse_elem1_css
50
- parser: CssStyleParser
51
- input: |
52
- #list {
53
- }
66
+ style: css
67
+ plogic: |
68
+ #list {
69
+ }
54
70
  expected: &elem1|
55
- - name: "list"
71
+ - name: list
56
72
 
57
73
  - name: parse_elem1_ruby
58
- parser: RubyStyleParser
59
- input: |
60
- element "list" {
61
- }
74
+ style: ruby
75
+ plogic: |
76
+ element "list" {
77
+ }
62
78
  expected: *elem1
63
79
 
64
- ---
80
+ ###
65
81
  - name: parse_value_part1_css
66
- parser: CssStyleParser
82
+ style: css
67
83
  desc: value part
68
- input: |
69
- #list {
70
- value: @user['name'];
71
- }
84
+ plogic: |
85
+ #list {
86
+ value: @user['name'];
87
+ }
72
88
  expected: &value1|
73
- - name: "list"
74
- cont: "@user['name']"
89
+ - name: list
90
+ cont: @user['name']
75
91
 
76
92
  - name: parse_value_part1_ruby
77
- parser: RubyStyleParser
93
+ style: ruby
78
94
  desc: value part
79
- input: |
80
- element "list" {
81
- value @user['name']
82
- }
95
+ plogic: |
96
+ element "list" {
97
+ value @user['name']
98
+ }
83
99
  expected: *value1
84
100
 
85
- ---
101
+ ###
86
102
  - name: parse_attrs_part1_css
87
- parser: CssStyleParser
88
- input: |
89
- #list {
90
- attrs: "class" @class,
91
- 'color' @prop[:color];
92
- }
103
+ style: css
104
+ plogic: |
105
+ #list {
106
+ attrs: "class" @class,
107
+ 'color' @prop[:color];
108
+ }
93
109
  expected: &attrs1|
94
- - name: "list"
95
- attrs:
96
- - name: "class"
97
- value: "@class"
98
- - name: "color"
99
- value: "@prop[:color]"
110
+ - name: list
111
+ attrs:
112
+ - name: class
113
+ value: @class
114
+ - name: color
115
+ value: @prop[:color]
100
116
 
101
117
  - name: parse_attrs_part1_ruby
102
- parser: RubyStyleParser
103
- input: |
104
- element "list" {
105
- attrs "class"=>@class, 'color' => @prop[:color]
106
- }
118
+ style: ruby
119
+ plogic: |
120
+ element "list" {
121
+ attrs "class"=>@class, 'color' => @prop[:color]
122
+ }
107
123
  expected: *attrs1
108
124
 
109
- ---
125
+ ###
110
126
  - name: parse_append_part1_css
111
- parser: CssStyleParser
112
- input: |
113
- #list1 {
114
- append: @name==item['name'] ? " checked='checked'" : '',
115
- chk(@name);
116
- }
117
- #list2 {
118
- append: aaa, bbb,ccc;
119
- }
127
+ style: css
128
+ plogic: |
129
+ #list1 {
130
+ append: @name==item['name'] ? " checked='checked'" : '',
131
+ chk(@name);
132
+ }
133
+ #list2 {
134
+ append: aaa, bbb,ccc;
135
+ }
120
136
  expected: &append1|
121
- - name: "list1"
122
- append:
123
- - "@name==item['name'] ? \" checked='checked'\" : ''"
124
- - "chk(@name)"
125
- - name: "list2"
126
- append:
127
- - "aaa, bbb,ccc"
137
+ - name: list1
138
+ append:
139
+ - @name==item['name'] ? " checked='checked'" : ''
140
+ - chk(@name)
141
+ - name: list2
142
+ append:
143
+ - aaa, bbb,ccc
128
144
 
129
145
  - name: parse_append_part1_ruby
130
- parser: RubyStyleParser
131
- input: |
132
- element "list1" {
133
- append @name==item['name'] ? " checked='checked'" : '', chk(@name)
134
- }
135
- element "list2" {
136
- append aaa, bbb,ccc
137
- }
146
+ style: ruby
147
+ plogic: |
148
+ element "list1" {
149
+ append @name==item['name'] ? " checked='checked'" : '', chk(@name)
150
+ }
151
+ element "list2" {
152
+ append aaa, bbb,ccc
153
+ }
138
154
  expected: |
139
- - name: "list1"
140
- append:
141
- - "@name==item['name'] ? \" checked='checked'\" : ''"
142
- - "chk(@name)"
143
- - name: "list2"
144
- append:
145
- - "aaa"
146
- - "bbb,ccc"
155
+ - name: list1
156
+ append:
157
+ - @name==item['name'] ? " checked='checked'" : ''
158
+ - chk(@name)
159
+ - name: list2
160
+ append:
161
+ - aaa
162
+ - bbb,ccc
147
163
 
148
- ---
164
+ ###
149
165
  - name: parse_remove_part1_css
150
- parser: CssStyleParser
151
- input: |
152
- #list {
153
- remove: "foo", "bar", 'baz';
154
- }
166
+ style: css
167
+ plogic: |
168
+ #list {
169
+ remove: "foo", "bar", 'baz';
170
+ }
155
171
  expected: &remove1|
156
- - name: "list"
157
- remove:
158
- - "foo"
159
- - "bar"
160
- - "baz"
172
+ - name: list
173
+ remove:
174
+ - foo
175
+ - bar
176
+ - baz
161
177
 
162
178
  - name: parse_remove_part1_ruby
163
- parser: RubyStyleParser
164
- input: |
165
- element "list" {
166
- remove "foo", "bar", 'baz'
167
- }
179
+ style: ruby
180
+ plogic: |
181
+ element "list" {
182
+ remove "foo", "bar", 'baz'
183
+ }
168
184
  expected: *remove1
169
185
 
170
- ---
186
+ ###
171
187
  - name: parse_tagname_part1_css
172
- parser: CssStyleParser
173
- input: |
174
- #list {
175
- tagname: 'html:html';
176
- }
188
+ style: css
189
+ plogic: |
190
+ #list {
191
+ tagname: 'html:html';
192
+ }
177
193
  expected: &tagname1|
178
- - name: "list"
179
- tagname: "html:html"
194
+ - name: list
195
+ tagname: html:html
180
196
 
181
197
  - name: parse_tagname_part1_ruby
182
- parser: RubyStyleParser
183
- input: |
184
- element "list" {
185
- tagname 'html:html'
186
- }
198
+ style: ruby
199
+ plogic: |
200
+ element "list" {
201
+ tagname 'html:html'
202
+ }
187
203
  expected: *tagname1
188
204
 
189
- ---
205
+ ###
190
206
  - name: parse_logic_part1_css
191
- parser: CssStyleParser
192
- input: |
193
- #list {
194
- logic: {
195
- @list.each { |item|
196
- _stag
197
- _cont
198
- _etag
199
- }
200
- }
201
- }
207
+ style: css
208
+ plogic: |
209
+ #list {
210
+ logic: {
211
+ @list.each { |item|
212
+ _stag
213
+ _cont
214
+ _etag
215
+ }
216
+ }
217
+ }
202
218
  expected: &logic1|
203
- - name: "list"
204
- logic:
205
- - " @list.each { |item|"
206
- - _stag
207
- - _cont
208
- - _etag
209
- - " }"
219
+ - name: list
220
+ logic:
221
+ - <% @list.each { |item|%>
222
+ - _stag
223
+ - _cont
224
+ - _etag
225
+ - <% }%>
210
226
 
211
227
  - name: parse_logic_part1_ruby
212
- parser: RubyStyleParser
213
- input: |
214
- element "list" {
215
- logic {
216
- @list.each { |item|
217
- _stag
218
- _cont
219
- _etag
220
- }
221
- }
222
- }
228
+ style: ruby
229
+ plogic: |
230
+ element "list" {
231
+ logic {
232
+ @list.each { |item|
233
+ _stag
234
+ _cont
235
+ _etag
236
+ }
237
+ }
238
+ }
223
239
  expected: *logic1
224
240
 
225
- ---
241
+ ###
226
242
  - name: parse_logic_part2_css
227
- parser: CssStyleParser
228
- input: |
229
- #list {
230
- logic: {
231
- @list.each_with_index { |item, i|
232
- if i % 2 == 0
233
- _element("foo")
234
- else
235
- _content('foo')
236
- end
237
- }
238
- }
239
- }
243
+ style: css
244
+ plogic: |
245
+ #list {
246
+ logic: {
247
+ @list.each_with_index { |item, i|
248
+ if i % 2 == 0
249
+ _element("foo")
250
+ else
251
+ _content('foo')
252
+ end
253
+ }
254
+ }
255
+ }
240
256
  expected: &logic2|
241
- - name: "list"
242
- logic:
243
- - " @list.each_with_index { |item, i|"
244
- - " if i % 2 == 0"
245
- - _element("foo")
246
- - " else"
247
- - _content("foo")
248
- - " end"
249
- - " }"
257
+ - name: list
258
+ logic:
259
+ - <% @list.each_with_index { |item, i|%>
260
+ - <% if i % 2 == 0%>
261
+ - _element(foo)
262
+ - <% else%>
263
+ - _content(foo)
264
+ - <% end%>
265
+ - <% }%>
250
266
 
251
267
  - name: parse_logic_part2_ruby
252
- parser: RubyStyleParser
253
- input: |
254
- element "list" {
255
- logic {
256
- @list.each_with_index { |item, i|
257
- if i % 2 == 0
258
- _element("foo")
259
- else
260
- _content('foo')
261
- end
262
- }
263
- }
264
- }
268
+ style: ruby
269
+ plogic: |
270
+ element "list" {
271
+ logic {
272
+ @list.each_with_index { |item, i|
273
+ if i % 2 == 0
274
+ _element("foo")
275
+ else
276
+ _content('foo')
277
+ end
278
+ }
279
+ }
280
+ }
265
281
  expected: *logic2
266
282
 
267
- ---
283
+ ###
268
284
  - name: parse_import_command1_css
269
- parser: CssStyleParser
270
- input: |
271
- @import 'common.plogic';
272
- #item {
273
- value: item;
274
- }
285
+ style: css
286
+ plogic: |
287
+ @import 'common.plogic';
288
+ #item {
289
+ value: item;
290
+ }
275
291
  expected: |
276
- - name: "page_link"
277
- cont: "page.label"
278
- attrs:
279
- - name: "href"
280
- value: "page.url"
281
- logic:
282
- - " if page"
283
- - _elem
284
- - " end"
285
- - name: "item"
286
- cont: "item"
287
- setup: |
288
- common_plogic = <<END
289
- #page_link {
290
- value: page.label;
291
- attrs: 'href' page.url;
292
- logic: {
293
- if page
294
- _elem
295
- end
292
+ - name: page_link
293
+ cont: page.label
294
+ attrs:
295
+ - name: href
296
+ value: page.url
297
+ logic:
298
+ - <% if page%>
299
+ - _elem
300
+ - <% end%>
301
+ - name: item
302
+ cont: item
303
+ setup*:
304
+ ruby: |
305
+ common_plogic = <<END
306
+ #page_link {
307
+ value: page.label;
308
+ attrs: 'href' page.url;
309
+ logic: {
310
+ if page
311
+ _elem
312
+ end
313
+ }
296
314
  }
297
- }
298
- END
299
- File.open('common.plogic', 'w') { |f| f.write(common_plogic) }
300
- teardown: |
301
- filename = 'common.plogic'
302
- File.unlink filename if test(?f, filename)
315
+ END
316
+ File.open('common.plogic', 'w') { |f| f.write(common_plogic) }
317
+ php: |
318
+ $common_plogic =
319
+ '#page_link {
320
+ value: page.label;
321
+ attrs: \'href\' page.url;
322
+ logic: {
323
+ if page
324
+ _elem
325
+ end
326
+ }
327
+ }
328
+ ';
329
+ file_put_contents('common.plogic', $common_plogic);
330
+ teardown*:
331
+ ruby: |
332
+ filename = 'common.plogic'
333
+ File.unlink filename if test(?f, filename)
334
+ php: |
335
+ $filename = 'common.plogic';
336
+ if (file_exists($filename)) unlink($filename);
337
+
338
+ ###
339
+ - name: parse_multi_selector_css
340
+ style: css
341
+ plogic: |
342
+ #item1, #item2, #item3 {
343
+ value: $item;
344
+ logic: {
345
+ foreach ($list as $item) {
346
+ _stag();
347
+ _cont();
348
+ _etag();
349
+ }
350
+ }
351
+ }
352
+ expected: |
353
+ - name: item1
354
+ cont: $item
355
+ logic:
356
+ - <% foreach ($list as $item) {%>
357
+ - _stag
358
+ - _cont
359
+ - _etag
360
+ - <% }%>
361
+ - name: item2
362
+ cont: $item
363
+ logic:
364
+ - <% foreach ($list as $item) {%>
365
+ - _stag
366
+ - _cont
367
+ - _etag
368
+ - <% }%>
369
+ - name: item3
370
+ cont: $item
371
+ logic:
372
+ - <% foreach ($list as $item) {%>
373
+ - _stag
374
+ - _cont
375
+ - _etag
376
+ - <% }%>
303
377
 
304
- ---
378
+ ###
305
379
  - name: parse_document
306
- parser: CssStyleParser
307
- input: |
308
- #DOCUMENT {
309
- local: i, item, title, list;
310
- global: _context;
311
- begin: {
312
- title = _context[:title]
313
- list = _context[:list]
380
+ style: css
381
+ plogic: |
382
+ #DOCUMENT {
383
+ local: i, item, title, list;
384
+ global: _context;
385
+ begin: {
386
+ title = _context[:title]
387
+ list = _context[:list]
388
+ }
389
+ end: {
390
+ print "*** debug:\n"
391
+ _context.each do |key, value|
392
+ print "*** key=#{key}, value=#{value.inspect}"
393
+ end
394
+ }
314
395
  }
315
- end: {
316
- print "*** debug:\n"
317
- _context.each do |key, value|
318
- print "*** key=#{key}, value=#{value.inspect}"
319
- end
396
+ expected: |
397
+ - name: DOCUMENT
398
+ global:
399
+ - _context
400
+ local:
401
+ - i
402
+ - item
403
+ - title
404
+ - list
405
+ begin:
406
+ - <% title = _context[:title]%>
407
+ - <% list = _context[:list]%>
408
+ end:
409
+ - print(<%="*** debug:\n"%>)
410
+ - <% _context.each do |key, value|%>
411
+ - print(<%="*** key=#{key}, value=#{value.inspect}"%>)
412
+ - <% end%>
413
+ ###
414
+ - name: parse_comment1_css
415
+ style: css
416
+ plogic: |
417
+ /*
418
+ * region comment
419
+ */
420
+ #foo {
421
+ // line comment
422
+ value: foo;
320
423
  }
321
- }
424
+ /* tail comment may cause parse error! */
322
425
  expected: |
323
- - name: "DOCUMENT"
324
- global:
325
- - _context
326
- local:
327
- - i
328
- - item
329
- - title
330
- - list
331
- begin:
332
- - " title = _context[:title]"
333
- - " list = _context[:list]"
334
- end:
335
- - [ <%="*** debug:\n"%>]
336
- - " _context.each do |key, value|"
337
- - [ <%="*** key=#{key}, value=#{value.inspect}"%>]
338
- - " end"
426
+ - name: foo
427
+ cont: foo
339
428
 
429
+ - name: parse_comment2_css
430
+ style: css
431
+ plogic*:
432
+ ruby: |
433
+ #foo {
434
+ value: item; // line comment
435
+ logic: {
436
+ _elem ## ruby comment
437
+ }
438
+ }
439
+ php: |
440
+ #foo {
441
+ value: item; // line comment
442
+ logic: {
443
+ _elem // ruby comment
444
+ }
445
+ }
446
+ expected: |
447
+ - name: foo
448
+ cont: item
449
+ logic:
450
+ - _elem
340
451
 
341
- ---
452
+ ###
342
453
  - name: parse_element_all1_css
343
- parser: CssStyleParser
344
- input: |
345
- #list {
346
- value: item.name;
347
- attrs: 'title' item.desc,
348
- 'class' klass;
349
- append: item==current_item ? ' checked="checked"' : '';
350
- logic: {
351
- @list.each_with_index { |item, i|
352
- klass = i % 2 == 0 ? 'even' : 'odd'
353
- _stag # start tag
354
- _cont # content
355
- _etag # end tag
356
- }
357
- }
358
- }
359
- expected: &all1|
360
- - name: "list"
361
- cont: "item.name"
362
- attrs:
363
- - name: "class"
364
- value: "klass"
365
- - name: "title"
366
- value: "item.desc"
367
- append:
368
- - "item==current_item ? ' checked=\"checked\"' : ''"
369
- logic:
370
- - " @list.each_with_index { |item, i|"
371
- - " klass = i % 2 == 0 ? 'even' : 'odd'"
372
- - _stag
373
- - _cont
374
- - _etag
375
- - " }"
454
+ style: css
455
+ plogic: |
456
+ #item {
457
+ stag: start_link_tag('user', 'name');
458
+ etag: end_link();
459
+ elem: link_to_remote('user', 'name');
460
+ value: $item;
461
+ attrs: "href" $href,
462
+ 'class' $class,
463
+ 'bgcolor' $color;
464
+ append: $gender == "M" ? " checked=\"checked\"" : "",
465
+ $obsolete ? ' disabled="disabled"' : '';
466
+ remove: "id", 'title', 'xml:lang';
467
+ logic: {
468
+ $i = 0;
469
+ foreach ($list as $item) {
470
+ $color = ++$i % 2 == 0 ? "#CCCCFF" : "#FFCCCC";
471
+ _stag();
472
+ _cont();
473
+ _etag();
474
+ }
475
+ }
476
+ }
477
+ expected: &all1 |
478
+ - name: item
479
+ stag: start_link_tag('user', 'name')
480
+ cont: $item
481
+ etag: end_link()
482
+ elem: link_to_remote('user', 'name')
483
+ attrs:
484
+ - name: bgcolor
485
+ value: $color
486
+ - name: class
487
+ value: $class
488
+ - name: href
489
+ value: $href
490
+ append:
491
+ - $gender == "M" ? " checked=\"checked\"" : ""
492
+ - $obsolete ? ' disabled="disabled"' : ''
493
+ remove:
494
+ - id
495
+ - title
496
+ - xml:lang
497
+ logic:
498
+ - <% $i = 0;%>
499
+ - <% foreach ($list as $item) {%>
500
+ - <% $color = ++$i % 2 == 0 ? "#CCCCFF" : "#FFCCCC";%>
501
+ - _stag
502
+ - _cont
503
+ - _etag
504
+ - <% }%>
376
505
 
377
506
  - name: parse_element_all1_ruby
378
- parser: RubyStyleParser
379
- input: |
380
- element "list" {
381
- value item.name
382
- attrs 'title'=>item.desc, 'class'=>klass
383
- append item==current_item ? ' checked="checked"' : ''
384
- logic {
385
- @list.each_with_index { |item, i|
386
- klass = i % 2 == 0 ? 'even' : 'odd'
387
- _stag # start tag
388
- _cont # content
389
- _etag # end tag
390
- }
391
- }
392
- }
393
- expected: *all1
394
-
507
+ style: ruby
508
+ plogic: |
509
+ element "item" {
510
+ stag start_link_tag('user', 'name')
511
+ etag end_link()
512
+ elem link_to_remote('user', 'name')
513
+ value item
514
+ attrs 'href'=>href, 'class'=>class, 'bgcolor'=>color
515
+ append gender == "M" ? " checked=\"checked\"" : "", obsolete ? ' disabled="disabled"' : ''
516
+ remove "id", 'title', 'xml:lang'
517
+ logic {
518
+ @list.each_with_index do |item, i|
519
+ color = i % 2 == 0 ? "#CCCCFF" : "#FFCCCC"
520
+ _stag
521
+ _cont
522
+ _etag
523
+ end
524
+ }
525
+ }
526
+ expected: |
527
+ - name: item
528
+ stag: start_link_tag('user', 'name')
529
+ cont: item
530
+ etag: end_link()
531
+ elem: link_to_remote('user', 'name')
532
+ attrs:
533
+ - name: bgcolor
534
+ value: color
535
+ - name: class
536
+ value: class
537
+ - name: href
538
+ value: href
539
+ append:
540
+ - gender == "M" ? " checked=\"checked\"" : ""
541
+ - obsolete ? ' disabled="disabled"' : ''
542
+ remove:
543
+ - id
544
+ - title
545
+ - xml:lang
546
+ logic:
547
+ - <% @list.each_with_index do |item, i|%>
548
+ - <% color = i % 2 == 0 ? "#CCCCFF" : "#FFCCCC"%>
549
+ - _stag
550
+ - _cont
551
+ - _etag
552
+ - <% end%>