wlang 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENCE.rdoc +25 -0
- data/README.rdoc +111 -0
- data/bin/wlang +24 -0
- data/doc/specification/about.rdoc +61 -0
- data/doc/specification/dialects.wtpl +0 -0
- data/doc/specification/examples.rb +3 -0
- data/doc/specification/glossary.wtpl +14 -0
- data/doc/specification/hosting.rdoc +0 -0
- data/doc/specification/overview.rdoc +116 -0
- data/doc/specification/rulesets.wtpl +87 -0
- data/doc/specification/specification.css +52 -0
- data/doc/specification/specification.html +1361 -0
- data/doc/specification/specification.js +8 -0
- data/doc/specification/specification.wtpl +41 -0
- data/doc/specification/specification.yml +430 -0
- data/doc/specification/symbols.wtpl +16 -0
- data/lib/wlang.rb +186 -0
- data/lib/wlang/basic_object.rb +19 -0
- data/lib/wlang/dialect.rb +230 -0
- data/lib/wlang/dialect_dsl.rb +136 -0
- data/lib/wlang/dialect_loader.rb +69 -0
- data/lib/wlang/dialects/coderay_dialect.rb +35 -0
- data/lib/wlang/dialects/plain_text_dialect.rb +75 -0
- data/lib/wlang/dialects/rdoc_dialect.rb +33 -0
- data/lib/wlang/dialects/ruby_dialect.rb +35 -0
- data/lib/wlang/dialects/sql_dialect.rb +38 -0
- data/lib/wlang/dialects/standard_dialects.rb +113 -0
- data/lib/wlang/dialects/xhtml_dialect.rb +40 -0
- data/lib/wlang/encoder.rb +66 -0
- data/lib/wlang/encoder_set.rb +117 -0
- data/lib/wlang/errors.rb +37 -0
- data/lib/wlang/intelligent_buffer.rb +94 -0
- data/lib/wlang/parser.rb +251 -0
- data/lib/wlang/parser_context.rb +146 -0
- data/lib/wlang/ruby_extensions.rb +21 -0
- data/lib/wlang/rule.rb +66 -0
- data/lib/wlang/rule_set.rb +93 -0
- data/lib/wlang/rulesets/basic_ruleset.rb +75 -0
- data/lib/wlang/rulesets/buffering_ruleset.rb +103 -0
- data/lib/wlang/rulesets/context_ruleset.rb +115 -0
- data/lib/wlang/rulesets/encoding_ruleset.rb +73 -0
- data/lib/wlang/rulesets/imperative_ruleset.rb +132 -0
- data/lib/wlang/rulesets/ruleset_utils.rb +296 -0
- data/lib/wlang/template.rb +79 -0
- data/lib/wlang/wlang_command.rb +54 -0
- data/lib/wlang/wlang_command_options.rb +158 -0
- data/test/sandbox.rb +1 -0
- data/test/test_all.rb +8 -0
- data/test/wlang/anagram_bugs_test.rb +111 -0
- data/test/wlang/basic_ruleset_test.rb +52 -0
- data/test/wlang/buffering_ruleset_test.rb +102 -0
- data/test/wlang/buffering_template1.wtpl +1 -0
- data/test/wlang/buffering_template2.wtpl +1 -0
- data/test/wlang/buffering_template3.wtpl +1 -0
- data/test/wlang/buffering_template4.wtpl +1 -0
- data/test/wlang/buffering_template5.wtpl +1 -0
- data/test/wlang/context_ruleset_test.rb +32 -0
- data/test/wlang/data.rb +3 -0
- data/test/wlang/encoder_set_test.rb +42 -0
- data/test/wlang/imperative_ruleset_test.rb +107 -0
- data/test/wlang/intelligent_buffer_test.rb +194 -0
- data/test/wlang/othersymbols_test.rb +16 -0
- data/test/wlang/parser_context_test.rb +29 -0
- data/test/wlang/parser_test.rb +89 -0
- data/test/wlang/plain_text_dialect_test.rb +21 -0
- data/test/wlang/ruby_dialect_test.rb +100 -0
- data/test/wlang/ruby_expected.rb +3 -0
- data/test/wlang/ruby_template.wrb +3 -0
- data/test/wlang/ruleset_utils_test.rb +245 -0
- data/test/wlang/specification_examples_test.rb +52 -0
- data/test/wlang/test_utils.rb +25 -0
- data/test/wlang/wlang_test.rb +80 -0
- metadata +136 -0
@@ -0,0 +1,136 @@
|
|
1
|
+
module WLang
|
2
|
+
class Dialect
|
3
|
+
|
4
|
+
#
|
5
|
+
# Installs the Domain Specific Language allowing to create new dialects easily.
|
6
|
+
# Below is a self-explaining example on how to use it.
|
7
|
+
#
|
8
|
+
# #
|
9
|
+
# # Starts a new _wlang_ dialect that will have children.
|
10
|
+
# #
|
11
|
+
# WLang::dialect("wlang") do
|
12
|
+
#
|
13
|
+
# #
|
14
|
+
# # Starts a _wlang/xhtml_ dialect that will be attached to .wtpl and .whtml
|
15
|
+
# # file extensions.
|
16
|
+
# #
|
17
|
+
# dialect("xhtml", ".wtpl", ".whtm") do
|
18
|
+
#
|
19
|
+
# # If your dialect needs external gems or files, use ruby_require instead
|
20
|
+
# # of built-in require: it will allow avoiding all users to have required
|
21
|
+
# # dependencies for dialects they don't use.
|
22
|
+
# ruby_require "somegem", "wlang/rulesets/basic_ruleset", "wlang/dialects/coderay_dialect" do
|
23
|
+
#
|
24
|
+
# # RuleSet defined as Ruby modules can be installed using _rules_.
|
25
|
+
# # Here: we automatically add the standard Basic ruleset to our dialect.
|
26
|
+
# rules WLang::RuleSet::Basic
|
27
|
+
#
|
28
|
+
# # You can also install inline rules if they are not designed to be
|
29
|
+
# # reusable by others.
|
30
|
+
# # Here, we add a #{...} rule that replaces all spaces by '#' symbols
|
31
|
+
# # For rule implementation, see Rule class.
|
32
|
+
# rule "#" do |parser, offset|
|
33
|
+
# text, reached = parser.parse(offset)
|
34
|
+
# text = text.gsub(/\s/, '#')
|
35
|
+
# [text, reached]
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# # Encoders can be installed the same way(s)
|
39
|
+
# # Here: we install all coderay encoders defined in a module
|
40
|
+
# encoders WLang::EncoderSet::CodeRay
|
41
|
+
#
|
42
|
+
# # And inline encoders can be installed as well
|
43
|
+
# # Encoder below will be allowed as ^{wlang/xhtml/upcase}{...} for example
|
44
|
+
# encoder 'upcase' do |src, options|
|
45
|
+
# src.upcase
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# end # ruby_require
|
49
|
+
#
|
50
|
+
# end # wlang/xhtml dialect
|
51
|
+
#
|
52
|
+
# end # wlang dialect
|
53
|
+
#
|
54
|
+
class DSL
|
55
|
+
|
56
|
+
# Initializes dsl with a real dialect instance
|
57
|
+
def initialize(dialect)
|
58
|
+
raise(ArgumentError, "Dialect expected") unless WLang::Dialect===dialect
|
59
|
+
@dialect = dialect
|
60
|
+
end
|
61
|
+
|
62
|
+
#
|
63
|
+
# Handles dialect dependencies: all _src_ dependencies will be correctly loaded
|
64
|
+
# at dialect building time (dialect are lazy loaded to avoid having all users
|
65
|
+
# to have all dependencies of standard dialects).
|
66
|
+
#
|
67
|
+
# This method should always be used instead of _require_. It takes a block that
|
68
|
+
# will be executed at building-time. Any code with dependency usage should be
|
69
|
+
# part of the block !
|
70
|
+
#
|
71
|
+
def ruby_require(*src) end
|
72
|
+
|
73
|
+
#
|
74
|
+
# Starts definition of a sub-dialect of the current one. _name_ is not allowed
|
75
|
+
# to be a qualified name. _extensions_ allows wlang to automatically infer
|
76
|
+
# dialects used by template files. A block is expected and should contain
|
77
|
+
# sub-dialect installation.
|
78
|
+
#
|
79
|
+
def dialect(name, *extensions, &block)
|
80
|
+
child = WLang::Dialect.new(name, @dialect, &block)
|
81
|
+
extensions.each do |ext|
|
82
|
+
ext = ('.' << ext) unless ext[0,1]=='.'
|
83
|
+
WLang::FILE_EXTENSIONS[ext] = child.qualified_name
|
84
|
+
end
|
85
|
+
@dialect.add_child_dialect(name, child)
|
86
|
+
end
|
87
|
+
|
88
|
+
#
|
89
|
+
# Adds a dialect encoder under _name_. Encoder's code is provided by the block.
|
90
|
+
# This block should always take <tt>|src, options|</tt> arguments: _src_ is
|
91
|
+
# the string to encode, _options_ is a Hash instance containing additional
|
92
|
+
# encoding options.
|
93
|
+
#
|
94
|
+
def encoder(name, &block) end
|
95
|
+
|
96
|
+
#
|
97
|
+
# Adds reusable encoders defined in a Ruby module. _mod_ must be a Module instance.
|
98
|
+
# If _pairs_ is ommitted (nil), all encoders of the module are added, under their
|
99
|
+
# standard names (see DEFAULT_ENCODERS under WLang::EncoderSet::XHtml for example).
|
100
|
+
# Otherwise, _pairs_ is expected to be a Hash providing a mapping between encoder
|
101
|
+
# names and _mod_ methods (whose names are given by ruby symbols).
|
102
|
+
#
|
103
|
+
def encoders(mod, pairs=nil) end
|
104
|
+
|
105
|
+
#
|
106
|
+
# Maps an inline rule with some tag symbols. _symbol_ must be ASCII symbols
|
107
|
+
# allowed by the wlang specification. The rule implementation is provided by
|
108
|
+
# the block. see Rule class about rule implementation.
|
109
|
+
#
|
110
|
+
def rule(symbol, &block) end
|
111
|
+
|
112
|
+
#
|
113
|
+
# Adds reusable rules defined in a Ruby module. _mod_ must be a Module instance.
|
114
|
+
# If _pairs_ is ommitted (nil), all rules of the module are added, under their
|
115
|
+
# standard tag symbols (see DEFAULT_RULESET under WLang::RuleSet::Basic for example).
|
116
|
+
# Otherwise, _pairs_ is expected to be a Hash providing a mapping between tag
|
117
|
+
# symbols and _mod_ methods (whose names are given by ruby symbols).
|
118
|
+
#
|
119
|
+
def rules(mod, pairs=nil) end
|
120
|
+
|
121
|
+
#
|
122
|
+
# Request wlang to associate _args_ files extensions with this dialect. File
|
123
|
+
# extensions may also be installed at construction (see dialect).
|
124
|
+
#
|
125
|
+
def extensions(*args)
|
126
|
+
args.each do |ext|
|
127
|
+
ext = ('.' << ext) unless ext[0,1]=='.'
|
128
|
+
WLang::FILE_EXTENSIONS[ext] = @dialect.qualified_name
|
129
|
+
end
|
130
|
+
end
|
131
|
+
alias :extension :extensions
|
132
|
+
|
133
|
+
end # class DSL
|
134
|
+
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module WLang
|
2
|
+
class Dialect
|
3
|
+
|
4
|
+
#
|
5
|
+
# Implements the same API as WLang::Dialect::DSL but used for effective loading.
|
6
|
+
# This class exists because of the lazy loading design pattern implemented by
|
7
|
+
# wlang on dialects. It does not convey any user-centric information.
|
8
|
+
#
|
9
|
+
class Loader
|
10
|
+
|
11
|
+
# Initializes dsl with a real dialect instance
|
12
|
+
def initialize(dialect)
|
13
|
+
@dialect = dialect
|
14
|
+
end
|
15
|
+
|
16
|
+
# See WLang::Dialect::DSL#ruby_require
|
17
|
+
def ruby_require(*src)
|
18
|
+
src.each do |s|
|
19
|
+
begin
|
20
|
+
require "rubygems" unless "wlang"==s[0,5]
|
21
|
+
rescue LoadError => ex
|
22
|
+
STDERR.puts "= Error, wlang depends on 'rubygems'\n"\
|
23
|
+
"= Please install it (methods differs from system, in debian : 'apt-get install rubygems')\n"\
|
24
|
+
"= Exception raised : '#{ex.message}'"
|
25
|
+
exit -1
|
26
|
+
end
|
27
|
+
begin
|
28
|
+
require s
|
29
|
+
rescue LoadError => ex
|
30
|
+
STDERR.puts "= Error in dialect '#{@dialect}'\n"\
|
31
|
+
"= This dialect depends on gem or file '#{s}' (try: 'gem install #{s}')\n"\
|
32
|
+
"= Exception raised : '#{ex.message}'"
|
33
|
+
exit -1
|
34
|
+
end
|
35
|
+
end
|
36
|
+
yield if block_given?
|
37
|
+
end
|
38
|
+
|
39
|
+
# See WLang::Dialect::DSL#dialect
|
40
|
+
def dialect(name, *extensions, &block) end
|
41
|
+
|
42
|
+
# See WLang::Dialect::DSL#encoder
|
43
|
+
def encoder(name, &block)
|
44
|
+
@dialect.add_encoder(name, &block)
|
45
|
+
end
|
46
|
+
|
47
|
+
# See WLang::Dialect::DSL#encoders
|
48
|
+
def encoders(mod, pairs=nil)
|
49
|
+
@dialect.add_encoders(mod, pairs)
|
50
|
+
end
|
51
|
+
|
52
|
+
# See WLang::Dialect::DSL#rule
|
53
|
+
def rule(symbol, &block)
|
54
|
+
@dialect.add_rule(symbol, &block)
|
55
|
+
end
|
56
|
+
|
57
|
+
# See WLang::Dialect::DSL#rules
|
58
|
+
def rules(mod, pairs=nil)
|
59
|
+
@dialect.add_rules(mod, pairs)
|
60
|
+
end
|
61
|
+
|
62
|
+
# See WLang::Dialect::DSL#extensions
|
63
|
+
def extensions(*args) end
|
64
|
+
alias :extension :extensions
|
65
|
+
|
66
|
+
end # class Loader
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'coderay'
|
2
|
+
module WLang
|
3
|
+
class EncoderSet
|
4
|
+
|
5
|
+
#
|
6
|
+
# Allows coderay highlighter to be used as encoder. When using standard dialects,
|
7
|
+
# these encoders are installed under <tt>xhtml/coderay/ruby</tt>,
|
8
|
+
# <tt>xhtml/coderay/html</tt>, etc. qualified names.
|
9
|
+
#
|
10
|
+
# Available languages are: java, ruby, html, yaml.
|
11
|
+
#
|
12
|
+
module CodeRayEncoderSet
|
13
|
+
|
14
|
+
# Default encoders
|
15
|
+
DEFAULT_ENCODERS = {"java" => :coderay, "ruby" => :coderay, "html" => :coderay,
|
16
|
+
"yaml" => :coderay}
|
17
|
+
|
18
|
+
# Upcase encoding
|
19
|
+
def self.coderay(src, options);
|
20
|
+
/([a-z]+)$/ =~ options['_encoder_']
|
21
|
+
encoder = $1.to_sym
|
22
|
+
tokens = CodeRay.scan src, encoder
|
23
|
+
highlighted = tokens.html({
|
24
|
+
:line_numbers => :inline,
|
25
|
+
:wrap => :div,
|
26
|
+
:css => :style,
|
27
|
+
:style => :cygnus}
|
28
|
+
)
|
29
|
+
return highlighted
|
30
|
+
end
|
31
|
+
|
32
|
+
end # module CodeRay
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module WLang
|
2
|
+
class EncoderSet
|
3
|
+
|
4
|
+
# Defines encoders of the plain-text dialect
|
5
|
+
module PlainText
|
6
|
+
|
7
|
+
# Default encoders
|
8
|
+
DEFAULT_ENCODERS = {"upcase" => :upcase,
|
9
|
+
"downcase" => :downcase,
|
10
|
+
"capitalize" => :capitalize,
|
11
|
+
"camel-case" => :camel_case}
|
12
|
+
|
13
|
+
# Accents to replace when camel-casing
|
14
|
+
# ACCENTS = { ['á','à','â','ä','ã','Ã','Ä','Â','À'] => 'a',
|
15
|
+
# ['é','è','ê','ë','Ë','É','È','Ê'] => 'e',
|
16
|
+
# ['í','ì','î','ï','I','Î','Ì'] => 'i',
|
17
|
+
# ['ó','ò','ô','ö','õ','Õ','Ö','Ô','Ò'] => 'o',
|
18
|
+
# ['œ'] => 'oe',
|
19
|
+
# ['ß'] => 'ss',
|
20
|
+
# ['ú','ù','û','ü','U','Û','Ù'] => 'u'}
|
21
|
+
|
22
|
+
# Upcase encoding
|
23
|
+
def self.upcase(src, options); src.upcase; end
|
24
|
+
|
25
|
+
# Downcase encoding
|
26
|
+
def self.downcase(src, options); src.downcase; end
|
27
|
+
|
28
|
+
# Capitalize encoding
|
29
|
+
def self.capitalize(src, options); src.capitalize; end
|
30
|
+
|
31
|
+
# Converts a string as CamelCase
|
32
|
+
def self.camel_case(src, options)
|
33
|
+
# ACCENTS.each do |ac,rep|
|
34
|
+
# ac.each do |s|
|
35
|
+
# src.gsub!(s, rep)
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
src.gsub!(/[^a-zA-Z ]/," ")
|
39
|
+
src = " " + src.split.join(" ")
|
40
|
+
src.gsub!(/ (.)/) { $1.upcase }
|
41
|
+
end
|
42
|
+
|
43
|
+
end # module PlainText
|
44
|
+
|
45
|
+
end
|
46
|
+
class RuleSet
|
47
|
+
|
48
|
+
# Defines rulset of the plain-text dialect
|
49
|
+
module PlainText
|
50
|
+
|
51
|
+
# Default mapping between tag symbols and methods
|
52
|
+
DEFAULT_RULESET = {'+' => :upcase, '-' => :downcase}
|
53
|
+
|
54
|
+
# Upcase rule as <tt>+{wlang/hosted}</tt>
|
55
|
+
def self.upcase(parser, offset)
|
56
|
+
expression, reached = parser.parse(offset, "wlang/ruby")
|
57
|
+
value = parser.evaluate(expression)
|
58
|
+
value = value.nil? ? "" : value.to_s
|
59
|
+
result = WLang::EncoderSet::PlainText.upcase(value)
|
60
|
+
[result, reached]
|
61
|
+
end
|
62
|
+
|
63
|
+
# Downcase rule as <tt>-{wlang/hosted}</tt>
|
64
|
+
def self.downcase(parser, offset)
|
65
|
+
expression, reached = parser.parse(offset, "wlang/ruby")
|
66
|
+
value = parser.evaluate(expression)
|
67
|
+
value = value.nil? ? "" : value.to_s
|
68
|
+
result = EncoderSet::PlainText.downcase(value)
|
69
|
+
[result, reached]
|
70
|
+
end
|
71
|
+
|
72
|
+
end # module PlainText
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rdoc/markup/to_html'
|
3
|
+
module WLang
|
4
|
+
class EncoderSet
|
5
|
+
|
6
|
+
# Provides the rdoc encoder
|
7
|
+
module RDocEncoders
|
8
|
+
|
9
|
+
# Default encoders
|
10
|
+
DEFAULT_ENCODERS = {"html" => :rdoc_encoding, "div" => :rdoc_encoding, "nop" => :nop_encoding}
|
11
|
+
|
12
|
+
# RDoc encoding
|
13
|
+
def self.rdoc_encoding(src, options);
|
14
|
+
encoder = RDoc::Markup::ToHtml.new
|
15
|
+
if options['_template_'] and options['_template_'].source_file
|
16
|
+
encoder.instance_eval do
|
17
|
+
@from_path = File.dirname(options['_template_'].source_file)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
encoder.convert(src)
|
21
|
+
end
|
22
|
+
|
23
|
+
# RDoc encoding, removing enclosing <tt><p>...</p></tt>
|
24
|
+
def self.nop_encoding(src, options);
|
25
|
+
rdoc = RDoc::Markup::ToHtml.new.convert(src)
|
26
|
+
rdoc = $1 if /^\s*<p>\s*(.*?)\s+<\/p>\s*$/m =~ rdoc
|
27
|
+
rdoc
|
28
|
+
end
|
29
|
+
|
30
|
+
end # RDoc
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module WLang
|
2
|
+
class EncoderSet
|
3
|
+
|
4
|
+
# Encoders for ruby
|
5
|
+
module Ruby
|
6
|
+
|
7
|
+
# Default encoders
|
8
|
+
DEFAULT_ENCODERS = {"single-quoting" => :single_quoting,
|
9
|
+
"double-quoting" => :double_quoting,
|
10
|
+
"regex-escaping" => :regex_escaping}
|
11
|
+
|
12
|
+
# Single-quoting encoding
|
13
|
+
def self.single_quoting(src, options); src.gsub(/([^\\])'/,%q{\1\\\'}); end
|
14
|
+
|
15
|
+
# Double-quoting encoding
|
16
|
+
def self.double_quoting(src, options); src.gsub('"','\"'); end
|
17
|
+
|
18
|
+
# Regexp-escaping encoding
|
19
|
+
def self.regex_escaping(src, options); Regexp.escape(src); end
|
20
|
+
|
21
|
+
end # module Ruby
|
22
|
+
|
23
|
+
end
|
24
|
+
class RuleSet
|
25
|
+
|
26
|
+
# Defines rulset of the wlang/ruby dialect
|
27
|
+
module Ruby
|
28
|
+
|
29
|
+
# Default mapping between tag symbols and methods
|
30
|
+
DEFAULT_RULESET = {}
|
31
|
+
|
32
|
+
end # module Ruby
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,38 @@
|
|
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
|
@@ -0,0 +1,113 @@
|
|
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
|
+
# ruby dialect
|
31
|
+
WLang::dialect("xhtml", ".html", ".xhtml", ".htm") do
|
32
|
+
ruby_require "cgi", "wlang/dialects/xhtml_dialect" do
|
33
|
+
encoders WLang::EncoderSet::XHtml
|
34
|
+
end
|
35
|
+
dialect("coderay") do
|
36
|
+
ruby_require("coderay", "wlang/dialects/coderay_dialect") do
|
37
|
+
encoders WLang::EncoderSet::CodeRayEncoderSet
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# rdoc dialect
|
43
|
+
WLang::dialect("rdoc") do
|
44
|
+
ruby_require "rdoc", "wlang/dialects/rdoc_dialect" do
|
45
|
+
encoders WLang::EncoderSet::RDocEncoders
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# wlang dialects
|
50
|
+
WLang::dialect("wlang") do
|
51
|
+
|
52
|
+
# Dummy dialect, no tag at all
|
53
|
+
dialect("dummy") do
|
54
|
+
end
|
55
|
+
|
56
|
+
# wlang/active-string dialect
|
57
|
+
dialect("active-string") do
|
58
|
+
rules WLang::RuleSet::Basic
|
59
|
+
end
|
60
|
+
|
61
|
+
# wlang/uri dialect
|
62
|
+
dialect("uri") do
|
63
|
+
rules WLang::RuleSet::Basic
|
64
|
+
end
|
65
|
+
|
66
|
+
# wlang/ruby dialect
|
67
|
+
dialect("ruby", ".wrb", ".wruby") do
|
68
|
+
ruby_require "wlang/dialects/ruby_dialect" do
|
69
|
+
encoders WLang::EncoderSet::Ruby
|
70
|
+
rules WLang::RuleSet::Basic
|
71
|
+
rules WLang::RuleSet::Encoding
|
72
|
+
rules WLang::RuleSet::Imperative
|
73
|
+
rules WLang::RuleSet::Context
|
74
|
+
rules WLang::RuleSet::Ruby
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# wlang/ruby dialect
|
79
|
+
dialect("xhtml", ".wtpl", ".whtml") do
|
80
|
+
ruby_require "cgi", "wlang/dialects/xhtml_dialect" do
|
81
|
+
encoders WLang::EncoderSet::XHtml
|
82
|
+
rules WLang::RuleSet::Basic
|
83
|
+
rules WLang::RuleSet::Encoding
|
84
|
+
rules WLang::RuleSet::Imperative
|
85
|
+
rules WLang::RuleSet::Buffering
|
86
|
+
rules WLang::RuleSet::Context
|
87
|
+
rules WLang::RuleSet::XHtml
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# wlang/ruby dialect
|
92
|
+
dialect("sql", ".wsql") do
|
93
|
+
ruby_require "wlang/dialects/sql_dialect" do
|
94
|
+
encoders WLang::EncoderSet::SQL
|
95
|
+
rules WLang::RuleSet::Basic
|
96
|
+
rules WLang::RuleSet::Encoding
|
97
|
+
rules WLang::RuleSet::Imperative
|
98
|
+
rules WLang::RuleSet::SQL
|
99
|
+
end
|
100
|
+
|
101
|
+
dialect("sybase") do
|
102
|
+
ruby_require "wlang/dialects/sql_dialect" do
|
103
|
+
encoders WLang::EncoderSet::SQL
|
104
|
+
encoders WLang::EncoderSet::SQL::Sybase
|
105
|
+
rules WLang::RuleSet::Basic
|
106
|
+
rules WLang::RuleSet::Encoding
|
107
|
+
rules WLang::RuleSet::Imperative
|
108
|
+
rules WLang::RuleSet::SQL
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|