kwartz 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +36 -1
- data/LGPL +504 -0
- data/README.txt +16 -2
- data/bin/kwartz +1 -1
- data/doc-api/classes/Kwartz.html +47 -1
- data/doc-api/classes/Kwartz/Assertion.html +6 -6
- data/doc-api/classes/Kwartz/AssertionError.html +6 -6
- data/doc-api/classes/Kwartz/AttrInfo.html +42 -42
- data/doc-api/classes/Kwartz/BaseError.html +12 -12
- data/doc-api/classes/Kwartz/BaseTranslator.html +210 -43
- data/doc-api/classes/Kwartz/CharacterType.html +24 -24
- data/doc-api/classes/Kwartz/CommandOptionError.html +7 -7
- data/doc-api/classes/Kwartz/CommandOptions.html +49 -49
- data/doc-api/classes/Kwartz/Config.html +6 -1
- data/doc-api/classes/Kwartz/ConvertError.html +14 -14
- data/doc-api/classes/Kwartz/Converter.html +31 -30
- data/doc-api/classes/Kwartz/CssStyleParser.html +79 -57
- data/doc-api/classes/Kwartz/Defun.html +313 -0
- data/doc-api/classes/Kwartz/DocumentRuleset.html +58 -58
- data/doc-api/classes/Kwartz/ElementExpander.html +32 -32
- data/doc-api/classes/Kwartz/ElementInfo.html +29 -29
- data/doc-api/classes/Kwartz/ElementRuleset.html +126 -96
- data/doc-api/classes/Kwartz/EperlHandler.html +108 -84
- data/doc-api/classes/Kwartz/EperlTranslator.html +7 -7
- data/doc-api/classes/Kwartz/ErubisHandler.html +2 -2
- data/doc-api/classes/Kwartz/ErubisTranslator.html +8 -8
- data/doc-api/classes/Kwartz/ErubyHandler.html +2 -220
- data/doc-api/classes/Kwartz/ErubyTranslator.html +7 -7
- data/doc-api/classes/Kwartz/ExpandStatement.html +20 -20
- data/doc-api/classes/Kwartz/Handler.html +122 -117
- data/doc-api/classes/Kwartz/HandlerArgument.html +215 -0
- data/doc-api/classes/Kwartz/Helper.html +112 -0
- data/doc-api/classes/Kwartz/Helper/ActionViewHelper.html +221 -0
- data/doc-api/classes/Kwartz/Helper/RailsTemplate.html +630 -0
- data/doc-api/classes/Kwartz/JstlHandler.html +208 -193
- data/doc-api/classes/Kwartz/JstlTranslator.html +15 -15
- data/doc-api/classes/Kwartz/KwartzError.html +6 -6
- data/doc-api/classes/Kwartz/Main.html +39 -23
- data/doc-api/classes/Kwartz/NativeExpression.html +18 -18
- data/doc-api/classes/Kwartz/NativeStatement.html +25 -25
- data/doc-api/classes/Kwartz/Node.html +6 -6
- data/doc-api/classes/Kwartz/PIErubisHandler.html +113 -0
- data/doc-api/classes/Kwartz/PIErubisTranslator.html +200 -0
- data/doc-api/classes/Kwartz/ParseError.html +6 -6
- data/doc-api/classes/Kwartz/PhpHandler.html +102 -83
- data/doc-api/classes/Kwartz/PhpTranslator.html +14 -14
- data/doc-api/classes/Kwartz/PresentationLogicParser.html +136 -128
- data/doc-api/classes/Kwartz/PrintStatement.html +19 -19
- data/doc-api/classes/Kwartz/RailsHandler.html +121 -118
- data/doc-api/classes/Kwartz/RailsTranslator.html +7 -7
- data/doc-api/classes/Kwartz/RubyHandler.html +349 -0
- data/doc-api/classes/Kwartz/RubyStyleParser.html +85 -85
- data/doc-api/classes/Kwartz/RubyTranslator.html +218 -0
- data/doc-api/classes/Kwartz/StatementHelper.html +479 -0
- data/doc-api/classes/Kwartz/StrutsTranslator.html +12 -12
- data/doc-api/classes/Kwartz/TagInfo.html +28 -28
- data/doc-api/classes/Kwartz/TextConverter.html +28 -28
- data/doc-api/classes/Kwartz/Translator.html +42 -42
- data/doc-api/classes/Kwartz/Util.html +284 -0
- data/doc-api/created.rid +1 -1
- data/doc-api/files/__/README_txt.html +30 -3
- data/doc-api/files/kwartz/assert_rb.html +1 -1
- data/doc-api/files/kwartz/binding/eperl_rb.html +2 -2
- data/doc-api/files/kwartz/binding/erubis_rb.html +3 -3
- data/doc-api/files/kwartz/binding/eruby_rb.html +3 -2
- data/doc-api/files/kwartz/binding/jstl_rb.html +2 -2
- data/doc-api/files/kwartz/binding/php_rb.html +2 -2
- data/doc-api/files/kwartz/binding/pierubis_rb.html +116 -0
- data/doc-api/files/kwartz/binding/rails_rb.html +2 -2
- data/doc-api/files/kwartz/binding/ruby_rb.html +115 -0
- data/doc-api/files/kwartz/binding/struts_rb.html +1 -1
- data/doc-api/files/kwartz/config_rb.html +2 -2
- data/doc-api/files/kwartz/converter_rb.html +3 -2
- data/doc-api/files/kwartz/defun_rb.html +116 -0
- data/doc-api/files/kwartz/error_rb.html +1 -1
- data/doc-api/files/kwartz/helper/rails_rb.html +123 -0
- data/doc-api/files/kwartz/main_rb.html +5 -2
- data/doc-api/files/kwartz/node_rb.html +2 -2
- data/doc-api/files/kwartz/parser_rb.html +2 -2
- data/doc-api/files/kwartz/translator_rb.html +2 -2
- data/doc-api/files/kwartz/util/assert-text-equal_rb.html +1 -1
- data/doc-api/files/kwartz/util/testcase-helper_rb.html +2 -2
- data/doc-api/files/kwartz/util_rb.html +107 -0
- data/doc-api/files/kwartz_rb.html +3 -2
- data/doc-api/fr_class_index.html +11 -0
- data/doc-api/fr_file_index.html +5 -0
- data/doc-api/fr_method_index.html +242 -190
- data/doc/p-pattern.html +94 -94
- data/doc/reference.html +847 -612
- data/doc/users-guide.html +744 -241
- data/examples/rails1/README +2 -2
- data/examples/rails1/application_helper.rb +2 -27
- data/examples/rails1/link_to.plogic +5 -5
- data/examples/rails1/list.plogic +2 -2
- data/examples/rails2/app/controllers/application.rb +14 -0
- data/examples/rails2/app/controllers/groups_controller.rb +47 -0
- data/examples/rails2/app/controllers/members_controller.rb +56 -0
- data/examples/rails2/app/helpers/application_helper.rb +6 -0
- data/examples/rails2/app/helpers/groups_helper.rb +2 -0
- data/examples/rails2/app/helpers/members_helper.rb +2 -0
- data/examples/rails2/app/models/group.rb +2 -0
- data/examples/rails2/app/models/member.rb +3 -0
- data/examples/rails2/app/views/groups/_form.html +30 -0
- data/examples/rails2/app/views/groups/_form.plogic +11 -0
- data/examples/rails2/app/views/groups/_link.plogic +19 -0
- data/examples/rails2/app/views/groups/_read.plogic +7 -0
- data/examples/rails2/app/views/groups/edit.cfg.yaml +2 -0
- data/examples/rails2/app/views/groups/edit.html +26 -0
- data/examples/rails2/app/views/groups/edit.plogic +9 -0
- data/examples/rails2/app/views/groups/list.html +48 -0
- data/examples/rails2/app/views/groups/list.plogic +32 -0
- data/examples/rails2/app/views/groups/new.cfg.yaml +2 -0
- data/examples/rails2/app/views/groups/new.html +27 -0
- data/examples/rails2/app/views/groups/new.plogic +9 -0
- data/examples/rails2/app/views/groups/show.html +27 -0
- data/examples/rails2/app/views/groups/show.plogic +2 -0
- data/examples/rails2/app/views/layouts/groups.html +23 -0
- data/examples/rails2/app/views/layouts/groups.plogic +11 -0
- data/examples/rails2/app/views/layouts/members.html +23 -0
- data/examples/rails2/app/views/layouts/members.plogic +11 -0
- data/examples/rails2/app/views/layouts/members2.html +24 -0
- data/examples/rails2/app/views/layouts/members2.plogic +11 -0
- data/examples/rails2/app/views/members/_form.plogic +27 -0
- data/examples/rails2/app/views/members/_link.plogic +19 -0
- data/examples/rails2/app/views/members/_read.plogic +29 -0
- data/examples/rails2/app/views/members/edit.cfg.yaml +6 -0
- data/examples/rails2/app/views/members/edit.html +27 -0
- data/examples/rails2/app/views/members/edit.plogic +10 -0
- data/examples/rails2/app/views/members/list.html +53 -0
- data/examples/rails2/app/views/members/list.plogic +32 -0
- data/examples/rails2/app/views/members/new.html +61 -0
- data/examples/rails2/app/views/members/new.plogic +17 -0
- data/examples/rails2/app/views/members/show.html +41 -0
- data/examples/rails2/app/views/members/show.plogic +3 -0
- data/examples/rails2/db/create-tables.mysql.sql +27 -0
- data/examples/rails2/db/create-tables.pgsql.sql +27 -0
- data/examples/rails2/db/insert-data.sql +21 -0
- data/examples/rails2/db/tabledef.yaml +51 -0
- data/kwartz.gemspec +4 -4
- data/lib/kwartz.rb +10 -2
- data/lib/kwartz/assert.rb +1 -1
- data/lib/kwartz/binding/eperl.rb +85 -61
- data/lib/kwartz/binding/erubis.rb +6 -8
- data/lib/kwartz/binding/eruby.rb +5 -120
- data/lib/kwartz/binding/jstl.rb +116 -101
- data/lib/kwartz/binding/php.rb +79 -60
- data/lib/kwartz/binding/pierubis.rb +58 -0
- data/lib/kwartz/binding/rails.rb +45 -42
- data/lib/kwartz/binding/ruby.rb +193 -0
- data/lib/kwartz/binding/struts.rb +1 -1
- data/lib/kwartz/config.rb +4 -3
- data/lib/kwartz/converter.rb +231 -68
- data/lib/kwartz/defun.rb +126 -0
- data/lib/kwartz/error.rb +1 -1
- data/lib/kwartz/helper/rails.rb +437 -0
- data/lib/kwartz/main.rb +30 -38
- data/lib/kwartz/node.rb +46 -31
- data/lib/kwartz/parser.rb +43 -15
- data/lib/kwartz/translator.rb +104 -6
- data/lib/kwartz/util.rb +113 -0
- data/lib/kwartz/util/assert-text-equal.rb +1 -1
- data/lib/kwartz/util/testcase-helper.rb +26 -8
- data/test/test-compile.rb +3 -3
- data/test/test-compile.yaml +135 -5
- data/test/test-converter.rb +16 -8
- data/test/test-converter.yaml +307 -76
- data/test/test-directives.rb +1 -1
- data/test/test-directives.yaml +964 -979
- data/test/test-main.rb +61 -146
- data/test/test-main.yaml +235 -0
- data/test/test-parser.rb +10 -12
- data/test/test-parser.yaml +484 -326
- data/test/test-rails.rb +1 -1
- data/test/test-rails.yaml +37 -37
- data/test/test-ruleset.rb +1 -1
- data/test/test-ruleset.yaml +34 -40
- data/test/test.rb +1 -1
- metadata +82 -3
- data/COPYING +0 -340
data/test/test-parser.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
###
|
2
|
-
### $Rev:
|
3
|
-
### $Release: 3.
|
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 @
|
27
|
-
when '
|
26
|
+
case @style
|
27
|
+
when 'ruby'
|
28
28
|
parser = Kwartz::RubyStyleParser.new()
|
29
|
-
when '
|
29
|
+
when 'css'
|
30
30
|
parser = Kwartz::CssStyleParser.new()
|
31
31
|
else
|
32
|
-
raise "*** invalid parser
|
32
|
+
raise "*** invalid parser style: #{@style}"
|
33
33
|
end
|
34
34
|
if @name =~ /scan/
|
35
35
|
actual = ''
|
36
|
-
parser.__send__ :reset, @
|
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(@
|
43
|
+
rulesets = parser.parse(@plogic)
|
44
44
|
actual = ''
|
45
45
|
rulesets.each do |ruleset|
|
46
|
-
|
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)
|
data/test/test-parser.yaml
CHANGED
@@ -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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
expected
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
66
|
+
style: css
|
67
|
+
plogic: |
|
68
|
+
#list {
|
69
|
+
}
|
54
70
|
expected: &elem1|
|
55
|
-
|
71
|
+
- name: list
|
56
72
|
|
57
73
|
- name: parse_elem1_ruby
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
82
|
+
style: css
|
67
83
|
desc: value part
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
84
|
+
plogic: |
|
85
|
+
#list {
|
86
|
+
value: @user['name'];
|
87
|
+
}
|
72
88
|
expected: &value1|
|
73
|
-
|
74
|
-
|
89
|
+
- name: list
|
90
|
+
cont: @user['name']
|
75
91
|
|
76
92
|
- name: parse_value_part1_ruby
|
77
|
-
|
93
|
+
style: ruby
|
78
94
|
desc: value part
|
79
|
-
|
80
|
-
|
81
|
-
|
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
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
103
|
+
style: css
|
104
|
+
plogic: |
|
105
|
+
#list {
|
106
|
+
attrs: "class" @class,
|
107
|
+
'color' @prop[:color];
|
108
|
+
}
|
93
109
|
expected: &attrs1|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
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
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
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
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
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
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
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
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
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
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
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
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
166
|
+
style: css
|
167
|
+
plogic: |
|
168
|
+
#list {
|
169
|
+
remove: "foo", "bar", 'baz';
|
170
|
+
}
|
155
171
|
expected: &remove1|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
172
|
+
- name: list
|
173
|
+
remove:
|
174
|
+
- foo
|
175
|
+
- bar
|
176
|
+
- baz
|
161
177
|
|
162
178
|
- name: parse_remove_part1_ruby
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
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
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
188
|
+
style: css
|
189
|
+
plogic: |
|
190
|
+
#list {
|
191
|
+
tagname: 'html:html';
|
192
|
+
}
|
177
193
|
expected: &tagname1|
|
178
|
-
|
179
|
-
|
194
|
+
- name: list
|
195
|
+
tagname: html:html
|
180
196
|
|
181
197
|
- name: parse_tagname_part1_ruby
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
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
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
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
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
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
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
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
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
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
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
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
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
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
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
285
|
+
style: css
|
286
|
+
plogic: |
|
287
|
+
@import 'common.plogic';
|
288
|
+
#item {
|
289
|
+
value: item;
|
290
|
+
}
|
275
291
|
expected: |
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
setup
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
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
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
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
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
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
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
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
|
-
|
324
|
-
|
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
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
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
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
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%>
|