walrus 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. data/bin/walrus +29 -14
  2. data/ext/extconf.rb +16 -0
  3. data/ext/{jindex/jindex.c → jindex.c} +27 -14
  4. data/lib/walrus/additions/string.rb +11 -5
  5. data/lib/walrus/compile_error.rb +11 -5
  6. data/lib/walrus/compiler.rb +12 -6
  7. data/lib/walrus/contrib/spec/walruscloth_spec.rb +11 -5
  8. data/lib/walrus/contrib/walruscloth.rb +11 -5
  9. data/lib/walrus/diff.rb +11 -5
  10. data/lib/walrus/document.rb +11 -5
  11. data/lib/walrus/grammar/additions/proc.rb +11 -5
  12. data/lib/walrus/grammar/additions/regexp.rb +11 -5
  13. data/lib/walrus/grammar/additions/string.rb +11 -5
  14. data/lib/walrus/grammar/additions/symbol.rb +12 -5
  15. data/lib/walrus/grammar/and_predicate.rb +11 -5
  16. data/lib/walrus/grammar/array_result.rb +11 -5
  17. data/lib/walrus/grammar/continuation_wrapper_exception.rb +11 -5
  18. data/lib/walrus/grammar/left_recursion_exception.rb +11 -5
  19. data/lib/walrus/grammar/location_tracking.rb +19 -9
  20. data/lib/walrus/grammar/match_data_wrapper.rb +11 -5
  21. data/lib/walrus/grammar/memoizing.rb +11 -5
  22. data/lib/walrus/grammar/memoizing_cache.rb +18 -9
  23. data/lib/walrus/grammar/node.rb +11 -5
  24. data/lib/walrus/grammar/not_predicate.rb +11 -5
  25. data/lib/walrus/grammar/parse_error.rb +11 -5
  26. data/lib/walrus/grammar/parser_state.rb +11 -5
  27. data/lib/walrus/grammar/parslet.rb +11 -5
  28. data/lib/walrus/grammar/parslet_choice.rb +15 -7
  29. data/lib/walrus/grammar/parslet_combination.rb +11 -5
  30. data/lib/walrus/grammar/parslet_combining.rb +11 -5
  31. data/lib/walrus/grammar/parslet_merge.rb +11 -5
  32. data/lib/walrus/grammar/parslet_omission.rb +11 -5
  33. data/lib/walrus/grammar/parslet_repetition.rb +17 -8
  34. data/lib/walrus/grammar/parslet_repetition_default.rb +11 -5
  35. data/lib/walrus/grammar/parslet_sequence.rb +20 -8
  36. data/lib/walrus/grammar/predicate.rb +11 -5
  37. data/lib/walrus/grammar/proc_parslet.rb +11 -5
  38. data/lib/walrus/grammar/regexp_parslet.rb +11 -5
  39. data/lib/walrus/grammar/skipped_substring_exception.rb +11 -5
  40. data/lib/walrus/grammar/string_enumerator.rb +14 -6
  41. data/lib/walrus/grammar/string_parslet.rb +11 -5
  42. data/lib/walrus/grammar/string_result.rb +11 -5
  43. data/lib/walrus/grammar/symbol_parslet.rb +11 -5
  44. data/lib/walrus/grammar.rb +11 -5
  45. data/lib/walrus/no_parameter_marker.rb +11 -5
  46. data/lib/walrus/parser.rb +12 -6
  47. data/lib/walrus/runner.rb +60 -67
  48. data/lib/walrus/template.rb +15 -7
  49. data/lib/walrus/version.rb +3 -0
  50. data/lib/walrus/walrus_grammar/assignment_expression.rb +11 -5
  51. data/lib/walrus/walrus_grammar/block_directive.rb +11 -5
  52. data/lib/walrus/walrus_grammar/comment.rb +11 -5
  53. data/lib/walrus/walrus_grammar/def_directive.rb +16 -8
  54. data/lib/walrus/walrus_grammar/echo_directive.rb +11 -5
  55. data/lib/walrus/walrus_grammar/escape_sequence.rb +11 -5
  56. data/lib/walrus/walrus_grammar/import_directive.rb +11 -5
  57. data/lib/walrus/walrus_grammar/include_directive.rb +11 -5
  58. data/lib/walrus/walrus_grammar/instance_variable.rb +11 -5
  59. data/lib/walrus/walrus_grammar/literal.rb +11 -5
  60. data/lib/walrus/walrus_grammar/message_expression.rb +11 -5
  61. data/lib/walrus/walrus_grammar/multiline_comment.rb +11 -5
  62. data/lib/walrus/walrus_grammar/placeholder.rb +11 -5
  63. data/lib/walrus/walrus_grammar/raw_directive.rb +11 -5
  64. data/lib/walrus/walrus_grammar/raw_text.rb +11 -5
  65. data/lib/walrus/walrus_grammar/ruby_directive.rb +11 -5
  66. data/lib/walrus/walrus_grammar/ruby_expression.rb +11 -5
  67. data/lib/walrus/walrus_grammar/set_directive.rb +11 -5
  68. data/lib/walrus/walrus_grammar/silent_directive.rb +11 -5
  69. data/lib/walrus/walrus_grammar/slurp_directive.rb +11 -5
  70. data/lib/walrus/walrus_grammar/super_directive.rb +11 -5
  71. data/lib/walrus.rb +30 -16
  72. metadata +91 -211
  73. data/ext/jindex/extconf.rb +0 -11
  74. data/ext/mkdtemp/extconf.rb +0 -11
  75. data/ext/mkdtemp/mkdtemp.c +0 -41
  76. data/lib/walrus/additions/module.rb +0 -36
  77. data/lib/walrus/additions/test/unit/error_collector.rb +0 -62
  78. data/spec/acceptance/acceptance_spec.rb +0 -97
  79. data/spec/acceptance/block/basic_block.expected +0 -1
  80. data/spec/acceptance/block/basic_block.tmpl +0 -3
  81. data/spec/acceptance/block/nested_blocks.expected +0 -5
  82. data/spec/acceptance/block/nested_blocks.tmpl +0 -11
  83. data/spec/acceptance/comments/comments_and_text.expected +0 -3
  84. data/spec/acceptance/comments/comments_and_text.tmpl +0 -6
  85. data/spec/acceptance/comments/single_comment.expected +0 -0
  86. data/spec/acceptance/comments/single_comment.tmpl +0 -1
  87. data/spec/acceptance/def/alternative_def_calling_conventions.expected +0 -3
  88. data/spec/acceptance/def/alternative_def_calling_conventions.tmpl +0 -18
  89. data/spec/acceptance/def/basic_def_block_no_output.expected +0 -0
  90. data/spec/acceptance/def/basic_def_block_no_output.tmpl +0 -17
  91. data/spec/acceptance/def/defs_can_be_called_multiple_times.expected +0 -3
  92. data/spec/acceptance/def/defs_can_be_called_multiple_times.tmpl +0 -6
  93. data/spec/acceptance/def/defs_can_be_dynamic.expected +0 -4
  94. data/spec/acceptance/def/defs_can_be_dynamic.tmpl +0 -12
  95. data/spec/acceptance/echo/echo_directive_with_numeric_literal.expected +0 -1
  96. data/spec/acceptance/echo/echo_directive_with_numeric_literal.tmpl +0 -1
  97. data/spec/acceptance/echo/echo_expression_list.expected +0 -1
  98. data/spec/acceptance/echo/echo_expression_list.tmpl +0 -1
  99. data/spec/acceptance/echo/echo_short_notation.expected +0 -1
  100. data/spec/acceptance/echo/echo_short_notation.tmpl +0 -1
  101. data/spec/acceptance/echo/echo_simple_expression.expected +0 -1
  102. data/spec/acceptance/echo/echo_simple_expression.tmpl +0 -1
  103. data/spec/acceptance/echo/echo_single_quoted_string_literal.expected +0 -1
  104. data/spec/acceptance/echo/echo_single_quoted_string_literal.tmpl +0 -1
  105. data/spec/acceptance/echo/multiple_echo_statements.expected +0 -1
  106. data/spec/acceptance/echo/multiple_echo_statements.tmpl +0 -2
  107. data/spec/acceptance/includes/basic_included_file.txt +0 -1
  108. data/spec/acceptance/includes/basic_includer.complex +0 -3
  109. data/spec/acceptance/includes/basic_includer.expected +0 -3
  110. data/spec/acceptance/includes/basic_includer.rb +0 -38
  111. data/spec/acceptance/includes/complicated_included_file.txt +0 -3
  112. data/spec/acceptance/includes/complicated_includer.complex +0 -3
  113. data/spec/acceptance/includes/complicated_includer.expected +0 -3
  114. data/spec/acceptance/includes/complicated_includer.rb +0 -41
  115. data/spec/acceptance/includes/nested_include_1.txt +0 -3
  116. data/spec/acceptance/includes/nested_include_2.txt +0 -1
  117. data/spec/acceptance/includes/nested_includer.complex +0 -3
  118. data/spec/acceptance/includes/nested_includer.expected +0 -4
  119. data/spec/acceptance/includes/nested_includer.rb +0 -41
  120. data/spec/acceptance/inheritance/basic_child.complex +0 -10
  121. data/spec/acceptance/inheritance/basic_child.expected +0 -9
  122. data/spec/acceptance/inheritance/basic_child.rb +0 -54
  123. data/spec/acceptance/inheritance/basic_parent.complex +0 -5
  124. data/spec/acceptance/inheritance/basic_parent.expected +0 -3
  125. data/spec/acceptance/inheritance/basic_parent.rb +0 -41
  126. data/spec/acceptance/inheritance/importing_child.complex +0 -8
  127. data/spec/acceptance/inheritance/importing_child.expected +0 -7
  128. data/spec/acceptance/inheritance/importing_child.rb +0 -46
  129. data/spec/acceptance/inheritance/subdirectory/importing_child_in_subdirectory.complex +0 -8
  130. data/spec/acceptance/inheritance/subdirectory/importing_child_in_subdirectory.expected +0 -7
  131. data/spec/acceptance/inheritance/subdirectory/importing_child_in_subdirectory.rb +0 -44
  132. data/spec/acceptance/multiline_comments/multiline_comment_with_directives_inside.expected +0 -0
  133. data/spec/acceptance/multiline_comments/multiline_comment_with_directives_inside.tmpl +0 -15
  134. data/spec/acceptance/multiline_comments/simple_multiline_comment.expected +0 -2
  135. data/spec/acceptance/multiline_comments/simple_multiline_comment.tmpl +0 -4
  136. data/spec/acceptance/raw/complicated_raw_example.expected +0 -57
  137. data/spec/acceptance/raw/complicated_raw_example.tmpl +0 -79
  138. data/spec/acceptance/raw-text/UTF_8.expected +0 -12
  139. data/spec/acceptance/raw-text/UTF_8.tmpl +0 -12
  140. data/spec/acceptance/raw-text/empty_file.expected +0 -0
  141. data/spec/acceptance/raw-text/empty_file.tmpl +0 -0
  142. data/spec/acceptance/raw-text/multi_line.expected +0 -4
  143. data/spec/acceptance/raw-text/multi_line.tmpl +0 -4
  144. data/spec/acceptance/raw-text/single_line.expected +0 -1
  145. data/spec/acceptance/raw-text/single_line.tmpl +0 -1
  146. data/spec/acceptance/raw-text/single_line_whitespace.expected +0 -1
  147. data/spec/acceptance/raw-text/single_line_whitespace.tmpl +0 -1
  148. data/spec/acceptance/ruby/ruby_directive_is_just_like_silent.expected +0 -1
  149. data/spec/acceptance/ruby/ruby_directive_is_just_like_silent.tmpl +0 -4
  150. data/spec/acceptance/ruby/ruby_directive_using_here_doc.expected +0 -1
  151. data/spec/acceptance/ruby/ruby_directive_using_here_doc.tmpl +0 -4
  152. data/spec/acceptance/ruby/ruby_directive_using_here_doc_alt_syntax.expected +0 -1
  153. data/spec/acceptance/ruby/ruby_directive_using_here_doc_alt_syntax.tmpl +0 -4
  154. data/spec/acceptance/ruby/ruby_directive_with_accumulate.expected +0 -1
  155. data/spec/acceptance/ruby/ruby_directive_with_accumulate.tmpl +0 -4
  156. data/spec/acceptance/ruby/ruby_directive_with_accumulate_and_block.expected +0 -1
  157. data/spec/acceptance/ruby/ruby_directive_with_accumulate_and_block.tmpl +0 -6
  158. data/spec/acceptance/set/unused_set.expected +0 -0
  159. data/spec/acceptance/set/unused_set.tmpl +0 -1
  160. data/spec/acceptance/set/used_set.expected +0 -1
  161. data/spec/acceptance/set/used_set.tmpl +0 -2
  162. data/spec/acceptance/silent/silent_and_echo_combined.expected +0 -1
  163. data/spec/acceptance/silent/silent_and_echo_combined.tmpl +0 -2
  164. data/spec/acceptance/silent/silent_short_notation.expected +0 -1
  165. data/spec/acceptance/silent/silent_short_notation.tmpl +0 -1
  166. data/spec/acceptance/silent/simple_silent_directive.expected +0 -0
  167. data/spec/acceptance/silent/simple_silent_directive.tmpl +0 -1
  168. data/spec/acceptance/slurp/basic_slurp_demo.expected +0 -1
  169. data/spec/acceptance/slurp/basic_slurp_demo.tmpl +0 -4
  170. data/spec/acceptance/super/super_with_no_effect.expected +0 -4
  171. data/spec/acceptance/super/super_with_no_effect.tmpl +0 -5
  172. data/spec/additions/module_spec.rb +0 -126
  173. data/spec/additions/string_spec.rb +0 -99
  174. data/spec/compiler_spec.rb +0 -55
  175. data/spec/grammar/additions/proc_spec.rb +0 -25
  176. data/spec/grammar/additions/regexp_spec.rb +0 -37
  177. data/spec/grammar/additions/string_spec.rb +0 -106
  178. data/spec/grammar/and_predicate_spec.rb +0 -29
  179. data/spec/grammar/continuation_wrapper_exception_spec.rb +0 -23
  180. data/spec/grammar/match_data_wrapper_spec.rb +0 -41
  181. data/spec/grammar/memoizing_cache_spec.rb +0 -112
  182. data/spec/grammar/node_spec.rb +0 -126
  183. data/spec/grammar/not_predicate_spec.rb +0 -29
  184. data/spec/grammar/parser_state_spec.rb +0 -172
  185. data/spec/grammar/parslet_choice_spec.rb +0 -49
  186. data/spec/grammar/parslet_combining_spec.rb +0 -287
  187. data/spec/grammar/parslet_merge_spec.rb +0 -33
  188. data/spec/grammar/parslet_omission_spec.rb +0 -58
  189. data/spec/grammar/parslet_repetition_spec.rb +0 -77
  190. data/spec/grammar/parslet_sequence_spec.rb +0 -49
  191. data/spec/grammar/parslet_spec.rb +0 -23
  192. data/spec/grammar/predicate_spec.rb +0 -53
  193. data/spec/grammar/proc_parslet_spec.rb +0 -52
  194. data/spec/grammar/regexp_parslet_spec.rb +0 -347
  195. data/spec/grammar/string_enumerator_spec.rb +0 -94
  196. data/spec/grammar/string_parslet_spec.rb +0 -143
  197. data/spec/grammar/symbol_parslet_spec.rb +0 -30
  198. data/spec/grammar_spec.rb +0 -545
  199. data/spec/parser_spec.rb +0 -1418
  200. data/spec/spec_helper.rb +0 -34
  201. data/spec/walrus_grammar/comment_spec.rb +0 -39
  202. data/spec/walrus_grammar/echo_directive_spec.rb +0 -63
  203. data/spec/walrus_grammar/escape_sequence_spec.rb +0 -85
  204. data/spec/walrus_grammar/literal_spec.rb +0 -41
  205. data/spec/walrus_grammar/message_expression_spec.rb +0 -37
  206. data/spec/walrus_grammar/multiline_comment_spec.rb +0 -58
  207. data/spec/walrus_grammar/placeholder_spec.rb +0 -48
  208. data/spec/walrus_grammar/raw_directive_spec.rb +0 -81
  209. data/spec/walrus_grammar/raw_text_spec.rb +0 -65
  210. data/spec/walrus_grammar/silent_directive_spec.rb +0 -34
data/bin/walrus CHANGED
@@ -1,23 +1,30 @@
1
1
  #!/usr/bin/env ruby
2
- # Copyright 2007 Wincent Colaiuta
3
- # This program is distributed in the hope that it will be useful, but WITHOUT
4
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6
- # in the accompanying file, "LICENSE.txt", for more details.
2
+ # Copyright 2007-2008 Wincent Colaiuta
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
7
  #
8
- # $Id: diff.rb 89 2007-02-26 15:35:56Z wincent $
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
9
15
 
10
16
  module Walrus
11
-
17
+
12
18
  EXIT_LOAD_ERROR = 1
13
19
  EXIT_ARGUMENT_ERROR = 2
14
20
  EXIT_OTHER_ERROR = 3
15
-
21
+ EXIT_UNKNOWN_ERROR = 4
22
+
16
23
  begin
17
24
  require 'walrus/runner'
18
25
  rescue LoadError => e
19
26
  $stderr.puts <<-HERE
20
- Error: load error (#{e.to_s})
27
+ :: error: load error (#{e.to_s})
21
28
 
22
29
  If you are trying to run Walrus but have not yet installed it, it may be that
23
30
  Ruby cannot find the Walrus files. You can help Ruby to find the Walrus "lib"
@@ -30,15 +37,23 @@ substituting absolute paths for "lib" and "ext":
30
37
  HERE
31
38
  exit EXIT_LOAD_ERROR
32
39
  end
33
-
34
- begin
40
+
41
+ begin
35
42
  Runner.new.run
43
+ rescue SystemExit => e
44
+ # normally raised for "--version" or "--help" switches
45
+ rescue Interrupt => e
46
+ $stderr.puts ':: aborting: interrupt'
47
+ exit EXIT_OTHER_ERROR
36
48
  rescue Runner::ArgumentError => e
37
- $stderr.puts "Error: #{e.to_s}", "For usage information type: #{$0} --help"
49
+ $stderr.puts ":: error: #{e.to_s}", "For usage information type: #{$0} --help"
38
50
  exit EXIT_ARGUMENT_ERROR
39
51
  rescue Runner::Error => e
40
- $stderr.puts "Error: #{e.to_s}"
52
+ $stderr.puts ":: error: #{e.to_s}"
41
53
  exit EXIT_OTHER_ERROR
54
+ rescue Exception => e
55
+ $stderr.puts ":: error: #{e.to_s}"
56
+ exit EXIT_UNKNOWN_ERROR
42
57
  end
43
-
58
+
44
59
  end # module Walrus
data/ext/extconf.rb ADDED
@@ -0,0 +1,16 @@
1
+ # Copyright 2007-2010 Wincent Colaiuta
2
+ # This program is free software: you can redistribute it and/or modify
3
+ # it under the terms of the GNU General Public License as published by
4
+ # the Free Software Foundation, either version 3 of the License, or
5
+ # (at your option) any later version.
6
+ #
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
+
15
+ require 'mkmf'
16
+ create_makefile('jindex')
@@ -1,22 +1,32 @@
1
- /*
2
- Copyright 2007 Wincent Colaiuta
3
- This program is distributed in the hope that it will be useful, but WITHOUT
4
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6
- in the accompanying file, "LICENSE.txt", for more details.
7
-
8
- $Id$
1
+ /*
2
+ Copyright 2007-2010 Wincent Colaiuta
3
+ This program is free software: you can redistribute it and/or modify
4
+ it under the terms of the GNU General Public License as published by
5
+ the Free Software Foundation, either version 3 of the License, or
6
+ (at your option) any later version.
7
+
8
+ This program is distributed in the hope that it will be useful,
9
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ GNU General Public License for more details.
12
+
13
+ You should have received a copy of the GNU General Public License
14
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
9
15
  */
10
16
 
11
17
  #include <ruby.h>
12
18
 
13
19
  /*
14
20
 
15
- Common code used by almost identical "jindex" and "jrindex" methods. A C extension is necessary here because with direct access to the rb_backref_get and rb_backref_set API there is no way to propagate $~ back to the caller after invoking the "index" and "rindex" methods. The code is basically equivalent to the following Ruby code:
21
+ Common code used by almost identical "jindex" and "jrindex" methods. A C
22
+ extension is necessary here because with direct access to the rb_backref_get
23
+ and rb_backref_set API there is no way to propagate $~ back to the caller after
24
+ invoking the "index" and "rindex" methods. The code is basically equivalent to
25
+ the following Ruby code:
16
26
 
17
27
  def index arg1, optional_arg
18
28
  index = super # plus code here for deciding whether or not to pass optional argument
19
- match = ($~ ? $~.clone : nil)
29
+ match = ($~ ? $~.clone : nil)
20
30
  index unpack('C*')[0...index].pack('C*').jlength # jlength clobbers $~ as a side effect, should consider rewriting it
21
31
  $~ = match # in pure Ruby setting $~ here has only a local effect (not seen by caller)
22
32
  index
@@ -32,7 +42,7 @@ static VALUE walrus_str_index_common(ID func, int argc, VALUE *argv, VALUE str)
32
42
  {
33
43
  VALUE packing_format = rb_str_new2("C*");
34
44
  VALUE unpacked = rb_funcall(str, rb_intern("unpack"), 1, packing_format); /* unpack('C*') */
35
- VALUE range = rb_funcall(rb_cRange, rb_intern("new"), 3, INT2FIX(0), index, Qtrue);
45
+ VALUE range = rb_funcall(rb_cRange, rb_intern("new"), 3, INT2FIX(0), index, Qtrue);
36
46
  VALUE slice = rb_funcall(unpacked, rb_intern("slice"), 1, range); /* [0...idx] */
37
47
  VALUE packed = rb_funcall(slice, rb_intern("pack"), 1, packing_format); /* pack('C*') */
38
48
  jindex = rb_funcall(packed, rb_intern("jlength"), 0); /* jlength */
@@ -48,7 +58,9 @@ call-seq:
48
58
  str.jindex(fixnum [, offset]) -> Fixnum or nil
49
59
  str.jindex(regexp [, offset]) -> Fixnum or nil
50
60
 
51
- Multibyte-friendly equivalent of the String#index method. If $KCODE is appropriately set will return an accurate index based on character count rather than byte counts.
61
+ Multibyte-friendly equivalent of the String#index method. If $KCODE is
62
+ appropriately set will return an accurate index based on character count rather
63
+ than byte counts.
52
64
 
53
65
  */
54
66
  static VALUE walrus_str_jindex_m(int argc, VALUE *argv, VALUE str)
@@ -63,7 +75,9 @@ call-seq:
63
75
  str.jrindex(fixnum [, offset]) -> Fixnum or nil
64
76
  str.jrindex(regexp [, offset]) -> Fixnum or nil
65
77
 
66
- Multibyte-friendly equivalent of the String#rindex method. If $KCODE is appropriately set will return an accurate index based on character count rather than byte counts.
78
+ Multibyte-friendly equivalent of the String#rindex method. If $KCODE is
79
+ appropriately set will return an accurate index based on character count rather
80
+ than byte counts.
67
81
 
68
82
  */
69
83
  static VALUE walrus_str_jrindex_m(int argc, VALUE *argv, VALUE str)
@@ -76,4 +90,3 @@ void Init_jindex()
76
90
  rb_define_method(rb_cString, "jindex", walrus_str_jindex_m, -1);
77
91
  rb_define_method(rb_cString, "jrindex", walrus_str_jrindex_m, -1);
78
92
  }
79
-
@@ -1,10 +1,16 @@
1
1
  # Copyright 2007 Wincent Colaiuta
2
- # This program is distributed in the hope that it will be useful, but WITHOUT
3
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5
- # in the accompanying file, "LICENSE.txt", for more details.
2
+ # This program is free software: you can redistribute it and/or modify
3
+ # it under the terms of the GNU General Public License as published by
4
+ # the Free Software Foundation, either version 3 of the License, or
5
+ # (at your option) any later version.
6
6
  #
7
- # $Id$
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
8
14
 
9
15
  require 'walrus'
10
16
 
@@ -1,10 +1,16 @@
1
1
  # Copyright 2007 Wincent Colaiuta
2
- # This program is distributed in the hope that it will be useful, but WITHOUT
3
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5
- # in the accompanying file, "LICENSE.txt", for more details.
2
+ # This program is free software: you can redistribute it and/or modify
3
+ # it under the terms of the GNU General Public License as published by
4
+ # the Free Software Foundation, either version 3 of the License, or
5
+ # (at your option) any later version.
6
6
  #
7
- # $Id$
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
8
14
 
9
15
  require 'walrus'
10
16
 
@@ -1,10 +1,16 @@
1
1
  # Copyright 2007 Wincent Colaiuta
2
- # This program is distributed in the hope that it will be useful, but WITHOUT
3
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5
- # in the accompanying file, "LICENSE.txt", for more details.
2
+ # This program is free software: you can redistribute it and/or modify
3
+ # it under the terms of the GNU General Public License as published by
4
+ # the Free Software Foundation, either version 3 of the License, or
5
+ # (at your option) any later version.
6
6
  #
7
- # $Id: /mirrors/Walrus/trunk/walrus/lib/walrus/compiler.rb 6709 2007-04-10T05:38:46.657919Z wincent $
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
8
14
 
9
15
  require 'walrus'
10
16
  require 'pathname'
@@ -74,7 +80,7 @@ module Walrus
74
80
 
75
81
  <<-RETURN
76
82
  \#!/usr/bin/env ruby
77
- \# Generated #{Time.new.to_s} by Walrus version #{VERSION}
83
+ \# Generated by Walrus <http://walrus.wincent.com/>
78
84
 
79
85
  begin
80
86
  require 'rubygems'
@@ -1,11 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Copyright 2007 Wincent Colaiuta
3
- # This program is distributed in the hope that it will be useful, but WITHOUT
4
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6
- # in the accompanying file, "LICENSE.txt", for more details.
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
7
  #
8
- # $Id: /mirrors/Walrus/trunk/walrus/lib/walrus/contrib/spec/walruscloth_spec.rb 6702 2007-04-09T15:04:40.448669Z wincent $
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
9
15
 
10
16
  require 'rubygems'
11
17
  require 'spec'
@@ -1,10 +1,16 @@
1
1
  # Copyright 2007 Wincent Colaiuta
2
- # This program is distributed in the hope that it will be useful, but WITHOUT
3
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5
- # in the accompanying file, "LICENSE.txt", for more details.
2
+ # This program is free software: you can redistribute it and/or modify
3
+ # it under the terms of the GNU General Public License as published by
4
+ # the Free Software Foundation, either version 3 of the License, or
5
+ # (at your option) any later version.
6
6
  #
7
- # $Id$
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
8
14
 
9
15
  require 'rubygems'
10
16
  gem 'RedCloth', '= 3.0.4'; require 'redcloth'
data/lib/walrus/diff.rb CHANGED
@@ -1,10 +1,16 @@
1
1
  # Copyright 2007 Wincent Colaiuta
2
- # This program is distributed in the hope that it will be useful, but WITHOUT
3
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5
- # in the accompanying file, "LICENSE.txt", for more details.
2
+ # This program is free software: you can redistribute it and/or modify
3
+ # it under the terms of the GNU General Public License as published by
4
+ # the Free Software Foundation, either version 3 of the License, or
5
+ # (at your option) any later version.
6
6
  #
7
- # $Id$
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
8
14
 
9
15
  require 'walrus'
10
16
  require 'open3'
@@ -1,12 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
3
  # Copyright 2007 Wincent Colaiuta
4
- # This program is distributed in the hope that it will be useful, but WITHOUT
5
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7
- # in the accompanying file, "LICENSE.txt", for more details.
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
8
  #
9
- # $Id: /mirrors/Walrus/trunk/walrus/lib/walrus/document.rb 6708 2007-04-10T05:38:35.035099Z wincent $
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
10
16
 
11
17
  require 'walrus'
12
18
  require 'pathname'
@@ -1,10 +1,16 @@
1
1
  # Copyright 2007 Wincent Colaiuta
2
- # This program is distributed in the hope that it will be useful, but WITHOUT
3
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5
- # in the accompanying file, "LICENSE.txt", for more details.
2
+ # This program is free software: you can redistribute it and/or modify
3
+ # it under the terms of the GNU General Public License as published by
4
+ # the Free Software Foundation, either version 3 of the License, or
5
+ # (at your option) any later version.
6
6
  #
7
- # $Id$
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
8
14
 
9
15
  require 'walrus'
10
16
 
@@ -1,10 +1,16 @@
1
1
  # Copyright 2007 Wincent Colaiuta
2
- # This program is distributed in the hope that it will be useful, but WITHOUT
3
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5
- # in the accompanying file, "LICENSE.txt", for more details.
2
+ # This program is free software: you can redistribute it and/or modify
3
+ # it under the terms of the GNU General Public License as published by
4
+ # the Free Software Foundation, either version 3 of the License, or
5
+ # (at your option) any later version.
6
6
  #
7
- # $Id$
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
8
14
 
9
15
  require 'walrus'
10
16
 
@@ -1,10 +1,16 @@
1
1
  # Copyright 2007 Wincent Colaiuta
2
- # This program is distributed in the hope that it will be useful, but WITHOUT
3
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5
- # in the accompanying file, "LICENSE.txt", for more details.
2
+ # This program is free software: you can redistribute it and/or modify
3
+ # it under the terms of the GNU General Public License as published by
4
+ # the Free Software Foundation, either version 3 of the License, or
5
+ # (at your option) any later version.
6
6
  #
7
- # $Id$
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
8
14
 
9
15
  require 'walrus'
10
16
 
@@ -1,10 +1,16 @@
1
1
  # Copyright 2007 Wincent Colaiuta
2
- # This program is distributed in the hope that it will be useful, but WITHOUT
3
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5
- # in the accompanying file, "LICENSE.txt", for more details.
2
+ # This program is free software: you can redistribute it and/or modify
3
+ # it under the terms of the GNU General Public License as published by
4
+ # the Free Software Foundation, either version 3 of the License, or
5
+ # (at your option) any later version.
6
6
  #
7
- # $Id$
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
8
14
 
9
15
  require 'walrus'
10
16
 
@@ -25,6 +31,7 @@ class Symbol
25
31
  def build(superclass, *params)
26
32
 
27
33
  # first use the continuation trick to find out what grammar (namespace) receiver is being messaged in
34
+ # Ruby 1.9/2.0 will not support continuations, so may need to come up with an alternative
28
35
  continuation = nil
29
36
  value = callcc { |c| continuation = c }
30
37
  if value == continuation # first time that we're here
@@ -1,10 +1,16 @@
1
1
  # Copyright 2007 Wincent Colaiuta
2
- # This program is distributed in the hope that it will be useful, but WITHOUT
3
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5
- # in the accompanying file, "LICENSE.txt", for more details.
2
+ # This program is free software: you can redistribute it and/or modify
3
+ # it under the terms of the GNU General Public License as published by
4
+ # the Free Software Foundation, either version 3 of the License, or
5
+ # (at your option) any later version.
6
6
  #
7
- # $Id$
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
8
14
 
9
15
  require 'walrus'
10
16
 
@@ -1,10 +1,16 @@
1
1
  # Copyright 2007 Wincent Colaiuta
2
- # This program is distributed in the hope that it will be useful, but WITHOUT
3
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5
- # in the accompanying file, "LICENSE.txt", for more details.
2
+ # This program is free software: you can redistribute it and/or modify
3
+ # it under the terms of the GNU General Public License as published by
4
+ # the Free Software Foundation, either version 3 of the License, or
5
+ # (at your option) any later version.
6
6
  #
7
- # $Id$
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
8
14
 
9
15
  require 'walrus'
10
16
 
@@ -1,10 +1,16 @@
1
1
  # Copyright 2007 Wincent Colaiuta
2
- # This program is distributed in the hope that it will be useful, but WITHOUT
3
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5
- # in the accompanying file, "LICENSE.txt", for more details.
2
+ # This program is free software: you can redistribute it and/or modify
3
+ # it under the terms of the GNU General Public License as published by
4
+ # the Free Software Foundation, either version 3 of the License, or
5
+ # (at your option) any later version.
6
6
  #
7
- # $Id$
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
8
14
 
9
15
  require 'walrus'
10
16
 
@@ -1,10 +1,16 @@
1
1
  # Copyright 2007 Wincent Colaiuta
2
- # This program is distributed in the hope that it will be useful, but WITHOUT
3
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5
- # in the accompanying file, "LICENSE.txt", for more details.
2
+ # This program is free software: you can redistribute it and/or modify
3
+ # it under the terms of the GNU General Public License as published by
4
+ # the Free Software Foundation, either version 3 of the License, or
5
+ # (at your option) any later version.
6
6
  #
7
- # $Id$
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
8
14
 
9
15
  require 'walrus'
10
16
 
@@ -1,10 +1,16 @@
1
1
  # Copyright 2007 Wincent Colaiuta
2
- # This program is distributed in the hope that it will be useful, but WITHOUT
3
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5
- # in the accompanying file, "LICENSE.txt", for more details.
2
+ # This program is free software: you can redistribute it and/or modify
3
+ # it under the terms of the GNU General Public License as published by
4
+ # the Free Software Foundation, either version 3 of the License, or
5
+ # (at your option) any later version.
6
6
  #
7
- # $Id: /mirrors/Walrus/trunk/walrus/lib/walrus/grammar/location_tracking.rb 6704 2007-04-09T18:30:00.421185Z wincent $
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
8
14
 
9
15
  require 'walrus'
10
16
 
@@ -92,10 +98,14 @@ module Walrus
92
98
  # Given another object that responds to column_end and line_end, returns true if the receiver is rightmost or equal.
93
99
  # If the other object is farther to the right returns false.
94
100
  def rightmost?(other)
95
- if self.line_end > other.line_end : true
96
- elsif other.line_end > self.line_end : false
97
- elsif self.column_end >= other.column_end : true
98
- else false
101
+ if self.line_end > other.line_end
102
+ true
103
+ elsif other.line_end > self.line_end
104
+ false
105
+ elsif self.column_end >= other.column_end
106
+ true
107
+ else
108
+ false
99
109
  end
100
110
  end
101
111
 
@@ -1,10 +1,16 @@
1
1
  # Copyright 2007 Wincent Colaiuta
2
- # This program is distributed in the hope that it will be useful, but WITHOUT
3
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5
- # in the accompanying file, "LICENSE.txt", for more details.
2
+ # This program is free software: you can redistribute it and/or modify
3
+ # it under the terms of the GNU General Public License as published by
4
+ # the Free Software Foundation, either version 3 of the License, or
5
+ # (at your option) any later version.
6
6
  #
7
- # $Id$
7
+ # This program is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ # GNU General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
8
14
 
9
15
  require 'walrus'
10
16