wlang 0.10.2 → 2.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -121
- data/Gemfile +23 -1
- data/Gemfile.lock +32 -28
- data/LICENCE.md +18 -21
- data/Manifest.txt +4 -5
- data/README.md +100 -174
- data/Rakefile +1 -13
- data/bin/wlang +3 -29
- data/lib/wlang.rb +21 -394
- data/lib/wlang/command.rb +94 -0
- data/lib/wlang/compiler.rb +78 -0
- data/lib/wlang/compiler/autospacing.rb +60 -0
- data/lib/wlang/compiler/dialect_enforcer.rb +91 -0
- data/lib/wlang/compiler/filter.rb +32 -0
- data/lib/wlang/compiler/grammar.citrus +67 -0
- data/lib/wlang/compiler/parser.rb +26 -0
- data/lib/wlang/compiler/proc_call_removal.rb +15 -0
- data/lib/wlang/compiler/static_merger.rb +28 -0
- data/lib/wlang/compiler/strconcat_flattener.rb +25 -0
- data/lib/wlang/compiler/to_ruby_abstraction.rb +22 -0
- data/lib/wlang/compiler/to_ruby_code.rb +55 -0
- data/lib/wlang/dialect.rb +40 -237
- data/lib/wlang/dialect/dispatching.rb +51 -0
- data/lib/wlang/dialect/evaluation.rb +30 -0
- data/lib/wlang/dialect/tags.rb +50 -0
- data/lib/wlang/dummy.rb +32 -0
- data/lib/wlang/html.rb +106 -0
- data/lib/wlang/loader.rb +6 -0
- data/lib/wlang/mustang.rb +90 -0
- data/lib/wlang/scope.rb +57 -0
- data/lib/wlang/scope/binding_scope.rb +18 -0
- data/lib/wlang/scope/object_scope.rb +25 -0
- data/lib/wlang/scope/proxy_scope.rb +18 -0
- data/lib/wlang/scope/root_scope.rb +24 -0
- data/lib/wlang/template.rb +16 -86
- data/lib/wlang/version.rb +9 -8
- data/spec/fixtures/dialect/foobar.rb +31 -0
- data/spec/fixtures/dialect/upcasing.rb +13 -0
- data/spec/fixtures/templates/hello.tpl +1 -0
- data/spec/integration/examples/1-basics.txt +65 -0
- data/spec/integration/examples/2-imperative.txt +51 -0
- data/spec/integration/examples/3-partials.txt +76 -0
- data/spec/integration/examples/4-recursion.txt +16 -0
- data/spec/integration/html/test_ampersand.rb +15 -0
- data/spec/integration/html/test_bang.rb +38 -0
- data/spec/integration/html/test_caret.rb +33 -0
- data/spec/integration/html/test_dollar.rb +16 -0
- data/spec/integration/html/test_greater.rb +23 -0
- data/spec/integration/html/test_modulo.rb +16 -0
- data/spec/integration/html/test_plus.rb +48 -0
- data/spec/integration/html/test_question.rb +33 -0
- data/spec/integration/html/test_sharp.rb +21 -0
- data/spec/integration/html/test_slash.rb +16 -0
- data/spec/integration/html/test_star.rb +37 -0
- data/spec/integration/test_dummy.rb +51 -0
- data/spec/integration/test_examples.rb +29 -0
- data/spec/integration/test_mustang.rb +120 -0
- data/spec/integration/test_readme.rb +56 -0
- data/spec/integration/test_upcasing.rb +22 -0
- data/spec/spec_helper.rb +62 -1
- data/spec/test_wlang.rb +101 -0
- data/spec/unit/compiler/autospacing/test_right_strip.rb +30 -0
- data/spec/unit/compiler/autospacing/test_unindent.rb +30 -0
- data/spec/unit/compiler/test_dialect_enforcer.rb +168 -0
- data/spec/unit/compiler/test_grammar.rb +207 -0
- data/spec/unit/compiler/test_parser.rb +69 -0
- data/spec/unit/compiler/test_proc_call_removal.rb +24 -0
- data/spec/unit/compiler/test_static_merger.rb +29 -0
- data/spec/unit/compiler/test_strconcat_flattener.rb +30 -0
- data/spec/unit/compiler/test_to_ruby_abstraction.rb +59 -0
- data/spec/unit/compiler/test_to_ruby_code.rb +24 -0
- data/spec/unit/dialect/test_compile.rb +52 -0
- data/spec/unit/dialect/test_dispatching.rb +19 -0
- data/spec/unit/dialect/test_evaluate.rb +41 -0
- data/spec/unit/dialect/test_render.rb +33 -0
- data/spec/unit/dialect/test_tags.rb +32 -0
- data/spec/unit/dialect/test_with_scope.rb +18 -0
- data/spec/unit/scope/test_binding_scope.rb +27 -0
- data/spec/unit/scope/test_coerce.rb +22 -0
- data/spec/unit/scope/test_object_scope.rb +38 -0
- data/spec/unit/scope/test_proxy_scope.rb +22 -0
- data/spec/unit/scope/test_root_scope.rb +22 -0
- data/spec/unit/test_assumptions.rb +29 -0
- data/spec/unit/test_scope.rb +57 -0
- data/tasks/debug_mail.rake +42 -45
- data/tasks/gem.rake +22 -17
- data/tasks/spec_test.rake +9 -17
- data/tasks/unit_test.rake +11 -12
- data/tasks/yard.rake +13 -13
- data/wlang.gemspec +36 -32
- data/wlang.noespec +27 -35
- metadata +268 -451
- data/doc/specification/about.rdoc +0 -61
- data/doc/specification/analytics.wtpl +0 -13
- data/doc/specification/dialect.wtpl +0 -14
- data/doc/specification/dialects.wtpl +0 -3
- data/doc/specification/examples.rb +0 -3
- data/doc/specification/glossary.wtpl +0 -14
- data/doc/specification/hosting.rdoc +0 -0
- data/doc/specification/overview.rdoc +0 -116
- data/doc/specification/rulesets.wtpl +0 -87
- data/doc/specification/specification.css +0 -53
- data/doc/specification/specification.html +0 -1690
- data/doc/specification/specification.js +0 -8
- data/doc/specification/specification.wtpl +0 -42
- data/doc/specification/specification.yml +0 -432
- data/doc/specification/symbols.wtpl +0 -16
- data/lib/wlang/dialect_dsl.rb +0 -141
- data/lib/wlang/dialect_loader.rb +0 -74
- data/lib/wlang/dialects/bluecloth_dialect.rb +0 -16
- data/lib/wlang/dialects/coderay_dialect.rb +0 -45
- data/lib/wlang/dialects/hosted_dialect.rb +0 -50
- data/lib/wlang/dialects/plain_text_dialect.rb +0 -69
- data/lib/wlang/dialects/rdoc_dialect.rb +0 -33
- data/lib/wlang/dialects/redcloth_dialect.rb +0 -16
- data/lib/wlang/dialects/ruby_dialect.rb +0 -118
- data/lib/wlang/dialects/sql_dialect.rb +0 -38
- data/lib/wlang/dialects/standard_dialects.rb +0 -181
- data/lib/wlang/dialects/xhtml_dialect.rb +0 -63
- data/lib/wlang/dialects/yaml_dialect.rb +0 -30
- data/lib/wlang/encoder.rb +0 -62
- data/lib/wlang/encoder_set.rb +0 -122
- data/lib/wlang/errors.rb +0 -80
- data/lib/wlang/ext/hash_methodize.rb +0 -13
- data/lib/wlang/ext/string.rb +0 -44
- data/lib/wlang/hash_scope.rb +0 -89
- data/lib/wlang/hosted_language.rb +0 -146
- data/lib/wlang/intelligent_buffer.rb +0 -94
- data/lib/wlang/parser.rb +0 -332
- data/lib/wlang/parser_state.rb +0 -94
- data/lib/wlang/rule.rb +0 -66
- data/lib/wlang/rule_set.rb +0 -106
- data/lib/wlang/rulesets/basic_ruleset.rb +0 -83
- data/lib/wlang/rulesets/buffering_ruleset.rb +0 -115
- data/lib/wlang/rulesets/context_ruleset.rb +0 -111
- data/lib/wlang/rulesets/encoding_ruleset.rb +0 -73
- data/lib/wlang/rulesets/imperative_ruleset.rb +0 -132
- data/lib/wlang/rulesets/ruleset_utils.rb +0 -317
- data/lib/wlang/wlang_command.rb +0 -51
- data/lib/wlang/wlang_command_options.rb +0 -163
- data/spec/basic_object.spec +0 -40
- data/spec/coderay_dialect.spec +0 -8
- data/spec/dialect/apply_post_transform.spec +0 -16
- data/spec/global_extensions.rb +0 -2
- data/spec/hash_scope.spec +0 -76
- data/spec/redcloth_dialect.spec +0 -24
- data/spec/test_all.rb +0 -8
- data/spec/wlang.spec +0 -53
- data/spec/wlang_spec.rb +0 -8
- data/spec/xhtml_dialect.spec +0 -22
- data/tasks/genspec.rake +0 -5
- data/test/blackbox/basic/execution_1.exp +0 -1
- data/test/blackbox/basic/execution_1.tpl +0 -1
- data/test/blackbox/basic/execution_2.exp +0 -1
- data/test/blackbox/basic/execution_2.tpl +0 -1
- data/test/blackbox/basic/execution_3.exp +0 -1
- data/test/blackbox/basic/execution_3.tpl +0 -1
- data/test/blackbox/basic/execution_4.exp +0 -1
- data/test/blackbox/basic/execution_4.tpl +0 -1
- data/test/blackbox/basic/inclusion_1.exp +0 -1
- data/test/blackbox/basic/inclusion_1.tpl +0 -1
- data/test/blackbox/basic/inclusion_2.exp +0 -1
- data/test/blackbox/basic/inclusion_2.tpl +0 -1
- data/test/blackbox/basic/injection_1.exp +0 -1
- data/test/blackbox/basic/injection_1.tpl +0 -1
- data/test/blackbox/basic/injection_2.exp +0 -1
- data/test/blackbox/basic/injection_2.tpl +0 -1
- data/test/blackbox/basic/modulation_1.exp +0 -1
- data/test/blackbox/basic/modulation_1.tpl +0 -1
- data/test/blackbox/basic/modulation_2.exp +0 -1
- data/test/blackbox/basic/modulation_2.tpl +0 -1
- data/test/blackbox/basic/recursive_app_1.exp +0 -1
- data/test/blackbox/basic/recursive_app_1.tpl +0 -1
- data/test/blackbox/basic/recursive_app_2.exp +0 -1
- data/test/blackbox/basic/recursive_app_2.tpl +0 -1
- data/test/blackbox/buffering/data_1.rb +0 -1
- data/test/blackbox/buffering/data_assignment_1.exp +0 -1
- data/test/blackbox/buffering/data_assignment_1.tpl +0 -1
- data/test/blackbox/buffering/data_assignment_2.exp +0 -1
- data/test/blackbox/buffering/data_assignment_2.tpl +0 -1
- data/test/blackbox/buffering/data_assignment_3.exp +0 -1
- data/test/blackbox/buffering/data_assignment_3.tpl +0 -1
- data/test/blackbox/buffering/data_assignment_4.exp +0 -1
- data/test/blackbox/buffering/data_assignment_4.tpl +0 -1
- data/test/blackbox/buffering/input_1.exp +0 -1
- data/test/blackbox/buffering/input_1.tpl +0 -1
- data/test/blackbox/buffering/input_2.exp +0 -1
- data/test/blackbox/buffering/input_2.tpl +0 -1
- data/test/blackbox/buffering/input_3.exp +0 -1
- data/test/blackbox/buffering/input_3.tpl +0 -1
- data/test/blackbox/buffering/input_inclusion.exp +0 -1
- data/test/blackbox/buffering/input_inclusion.tpl +0 -1
- data/test/blackbox/buffering/input_inclusion_1.exp +0 -0
- data/test/blackbox/buffering/input_inclusion_1.tpl +0 -1
- data/test/blackbox/buffering/input_inclusion_2.exp +0 -1
- data/test/blackbox/buffering/input_inclusion_2.tpl +0 -1
- data/test/blackbox/buffering/input_inclusion_3.exp +0 -1
- data/test/blackbox/buffering/input_inclusion_3.tpl +0 -1
- data/test/blackbox/buffering/input_inclusion_4.exp +0 -0
- data/test/blackbox/buffering/input_inclusion_4.tpl +0 -1
- data/test/blackbox/buffering/input_inclusion_5.exp +0 -1
- data/test/blackbox/buffering/input_inclusion_5.tpl +0 -1
- data/test/blackbox/buffering/input_inclusion_6.exp +0 -1
- data/test/blackbox/buffering/input_inclusion_6.tpl +0 -1
- data/test/blackbox/buffering/input_inclusion_7.exp +0 -0
- data/test/blackbox/buffering/input_inclusion_7.tpl +0 -1
- data/test/blackbox/buffering/text_1.txt +0 -1
- data/test/blackbox/buffering/wlang.txt +0 -1
- data/test/blackbox/context/assignment_1.exp +0 -1
- data/test/blackbox/context/assignment_1.tpl +0 -1
- data/test/blackbox/context/assignment_2.exp +0 -1
- data/test/blackbox/context/assignment_2.tpl +0 -1
- data/test/blackbox/context/assignment_3.exp +0 -2
- data/test/blackbox/context/assignment_3.tpl +0 -2
- data/test/blackbox/context/assignment_4.exp +0 -1
- data/test/blackbox/context/assignment_4.tpl +0 -1
- data/test/blackbox/context/block_assignment_1.exp +0 -1
- data/test/blackbox/context/block_assignment_1.tpl +0 -1
- data/test/blackbox/context/block_assignment_2.exp +0 -1
- data/test/blackbox/context/block_assignment_2.tpl +0 -1
- data/test/blackbox/context/modulo_assignment_1.exp +0 -1
- data/test/blackbox/context/modulo_assignment_1.tpl +0 -1
- data/test/blackbox/context/modulo_assignment_2.exp +0 -1
- data/test/blackbox/context/modulo_assignment_2.tpl +0 -1
- data/test/blackbox/data_1.rb +0 -1
- data/test/blackbox/postblock/hello.exp +0 -1
- data/test/blackbox/postblock/hello.pre +0 -1
- data/test/blackbox/postblock/hello.tpl +0 -1
- data/test/blackbox/postblock/hello_input_inclusion.exp +0 -1
- data/test/blackbox/postblock/hello_input_inclusion.tpl +0 -1
- data/test/blackbox/postblock/hello_to_authors.exp +0 -1
- data/test/blackbox/postblock/hello_to_authors.tpl +0 -1
- data/test/blackbox/poststring/hello.exp +0 -1
- data/test/blackbox/poststring/hello.tpl +0 -1
- data/test/blackbox/test_all.rb +0 -70
- data/test/standard_dialects/ruby/data.rb +0 -7
- data/test/standard_dialects/ruby/inclusion.exp +0 -6
- data/test/standard_dialects/ruby/inclusion.tpl +0 -6
- data/test/standard_dialects/test_all.rb +0 -29
- data/test/standard_dialects/yaml/assumptions_test.rb +0 -13
- data/test/standard_dialects/yaml/data.rb +0 -3
- data/test/standard_dialects/yaml/inclusion_1.exp +0 -7
- data/test/standard_dialects/yaml/inclusion_1.tpl +0 -2
- data/test/standard_dialects/yaml/inclusion_2.exp +0 -5
- data/test/standard_dialects/yaml/inclusion_2.tpl +0 -3
- data/test/unit/test_all.rb +0 -9
- data/test/unit/wlang/anagram_bugs_test.rb +0 -111
- data/test/unit/wlang/basic_ruleset_test.rb +0 -52
- data/test/unit/wlang/buffering_ruleset_test.rb +0 -102
- data/test/unit/wlang/buffering_template1.wtpl +0 -1
- data/test/unit/wlang/buffering_template2.wtpl +0 -1
- data/test/unit/wlang/buffering_template3.wtpl +0 -1
- data/test/unit/wlang/buffering_template4.wtpl +0 -1
- data/test/unit/wlang/buffering_template5.wtpl +0 -1
- data/test/unit/wlang/context_ruleset_test.rb +0 -32
- data/test/unit/wlang/data.rb +0 -3
- data/test/unit/wlang/encoder_set_test.rb +0 -42
- data/test/unit/wlang/imperative_ruleset_test.rb +0 -107
- data/test/unit/wlang/intelligent_buffer_test.rb +0 -194
- data/test/unit/wlang/othersymbols_test.rb +0 -16
- data/test/unit/wlang/parser_test.rb +0 -88
- data/test/unit/wlang/plain_text_dialect_test.rb +0 -21
- data/test/unit/wlang/ruby_dialect_test.rb +0 -100
- data/test/unit/wlang/ruby_expected.rb +0 -3
- data/test/unit/wlang/ruby_template.wrb +0 -3
- data/test/unit/wlang/ruleset_utils_test.rb +0 -245
- data/test/unit/wlang/specification_examples_test.rb +0 -54
- data/test/unit/wlang/test_utils.rb +0 -25
- data/test/unit/wlang/wlang_test.rb +0 -80
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
module WLang
|
3
|
-
class EncoderSet
|
4
|
-
module RedClothEncoders
|
5
|
-
|
6
|
-
# Default encoders
|
7
|
-
DEFAULT_ENCODERS = {"xhtml" => :xhtml_encoding}
|
8
|
-
|
9
|
-
# RDoc encoding
|
10
|
-
def self.xhtml_encoding(src, options)
|
11
|
-
RedCloth.new(src).to_html
|
12
|
-
end
|
13
|
-
|
14
|
-
end # RedClothEncoders
|
15
|
-
end # module EncoderSet
|
16
|
-
end # module WLang
|
@@ -1,118 +0,0 @@
|
|
1
|
-
module WLang
|
2
|
-
class EncoderSet
|
3
|
-
|
4
|
-
# Encoders for ruby
|
5
|
-
module Ruby
|
6
|
-
|
7
|
-
# Default encoders
|
8
|
-
DEFAULT_ENCODERS = {"main-encoding" => :main_encoding,
|
9
|
-
"single-quoting" => :single_quoting,
|
10
|
-
"double-quoting" => :double_quoting,
|
11
|
-
"regex-escaping" => :regex_escaping,
|
12
|
-
"method-case" => :method_case,
|
13
|
-
"literal" => :to_literal}
|
14
|
-
|
15
|
-
# No-op encoding here
|
16
|
-
def self.main_encoding(src, options); src; end
|
17
|
-
|
18
|
-
# Single-quoting encoding
|
19
|
-
def self.single_quoting(src, options); src.gsub(/([^\\])'/,%q{\1\\\'}); end
|
20
|
-
|
21
|
-
# Double-quoting encoding
|
22
|
-
def self.double_quoting(src, options); src.gsub('"','\"'); end
|
23
|
-
|
24
|
-
# Regexp-escaping encoding
|
25
|
-
def self.regex_escaping(src, options); Regexp.escape(src); end
|
26
|
-
|
27
|
-
# Converts any source to a typical ruby method name
|
28
|
-
def self.method_case(src, options)
|
29
|
-
src.strip.gsub(/[^a-zA-Z0-9\s]/," ").
|
30
|
-
gsub(/([A-Z])/){ " " + $1.downcase}.
|
31
|
-
strip.
|
32
|
-
gsub(/^([^a-z])/){ "_" + $1 }.
|
33
|
-
gsub(/\s+/){"_"}
|
34
|
-
end
|
35
|
-
|
36
|
-
# Ruby classes for which value.inspect will work for returning
|
37
|
-
# a valid literal
|
38
|
-
SAFE_LITERAL_CLASSES = {}
|
39
|
-
[NilClass, TrueClass, FalseClass,
|
40
|
-
Fixnum, Bignum,
|
41
|
-
Float,
|
42
|
-
String,
|
43
|
-
Symbol,
|
44
|
-
Class,
|
45
|
-
Module,
|
46
|
-
Regexp].each{|c| SAFE_LITERAL_CLASSES[c] = true}
|
47
|
-
|
48
|
-
#
|
49
|
-
# Converts _value_ to a ruby literal and returns it.
|
50
|
-
#
|
51
|
-
# Behavior of the algorithm when th value cannot be recognized depends
|
52
|
-
# on the :fallback option:
|
53
|
-
# * when set to :fail, it raises a NoSuchLiteralError
|
54
|
-
# * when set to :inspect, it returns <code>value.inspect</code>
|
55
|
-
# * when set to :marshal it uses <code>Marshal::dump(value)</code>
|
56
|
-
# * when set to :json it uses <code>JSON::generate(value)</code>
|
57
|
-
#
|
58
|
-
def self.to_literal(value, options = {:fallback => :fail})
|
59
|
-
if value.respond_to?(:to_ruby_literal)
|
60
|
-
value.to_ruby_literal
|
61
|
-
elsif value.respond_to?(:to_ruby)
|
62
|
-
value.to_ruby
|
63
|
-
elsif value == (1.0/0)
|
64
|
-
return '(1.0/0)'
|
65
|
-
elsif value == -(1.0/0)
|
66
|
-
return '(-1.0/0)'
|
67
|
-
elsif SAFE_LITERAL_CLASSES.key?(value.class)
|
68
|
-
value.inspect
|
69
|
-
elsif value.kind_of?(Array)
|
70
|
-
"[" + value.collect{|v| to_literal(v, options)}.join(', ') + "]"
|
71
|
-
elsif value.kind_of?(Hash)
|
72
|
-
"{" + value.collect{|pair| "#{to_literal(pair[0], options)} => #{to_literal(pair[1], options)}"}.join(', ') + "}"
|
73
|
-
elsif value.kind_of?(Date)
|
74
|
-
"Date::parse(#{value.to_s.inspect})"
|
75
|
-
elsif value.kind_of?(Time)
|
76
|
-
"Time::parse(#{value.inspect.inspect})"
|
77
|
-
else
|
78
|
-
case options[:fallback]
|
79
|
-
when :to_s
|
80
|
-
value.to_s
|
81
|
-
when :inspect
|
82
|
-
value.inspect
|
83
|
-
when :marshal
|
84
|
-
"Marshal::load(#{Marshal::dump(value).inspect})"
|
85
|
-
when :json
|
86
|
-
require 'json'
|
87
|
-
JSON::generate(value)
|
88
|
-
when :fail, nil
|
89
|
-
raise WLang::Error, "Unable to convert #{value.inspect} to a ruby literal"
|
90
|
-
else
|
91
|
-
raise ArgumentError, "Invalid fallback option #{options[:fallback]}"
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
end # module Ruby
|
97
|
-
|
98
|
-
end
|
99
|
-
class RuleSet
|
100
|
-
|
101
|
-
# Defines rulset of the wlang/ruby dialect
|
102
|
-
module Ruby
|
103
|
-
|
104
|
-
# Default mapping between tag symbols and methods
|
105
|
-
DEFAULT_RULESET = {'+' => :inclusion}
|
106
|
-
|
107
|
-
# Rule implementation of <tt>+{wlang/ruby}</tt>.
|
108
|
-
def self.inclusion(parser, offset)
|
109
|
-
expression, reached = parser.parse(offset, "wlang/hosted")
|
110
|
-
value = parser.evaluate(expression)
|
111
|
-
result = WLang::EncoderSet::Ruby.to_literal(value)
|
112
|
-
[result, reached]
|
113
|
-
end
|
114
|
-
|
115
|
-
end # module Ruby
|
116
|
-
|
117
|
-
end # class RuleSet
|
118
|
-
end # module WLang
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module WLang
|
2
|
-
class EncoderSet
|
3
|
-
|
4
|
-
# Encoders for ruby
|
5
|
-
module SQL
|
6
|
-
|
7
|
-
# Default encoders
|
8
|
-
DEFAULT_ENCODERS = {"single-quoting" => :single_quoting}
|
9
|
-
|
10
|
-
# Upcase encoding
|
11
|
-
def self.single_quoting(src, options); src.gsub("'","\\\\'"); end
|
12
|
-
|
13
|
-
end # module SQL
|
14
|
-
|
15
|
-
# Encoders for ruby
|
16
|
-
module SQL::Sybase
|
17
|
-
|
18
|
-
# Default encoders
|
19
|
-
DEFAULT_ENCODERS = {"single-quoting" => :single_quoting}
|
20
|
-
|
21
|
-
# Upcase encoding
|
22
|
-
def self.single_quoting(src, options); src.gsub("'","''"); end
|
23
|
-
|
24
|
-
end # module SQL::Sybase
|
25
|
-
|
26
|
-
end
|
27
|
-
class RuleSet
|
28
|
-
|
29
|
-
# Defines rulset of the wlang/ruby dialect
|
30
|
-
module SQL
|
31
|
-
|
32
|
-
# Default mapping between tag symbols and methods
|
33
|
-
DEFAULT_RULESET = {}
|
34
|
-
|
35
|
-
end # module SQL
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
@@ -1,181 +0,0 @@
|
|
1
|
-
require "wlang/rulesets/basic_ruleset"
|
2
|
-
require "wlang/rulesets/encoding_ruleset"
|
3
|
-
require "wlang/rulesets/imperative_ruleset"
|
4
|
-
require "wlang/rulesets/buffering_ruleset"
|
5
|
-
require "wlang/rulesets/context_ruleset"
|
6
|
-
|
7
|
-
WLang::data_loader(".yml", ".yaml") do |file|
|
8
|
-
require "yaml"
|
9
|
-
YAML.load(File.open(file))
|
10
|
-
end
|
11
|
-
|
12
|
-
WLang::data_loader(".rb", ".ruby", ".dsl") do |file|
|
13
|
-
Kernel.eval(File.read(file))
|
14
|
-
end
|
15
|
-
|
16
|
-
# plain-text dialect
|
17
|
-
WLang::dialect("plain-text") do
|
18
|
-
ruby_require("wlang/dialects/plain_text_dialect") do
|
19
|
-
encoders WLang::EncoderSet::PlainText
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
# ruby dialect
|
24
|
-
WLang::dialect("ruby", ".rb", ".ruby") do
|
25
|
-
ruby_require "wlang/dialects/ruby_dialect" do
|
26
|
-
encoders WLang::EncoderSet::Ruby
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# yaml dialect
|
31
|
-
WLang::dialect("yaml", ".yaml", ".yml") do
|
32
|
-
ruby_require "wlang/dialects/yaml_dialect" do
|
33
|
-
encoders WLang::EncoderSet::YAML
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# sql dialect
|
38
|
-
WLang::dialect("sql", ".sql") do
|
39
|
-
ruby_require "wlang/dialects/sql_dialect" do
|
40
|
-
encoders WLang::EncoderSet::SQL
|
41
|
-
end
|
42
|
-
dialect("sybase", '.sybsql') do
|
43
|
-
ruby_require "wlang/dialects/sql_dialect" do
|
44
|
-
encoders WLang::EncoderSet::SQL::Sybase
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# ruby dialect
|
50
|
-
WLang::dialect("xhtml", ".html", ".xhtml", ".htm") do
|
51
|
-
ruby_require "cgi", "wlang/dialects/xhtml_dialect" do
|
52
|
-
encoders WLang::EncoderSet::XHtml
|
53
|
-
end
|
54
|
-
dialect("coderay") do
|
55
|
-
ruby_require("coderay", "wlang/dialects/coderay_dialect") do
|
56
|
-
encoders WLang::EncoderSet::CodeRayEncoderSet
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# rdoc dialect
|
62
|
-
WLang::dialect("rdoc") do
|
63
|
-
ruby_require "rdoc", "wlang/dialects/rdoc_dialect" do
|
64
|
-
encoders WLang::EncoderSet::RDocEncoders
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# redcloth (textile) dialect
|
69
|
-
WLang::dialect("redcloth") do
|
70
|
-
ruby_require "RedCloth", "wlang/dialects/redcloth_dialect" do
|
71
|
-
encoders WLang::EncoderSet::RedClothEncoders
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# bluecloth (markdown) dialect
|
76
|
-
WLang::dialect("bluecloth") do
|
77
|
-
ruby_require "BlueCloth", "wlang/dialects/bluecloth_dialect" do
|
78
|
-
encoders WLang::EncoderSet::BlueClothEncoders
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# wlang dialects
|
83
|
-
WLang::dialect("wlang") do
|
84
|
-
|
85
|
-
# Dummy dialect, no tag at all
|
86
|
-
dialect("dummy") do
|
87
|
-
end
|
88
|
-
|
89
|
-
# wlang/ruby dialect
|
90
|
-
dialect("hosted") do
|
91
|
-
ruby_require "wlang/dialects/hosted_dialect" do
|
92
|
-
encoders WLang::EncoderSet::Hosted
|
93
|
-
rules WLang::RuleSet::Basic
|
94
|
-
rules WLang::RuleSet::Encoding
|
95
|
-
rules WLang::RuleSet::Imperative
|
96
|
-
rules WLang::RuleSet::Context
|
97
|
-
rules WLang::RuleSet::Hosted
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
# wlang/active-string dialect
|
102
|
-
dialect("active-string") do
|
103
|
-
rules WLang::RuleSet::Basic
|
104
|
-
rules WLang::RuleSet::Imperative
|
105
|
-
end
|
106
|
-
|
107
|
-
# wlang/active-text dialect
|
108
|
-
dialect("active-text") do
|
109
|
-
rules WLang::RuleSet::Basic
|
110
|
-
rules WLang::RuleSet::Imperative
|
111
|
-
rules WLang::RuleSet::Buffering
|
112
|
-
rules WLang::RuleSet::Context
|
113
|
-
end
|
114
|
-
|
115
|
-
# wlang/uri dialect
|
116
|
-
dialect("uri") do
|
117
|
-
rules WLang::RuleSet::Basic
|
118
|
-
end
|
119
|
-
|
120
|
-
# wlang/ruby dialect
|
121
|
-
dialect("ruby", ".wrb", ".wruby") do
|
122
|
-
ruby_require "wlang/dialects/ruby_dialect" do
|
123
|
-
encoders WLang::EncoderSet::Ruby
|
124
|
-
rules WLang::RuleSet::Basic
|
125
|
-
rules WLang::RuleSet::Encoding
|
126
|
-
rules WLang::RuleSet::Imperative
|
127
|
-
rules WLang::RuleSet::Buffering
|
128
|
-
rules WLang::RuleSet::Context
|
129
|
-
rules WLang::RuleSet::Ruby
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
# wlang/ruby dialect
|
134
|
-
dialect("yaml", ".wyaml", ".wyml") do
|
135
|
-
ruby_require "wlang/dialects/yaml_dialect" do
|
136
|
-
encoders WLang::EncoderSet::YAML
|
137
|
-
rules WLang::RuleSet::Basic
|
138
|
-
rules WLang::RuleSet::Encoding
|
139
|
-
rules WLang::RuleSet::Imperative
|
140
|
-
rules WLang::RuleSet::Buffering
|
141
|
-
rules WLang::RuleSet::Context
|
142
|
-
rules WLang::RuleSet::YAML
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
# wlang/ruby dialect
|
147
|
-
dialect("xhtml", ".wtpl", ".whtml") do
|
148
|
-
ruby_require "cgi", "wlang/dialects/xhtml_dialect" do
|
149
|
-
encoders WLang::EncoderSet::XHtml
|
150
|
-
rules WLang::RuleSet::Basic
|
151
|
-
rules WLang::RuleSet::Encoding
|
152
|
-
rules WLang::RuleSet::Imperative
|
153
|
-
rules WLang::RuleSet::Buffering
|
154
|
-
rules WLang::RuleSet::Context
|
155
|
-
rules WLang::RuleSet::XHtml
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
# wlang/ruby dialect
|
160
|
-
dialect("sql", ".wsql") do
|
161
|
-
ruby_require "wlang/dialects/sql_dialect" do
|
162
|
-
encoders WLang::EncoderSet::SQL
|
163
|
-
rules WLang::RuleSet::Basic
|
164
|
-
rules WLang::RuleSet::Encoding
|
165
|
-
rules WLang::RuleSet::Imperative
|
166
|
-
rules WLang::RuleSet::SQL
|
167
|
-
end
|
168
|
-
|
169
|
-
dialect("sybase") do
|
170
|
-
ruby_require "wlang/dialects/sql_dialect" do
|
171
|
-
encoders WLang::EncoderSet::SQL
|
172
|
-
encoders WLang::EncoderSet::SQL::Sybase
|
173
|
-
rules WLang::RuleSet::Basic
|
174
|
-
rules WLang::RuleSet::Encoding
|
175
|
-
rules WLang::RuleSet::Imperative
|
176
|
-
rules WLang::RuleSet::SQL
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
module WLang
|
3
|
-
class EncoderSet
|
4
|
-
|
5
|
-
# Defines encoders of the whtml dialect
|
6
|
-
module XHtml
|
7
|
-
|
8
|
-
# Default encoders
|
9
|
-
DEFAULT_ENCODERS = {"main-encoding" => :entities_encoding,
|
10
|
-
"single-quoting" => :single_quoting,
|
11
|
-
"double-quoting" => :double_quoting,
|
12
|
-
"entities-encoding" => :entities_encoding}
|
13
|
-
|
14
|
-
|
15
|
-
# Single-quoting encoding
|
16
|
-
def self.single_quoting(src, options); src.gsub(/([^\\])'/,%q{\1\\\'}); end
|
17
|
-
|
18
|
-
# Double-quoting encoding
|
19
|
-
def self.double_quoting(src, options); src.gsub('"','\"'); end
|
20
|
-
|
21
|
-
# Entities-encoding
|
22
|
-
def self.entities_encoding(src, options);
|
23
|
-
CGI::escapeHTML(src)
|
24
|
-
end
|
25
|
-
|
26
|
-
end # module XHtml
|
27
|
-
end
|
28
|
-
class RuleSet
|
29
|
-
|
30
|
-
# Defines rulset of the wlang/xhtml dialect
|
31
|
-
module XHtml
|
32
|
-
|
33
|
-
# Default mapping between tag symbols and methods
|
34
|
-
DEFAULT_RULESET = {'@' => :at}
|
35
|
-
|
36
|
-
def self.at(parser, offset)
|
37
|
-
# parse the url
|
38
|
-
url, reached = parser.parse(offset, 'wlang/active-string')
|
39
|
-
url = WLang::encode(url, 'wlang/xhtml/double-quoting')
|
40
|
-
|
41
|
-
# parse the label if there is one
|
42
|
-
label = nil
|
43
|
-
if parser.has_block?(reached)
|
44
|
-
label, reached = parser.parse_block(reached)
|
45
|
-
label = WLang::encode(label, 'wlang/xhtml/entities-encoding')
|
46
|
-
end
|
47
|
-
|
48
|
-
if label and url.respond_to?(:to_xhtml_link)
|
49
|
-
[url.to_xhtml_link(url, label), reached]
|
50
|
-
elsif url.respond_to?(:to_xhtml_href)
|
51
|
-
[url.to_xhtml_href(url), reached]
|
52
|
-
elsif label
|
53
|
-
["<a href=\"#{url}\">#{label}</a>", reached]
|
54
|
-
else
|
55
|
-
[url, reached]
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
end # module XHtml
|
60
|
-
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require "yaml"
|
2
|
-
module WLang
|
3
|
-
class EncoderSet
|
4
|
-
module YAML
|
5
|
-
|
6
|
-
# Default encoders
|
7
|
-
DEFAULT_ENCODERS = {}
|
8
|
-
|
9
|
-
end # module YAML
|
10
|
-
end
|
11
|
-
class RuleSet
|
12
|
-
module YAML
|
13
|
-
|
14
|
-
# Default mapping between tag symbols and methods
|
15
|
-
DEFAULT_RULESET = {'+' => :inclusion}
|
16
|
-
|
17
|
-
# Rule implementation of <tt>+{wlang/ruby}</tt>.
|
18
|
-
def self.inclusion(parser, offset)
|
19
|
-
expression, reached = parser.parse(offset, "wlang/hosted")
|
20
|
-
value = parser.evaluate(expression)
|
21
|
-
col = parser.buffer.__wlang_column_of(parser.buffer.length)
|
22
|
-
result = value.to_yaml.
|
23
|
-
gsub(/^\s*---\s*|\n$/,"").
|
24
|
-
__wlang_realign(col-1, true)
|
25
|
-
[result, reached]
|
26
|
-
end
|
27
|
-
|
28
|
-
end # module YAML
|
29
|
-
end # class RuleSet
|
30
|
-
end # module WLang
|