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,8 +0,0 @@
|
|
1
|
-
var current = 'about'
|
2
|
-
function show(who) {
|
3
|
-
document.getElementById(current).style.display = "none";
|
4
|
-
document.getElementById(current + 'focus').className = "unfocus";
|
5
|
-
document.getElementById(who).style.display = "block";
|
6
|
-
document.getElementById(who + 'focus').className = "focus";
|
7
|
-
current = who;
|
8
|
-
}
|
@@ -1,42 +0,0 @@
|
|
1
|
-
<<={specification.yml as spec}
|
2
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
-
<head>
|
5
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
6
|
-
<title>${spec.title} (version ${spec.version})</title>
|
7
|
-
<style type="text/css">
|
8
|
-
<<{specification.css}
|
9
|
-
</style>
|
10
|
-
<script type="text/javascript" language="JavaScript"><!--
|
11
|
-
<<{specification.js}
|
12
|
-
//--></script>
|
13
|
-
</head>
|
14
|
-
<body onload="show('about')">
|
15
|
-
<h1 id="title">${spec.title} (version ${spec.version})</h1>
|
16
|
-
<ul id="tabs">
|
17
|
-
*{spec.sections.reverse as section}{
|
18
|
-
<li id="+{section.identifier}focus" onclick="show('{section.identifier}')">${section.name}</li>
|
19
|
-
}
|
20
|
-
</ul>
|
21
|
-
<div class="clear"></div>
|
22
|
-
*{spec.sections as section}{
|
23
|
-
<div id="{section.identifier}" style="display: none;">
|
24
|
-
<div class="header">
|
25
|
-
<h2>${section.name}</h2>
|
26
|
-
?{section.links}{
|
27
|
-
<ul class="links">
|
28
|
-
*{+{section.links} as link}{<li><a href="#${link.name}">${link.name}</a></li>}
|
29
|
-
</ul>
|
30
|
-
}
|
31
|
-
<div class="clear"></div>
|
32
|
-
</div>
|
33
|
-
?{/rdoc$/ =~ "{section.file}"}{
|
34
|
-
^{rdoc/div}{<<{+{section.file}}}
|
35
|
-
}{
|
36
|
-
<<+{+{section.file} with spec: spec}
|
37
|
-
}
|
38
|
-
</div>
|
39
|
-
}
|
40
|
-
<<{analytics.wtpl}
|
41
|
-
</body>
|
42
|
-
</html>
|
@@ -1,432 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: WLang
|
3
|
-
version: 0.10.1
|
4
|
-
sections:
|
5
|
-
- identifier: about
|
6
|
-
name: About
|
7
|
-
file: about.rdoc
|
8
|
-
- identifier: overview
|
9
|
-
name: Overview
|
10
|
-
file: overview.rdoc
|
11
|
-
- identifier: rulesets
|
12
|
-
name: Rulesets
|
13
|
-
file: rulesets.wtpl
|
14
|
-
links: 'spec["rulesets"].reverse'
|
15
|
-
- identifier: dialects
|
16
|
-
name: Dialects
|
17
|
-
file: dialects.wtpl
|
18
|
-
- identifier: hosting
|
19
|
-
name: Hosting language
|
20
|
-
file: hosting.rdoc
|
21
|
-
- identifier: glossary
|
22
|
-
name: Glossary
|
23
|
-
file: glossary.wtpl
|
24
|
-
- identifier: symbols
|
25
|
-
name: Tag symbols
|
26
|
-
file: symbols.wtpl
|
27
|
-
glossary:
|
28
|
-
- term: template
|
29
|
-
definition: |-
|
30
|
-
Source code respecting the wlang grammar, and attached to a given <em>wlang
|
31
|
-
dialect</em>.
|
32
|
-
example: |-
|
33
|
-
<tt>Hello ${name}</tt>
|
34
|
-
- term: dialect
|
35
|
-
definition: |-
|
36
|
-
Basically, <em>dialect</em> is used as a synonym for (programming) <em>language</em>.
|
37
|
-
However _wlang_ uses a tree of dialects, allowing specializations: <tt>sql/sybase</tt>
|
38
|
-
for example is the qualified name of a sub-dialect 'sybase' of the 'sql' dialect.
|
39
|
-
Dialects come with associated _encoders_.
|
40
|
-
example: |-
|
41
|
-
<tt>sql/sybase</tt>
|
42
|
-
- term: wlang dialect
|
43
|
-
definition: |-
|
44
|
-
When we talk about a <em>wlang dialect</em>, we are actually refering to some
|
45
|
-
specialization of the wlang tag-based grammar: <tt>wlang/xhtml</tt> for example
|
46
|
-
is the templating language _wlang_ proposes to generate xhtml pages. An
|
47
|
-
example of source code in that dialect has been shown before.
|
48
|
-
In addition to its encoders a <em>wlang dialect</em> comes with its sets of _tags_
|
49
|
-
and associated _rules_.
|
50
|
-
example: |-
|
51
|
-
<tt>wlang/xhtml</tt>
|
52
|
-
- term: encoder
|
53
|
-
definition: |-
|
54
|
-
Text transformation (algorithm) applying some encoding conventions of a portion
|
55
|
-
of a the target language generated by a dialect. HTML entities-encoding, SQL's back-quoting
|
56
|
-
are examples of encoders. Encoders are accessible through their qualified name (dialect/encoder).
|
57
|
-
example: |-
|
58
|
-
<tt>xhtml/entities-encoding</tt><br/><tt>sql/single-quoting</tt>
|
59
|
-
- term: ruleset
|
60
|
-
definition: |-
|
61
|
-
Reusable set of <em>tags</em> associated to <em>rule</em>s.
|
62
|
-
example: |-
|
63
|
-
<tt>Imperative ruleset</tt><br/><tt>Encoding rulset</tt>
|
64
|
-
- term: wlang tag
|
65
|
-
definition: |-
|
66
|
-
Special tags in the template, starting with wlang symbols and a number of wlang
|
67
|
-
blocks. A tag is associated with a wlang rule.
|
68
|
-
example: |-
|
69
|
-
<tt>${...}</tt><br/><tt>?{...}{...}{...}</tt>
|
70
|
-
- term: rule
|
71
|
-
definition: |-
|
72
|
-
Transformation semantics of a given <em>tag</em>. When wlang instantiates a
|
73
|
-
template it simply replaces <em>wlang tags</em> by some <em>replacement value</em>
|
74
|
-
(which is always a string). This value is computed by the rule attached to
|
75
|
-
the tag. Rule definition (see Rulesets tab on top of the page)
|
76
|
-
explicitly describes the number of blocks it expects, in which dialect they
|
77
|
-
are parsed and instantiated and the way the replacement value is computed.
|
78
|
-
example: |-
|
79
|
-
<tt>^{wlang/active-string}{...}</tt><br/>
|
80
|
-
Instantiates #1, looking for an encoder qualified name. Instantiates #2 in
|
81
|
-
the current dialect. Encode #2's instantiation using encoder found in (#1)
|
82
|
-
and return the result as replacement value.
|
83
|
-
- term: context
|
84
|
-
definition: |-
|
85
|
-
Some rules allow code to be executed in the <em>hosting language</em> (the
|
86
|
-
definition explicitly announce it by putting <tt>wlang/hosted</tt> in the corresponding
|
87
|
-
block). When doing so, this code is in fact executed in a given context that
|
88
|
-
provides the execution semantics.
|
89
|
-
- term: hosting language
|
90
|
-
definition: |-
|
91
|
-
language (or framework) that executes wlang. More precisely, the hosting language
|
92
|
-
is the one that rules what is considered as an executable expression in tags that
|
93
|
-
relies on some execution semantics (like !{...} for example). See the 'Hosting language'
|
94
|
-
section to learn more.
|
95
|
-
example: |-
|
96
|
-
ruby
|
97
|
-
rulesets:
|
98
|
-
- name: Basic
|
99
|
-
description: |-
|
100
|
-
The Basic ruleset is commonly installed on any dialect and provides access to _wlang_
|
101
|
-
foundations inside your template: requesting the hosting language to execute some expression,
|
102
|
-
changing the current dialect and encoding text.
|
103
|
-
examples:
|
104
|
-
- ["wlang/active-string", "Hello !{name}", "Hello O'Neil"]
|
105
|
-
- ["wlang/active-string", "Hello %{wlang/dummy}{!{name}}", "Hello !{name}"]
|
106
|
-
- ["wlang/dummy", "Hello %{wlang/dummy}{!{name}}", "Hello %{wlang/dummy}{!{name}}"]
|
107
|
-
- ["wlang/active-string", "Hello ^{plain-text/upcase}{${name}}", "Hello O'NEIL"]
|
108
|
-
- ["wlang/ruby", "puts +{name}", "puts \"O'Neil\""]
|
109
|
-
- ["wlang/ruby", "puts +{authors}", "puts [\"blambeau\", \"llambeau\", \"ancailliau\"]"]
|
110
|
-
rules:
|
111
|
-
# !{wlang/hosted}
|
112
|
-
- name: "execution"
|
113
|
-
symbol: "!"
|
114
|
-
signature: "!{wlang/hosted}"
|
115
|
-
definition: |-
|
116
|
-
Instantiates #1, looking for an expression of the hosting language. Evaluates it,
|
117
|
-
looking for any object. Converts it to a string (using to_s for example if Ruby is
|
118
|
-
the hosting language) and returns the result as replacement value.
|
119
|
-
|
120
|
-
# %{wlang/active-string}{...}
|
121
|
-
- name: "modulation"
|
122
|
-
symbol: "%"
|
123
|
-
signature: "%{wlang/active-string}{...}"
|
124
|
-
definition: |-
|
125
|
-
Instantiates #1, looking for a dialect qualified name. Instantiates #2
|
126
|
-
according to the rules defined by that dialect and returns the #2's
|
127
|
-
instantiation as replacement value.
|
128
|
-
|
129
|
-
# ^{wlang/active-string}{...}
|
130
|
-
- name: "encoding"
|
131
|
-
symbol: "^"
|
132
|
-
signature: "^{wlang/active-string}{...}"
|
133
|
-
definition: |-
|
134
|
-
Instantiates #1, looking for an encoder qualified name. Instantiates #2 in
|
135
|
-
the current dialect. Encode #2's instantiation using encoder found in (#1) and
|
136
|
-
returns encoding as replacement value.
|
137
|
-
|
138
|
-
# %!{wlang/active-string using ... with ...}{...}
|
139
|
-
- name: "recursive-application"
|
140
|
-
symbol: "%!"
|
141
|
-
signature: "%!{wlang/active-string <using>? <with>?}{...}"
|
142
|
-
definition: |-
|
143
|
-
Instantiates #1, looking for a dialect qualified name. Instantiates #2
|
144
|
-
in the current dialect. Instantiates #2's instantiation in the dialect found
|
145
|
-
in #1, using context installed by 'using ...' and 'with ...'. Returns this
|
146
|
-
instantiation as replacement value (this really advanced rule allows
|
147
|
-
metaprogramming).
|
148
|
-
|
149
|
-
# ${wlang/hosted}
|
150
|
-
- name: "injection"
|
151
|
-
symbol: "$"
|
152
|
-
signature: "${wlang/hosted}"
|
153
|
-
definition: Same semantics as execution (intended to be overrided).
|
154
|
-
|
155
|
-
# +{wlang/hosted}
|
156
|
-
- name: "inclusion"
|
157
|
-
symbol: "+"
|
158
|
-
signature: "+{wlang/hosted}"
|
159
|
-
definition: Same semantics as execution (intended to be overrided).
|
160
|
-
|
161
|
-
- name: Encoding
|
162
|
-
description: |-
|
163
|
-
Almost all languages require escaping/encoding in specific situations: quoted string literals
|
164
|
-
always come with an escaping mechanism (unfortunately different from one language to another),
|
165
|
-
html requires entities-encoding, etc. The Encoding ruleset proposes shortcut tags for encoding.
|
166
|
-
Note that these shortcuts are written in such a way that they don't depend on the effective
|
167
|
-
dialect. _wlang_ hides language and vendors differences!
|
168
|
-
examples:
|
169
|
-
- ["wlang/xhtml", "Hello &{name}", "Hello name"]
|
170
|
-
- ["wlang/xhtml", "Hello &{<script>}", "Hello <script>"]
|
171
|
-
- ["wlang/xhtml", "Hello &;{<script>}", "Hello <script>"]
|
172
|
-
- ["wlang/ruby", "puts 'Hello &'{name}'", "puts 'Hello name'"]
|
173
|
-
- ["wlang/ruby", "puts 'Hello &'{!{name}}'", "puts 'Hello O\'Neil'"]
|
174
|
-
- ["wlang/ruby", "puts 'Hello ' << '{name}'", "puts 'Hello ' << 'O\'Neil'"]
|
175
|
-
- ["wlang/sql", "... WHERE name='{name}'", "... WHERE name='O\'Neil'"]
|
176
|
-
- ["wlang/sql/sybase", "... WHERE name='{name}'", "... WHERE name='O''Neil'"]
|
177
|
-
rules:
|
178
|
-
# &{...}
|
179
|
-
- name: "main-encoding"
|
180
|
-
symbol: "&"
|
181
|
-
signature: "&{...}"
|
182
|
-
definition: "<tt>^{+{@parser.current_dialect}/main-encoding}{#1}</tt>"
|
183
|
-
|
184
|
-
# &;{...}
|
185
|
-
- name: "entities-encoding"
|
186
|
-
symbol: "&;"
|
187
|
-
signature: "&;{...}"
|
188
|
-
definition: "<tt>^{+{@parser.current_dialect}/entities-encoding}{#1}</tt>"
|
189
|
-
|
190
|
-
# &'{...}
|
191
|
-
- name: "single-quoting"
|
192
|
-
symbol: "&'"
|
193
|
-
signature: "&'{...}"
|
194
|
-
definition: "<tt>^{+{@parser.current_dialect}/single-quoting}{#1}</tt>"
|
195
|
-
|
196
|
-
# &;{...}
|
197
|
-
- name: "double-quoting"
|
198
|
-
symbol: '&"'
|
199
|
-
signature: '&"{...}'
|
200
|
-
definition: "<tt>^{+{@parser.current_dialect}/double-quoting}{#1}</tt>"
|
201
|
-
|
202
|
-
# ${wlang/hosted}
|
203
|
-
- name: "injection"
|
204
|
-
symbol: "$"
|
205
|
-
signature: "${wlang/hosted}"
|
206
|
-
definition: "<tt>&{+{#1}}</tt>"
|
207
|
-
|
208
|
-
# '{wlang/hosted}
|
209
|
-
- name: "single-quoted"
|
210
|
-
symbol: "'"
|
211
|
-
signature: "'{wlang/hosted}"
|
212
|
-
definition: |-
|
213
|
-
<tt>'&'{+{#1}}</tt> (first single quote is kept in the result)
|
214
|
-
|
215
|
-
# "{wlang/hosted}
|
216
|
-
- name: "double-quoted"
|
217
|
-
symbol: '"'
|
218
|
-
signature: '"{wlang/hosted}'
|
219
|
-
definition: |-
|
220
|
-
<tt>"&"{+{#1}}</tt> (first double quote is kept in the result)
|
221
|
-
|
222
|
-
- name: Imperative
|
223
|
-
description: |-
|
224
|
-
Instantiating conditionally and iterating collection elements are common code generation tasks.
|
225
|
-
The Imperative dialect provides these features.
|
226
|
-
examples:
|
227
|
-
- ["wlang/*", '?{true}{then}{else}', 'then']
|
228
|
-
- ["wlang/*", '?{/th/ =~ "not tat"}{then}{else}', 'else']
|
229
|
-
- ["wlang/*", '?{authors.include? "blambeau"}{yes}{no}', 'yes']
|
230
|
-
- ["wlang/*", '[*{authors as a}{"{a}"}{, }]', '["blambeau", "llambeau", "ancailliau"]']
|
231
|
-
rules:
|
232
|
-
# ?{wlang/hosted}{...}{...}
|
233
|
-
- name: "conditional<br/>(third block is optional)"
|
234
|
-
symbol: "?"
|
235
|
-
signature: "?{wlang/hosted}{...}{...}"
|
236
|
-
definition: |-
|
237
|
-
Instantiates #1, looking for an expression in the hosting language.
|
238
|
-
Evaluates it, looking for a boolean value (according to boolean semantics
|
239
|
-
of the hosting language). If true, instantiates #2, otherwise instantiates
|
240
|
-
#3 if present, returning instantiation as replacement value.
|
241
|
-
|
242
|
-
# *{wlang/hosted as x}{...}{...}
|
243
|
-
- name: "enumeration<br/>(third block is optional)"
|
244
|
-
symbol: "*"
|
245
|
-
signature: "*{wlang/hosted <as x>?}{...}{...}"
|
246
|
-
definition: |-
|
247
|
-
Instantiates #1, looking for an expression in the hosting language. Evaluates
|
248
|
-
it, looking for an enumerable. Iterates all its elements, instantiating #2 for
|
249
|
-
each of them (the iterated value is set under name x in the scope). If #3 is
|
250
|
-
present, it is instantiated between elements. Replacement is the concatenation
|
251
|
-
of all these instantiations.
|
252
|
-
|
253
|
-
- name: Context
|
254
|
-
description: |-
|
255
|
-
Complex templates come with specific needs. The ability to manipulate the context and the current
|
256
|
-
scope is provided by the Context ruleset. All are variants of 'saving previous instantiations' in
|
257
|
-
scope variables...
|
258
|
-
examples:
|
259
|
-
- ["wlang/*", '={name as n}{Hello !{n}}', "Hello O'Neil"]
|
260
|
-
- ["wlang/*", '={name as n}Hello !{n}', "Hello O'Neil"]
|
261
|
-
- ["wlang/*", '#={name}{blambeau}{Hello !{name}} and !{name}', "Hello blambeau and O'Neil"]
|
262
|
-
- ["wlang/*", '#={name}{blambeau}Hello !{name} and !{name}', "Hello blambeau and blambeau"]
|
263
|
-
- ["wlang/*", '={author as name}{Hello !{name}} and !{name}', "Hello blambeau and O'Neil"]
|
264
|
-
- ["wlang/*", '={author as name}Hello !{name} and !{name}', "Hello blambeau and blambeau"]
|
265
|
-
- ["wlang/*", '%={wlang/dummy as hello}{Hello !{name}}{!{hello}}', "Hello !{name}"]
|
266
|
-
- ["wlang/*", '^={plain-text/upcase as name}{!{author}}{Hello !{name}} and !{name}', "Hello BLAMBEAU and O'Neil"]
|
267
|
-
- ["wlang/*", '^={plain-text/upcase as name}{!{author}}Hello !{name} and !{name}', "Hello BLAMBEAU and BLAMBEAU"]
|
268
|
-
|
269
|
-
rules:
|
270
|
-
# ={wlang/hosted as x}{...}
|
271
|
-
- name: "assignment<br/>(second block is optional)"
|
272
|
-
symbol: "="
|
273
|
-
signature: "={wlang/hosted <as x>}{...}"
|
274
|
-
definition: |-
|
275
|
-
Instantiates #1, looking for an expression in the hosting language. Evaluates
|
276
|
-
it, looking for any object. Without second block, expands the current scope with
|
277
|
-
'x' being bound to evaluation result. Otherwise, branches the current scope for
|
278
|
-
the second block instantiation only and bind 'x' the same way (i.e. x will not be
|
279
|
-
available outside the second block). Returns an empty string as replacement value.
|
280
|
-
# %={wlang/active-string as x}{...}{...}
|
281
|
-
- name: "modulo-assignment<br/>(third block is optional)"
|
282
|
-
symbol: "%="
|
283
|
-
signature: "%={wlang/active-string <as x>}{...}{...}"
|
284
|
-
definition: |-
|
285
|
-
Instantiates #1, looking for a dialect qualified name. Instantiates #2 according
|
286
|
-
to the rules defined by that dialect. Without third block, expands the current
|
287
|
-
scope with 'x' being bound to #2's instantiation. Otherwise, branches the current
|
288
|
-
scope for the third block instantiation only and binds 'x' the same way (i.e. x will
|
289
|
-
not be available outside the third block). Returns an empty string as replacement
|
290
|
-
value.
|
291
|
-
# #={wlang/active-string}{...}{...}
|
292
|
-
- name: "block-assignment<br/>(third block is optional)"
|
293
|
-
symbol: "="
|
294
|
-
signature: "#={wlang/active-string}{...}{...}"
|
295
|
-
definition: |-
|
296
|
-
<tt>%={+{@parser.current_dialect} as #1}{#2}{#3}</tt>
|
297
|
-
# ^={wlang/active-string as x}{...}{...}
|
298
|
-
- name: "encoding-assignment<br/>(third block is optional)"
|
299
|
-
symbol: "^="
|
300
|
-
signature: "^={wlang/active-string <as x>}{...}{...}"
|
301
|
-
definition: |-
|
302
|
-
<tt>%={+{@parser.current_dialect} as x}{^{#1}{#2}}{#3}</tt>
|
303
|
-
|
304
|
-
- name: Buffering
|
305
|
-
description: |-
|
306
|
-
The Buffering ruleset is probably one of the more useful. It allows you to load text and data files,
|
307
|
-
to change the current output buffer (for generating multiple files for example) and even to start
|
308
|
-
the instantiation on other templates.
|
309
|
-
rules:
|
310
|
-
# <<{wlang/uri}
|
311
|
-
- name: "input"
|
312
|
-
symbol: "<<"
|
313
|
-
signature: "<<{wlang/uri}"
|
314
|
-
definition: |-
|
315
|
-
Instantiates #1, looking for an uri. Returns the text content of the found
|
316
|
-
uri (#1) as replacement value.
|
317
|
-
# >>{wlang/uri}
|
318
|
-
- name: "output"
|
319
|
-
symbol: ">>"
|
320
|
-
signature: ">>{wlang/uri}{...}"
|
321
|
-
definition: |-
|
322
|
-
Instantiates #1, looking for an uri. Instantiates #2 in the current dialect,
|
323
|
-
using the file found in #1 as output buffer. Returns an empty string as replacement
|
324
|
-
value.
|
325
|
-
# <<={wlang/uri as x}{...}
|
326
|
-
- name: "data-assignment"
|
327
|
-
symbol: "<<="
|
328
|
-
signature: "<<={wlang/uri <as x>}{...}"
|
329
|
-
definition: |-
|
330
|
-
Instantiates #1, looking for an uri. Loads data provided by this uri, based on the
|
331
|
-
file extension (typically .yml or .rb). Without second block, expands the current scope
|
332
|
-
with 'x' being bound to the data. Otherwise, branches the current scope for the second
|
333
|
-
block instantiation only and binds 'x' the same way (i.e. x will not be available outside
|
334
|
-
the second block). Returns an empty string as replacement value.
|
335
|
-
# <<+{wlang/uri with ...}
|
336
|
-
- name: "input-inclusion"
|
337
|
-
symbol: "<<+"
|
338
|
-
signature: "<<+{wlang/uri <using>? <with>?}"
|
339
|
-
definition: |-
|
340
|
-
Instantiates #1, looking for an uri. Instantiates the _wlang_ template at this location
|
341
|
-
(the dialect is infered from the file extension) in a fresh new scope built from the _with_
|
342
|
-
expression. Returns this instantiation as replacement value.
|
343
|
-
|
344
|
-
symbols:
|
345
|
-
- name: exclamation mark
|
346
|
-
symbol: '!'
|
347
|
-
meaning: execution
|
348
|
-
remark: should never be overrided as single
|
349
|
-
- name: 'caret/circumflex'
|
350
|
-
symbol: '^'
|
351
|
-
meaning: explicit encoding
|
352
|
-
remark: should never be overrided as single
|
353
|
-
- name: percent
|
354
|
-
symbol: '%'
|
355
|
-
meaning: modulation
|
356
|
-
remark: should never be overrided as single
|
357
|
-
- name: double quote
|
358
|
-
symbol: '"'
|
359
|
-
meaning: double-quoting
|
360
|
-
- name: dollar
|
361
|
-
symbol: '$'
|
362
|
-
meaning: 'main-encoding'
|
363
|
-
- name: ampersand
|
364
|
-
symbol: '&'
|
365
|
-
meaning: encoding
|
366
|
-
- name: single quote
|
367
|
-
symbol: "'"
|
368
|
-
meaning: single-quoting
|
369
|
-
- name: asterisk
|
370
|
-
symbol: '*'
|
371
|
-
meaning: iteration
|
372
|
-
- name: plus
|
373
|
-
symbol: '+'
|
374
|
-
meaning: inclusion
|
375
|
-
- name: question mark
|
376
|
-
symbol: '?'
|
377
|
-
meaning: condition
|
378
|
-
- name: at symbol
|
379
|
-
symbol: '@'
|
380
|
-
meaning: linking
|
381
|
-
- name: tilde
|
382
|
-
symbol: '~'
|
383
|
-
meaning: matching
|
384
|
-
- name: number sign
|
385
|
-
symbol: '#'
|
386
|
-
- name: comma
|
387
|
-
symbol: ','
|
388
|
-
- name: minus (dash)
|
389
|
-
symbol: '-'
|
390
|
-
- name: dot
|
391
|
-
symbol: '.'
|
392
|
-
- name: forward slash
|
393
|
-
symbol: '/'
|
394
|
-
- name: colon
|
395
|
-
symbol: ':'
|
396
|
-
- name: 'semi-colon'
|
397
|
-
symbol: ';'
|
398
|
-
- name: equal sign
|
399
|
-
symbol: '='
|
400
|
-
- name: less than
|
401
|
-
symbol: '<'
|
402
|
-
- name: greater than
|
403
|
-
symbol: '>'
|
404
|
-
- name: vertical bar
|
405
|
-
symbol: '|'
|
406
|
-
- name: underscore
|
407
|
-
symbol: '_'
|
408
|
-
remark: cannot be used as tag symbol; reserved for escaping in future versions
|
409
|
-
- name: back slash
|
410
|
-
symbol: \
|
411
|
-
remark: cannot be used as tag symbol; reserved for escaping in current version
|
412
|
-
- name: left parenthesis
|
413
|
-
symbol: '('
|
414
|
-
remark: cannot be used as tag symbol; reserved for block delimiter
|
415
|
-
- name: right parenthesis
|
416
|
-
symbol: ')'
|
417
|
-
remark: cannot be used as tag symbol; reserved for block delimiter
|
418
|
-
- name: left bracket
|
419
|
-
symbol: '['
|
420
|
-
remark: cannot be used as tag symbol; reserved for block delimiter
|
421
|
-
- name: right bracket
|
422
|
-
symbol: ']'
|
423
|
-
remark: cannot be used as tag symbol; reserved for block delimiter
|
424
|
-
- name: left brace
|
425
|
-
symbol: '{'
|
426
|
-
remark: cannot be used as tag symbol; reserved for block delimiter
|
427
|
-
- name: right brace
|
428
|
-
symbol: '}'
|
429
|
-
remark: cannot be used as tag symbol; reserved for block delimiter
|
430
|
-
|
431
|
-
|
432
|
-
|