less 0.8.13 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. data/README.md +10 -1
  2. data/Rakefile +21 -3
  3. data/VERSION +1 -1
  4. data/bin/lessc +0 -8
  5. data/less.gemspec +138 -15
  6. data/lib/less.rb +67 -11
  7. data/lib/less/command.rb +24 -25
  8. data/lib/less/engine.rb +36 -140
  9. data/lib/less/engine/builder.rb +8 -0
  10. data/lib/less/engine/less.tt +374 -0
  11. data/lib/less/engine/nodes.rb +8 -0
  12. data/lib/less/engine/nodes/element.rb +150 -0
  13. data/lib/less/engine/nodes/entity.rb +73 -0
  14. data/lib/less/engine/nodes/function.rb +82 -0
  15. data/lib/less/engine/nodes/literal.rb +135 -0
  16. data/lib/less/engine/nodes/property.rb +112 -0
  17. data/lib/less/engine/nodes/selector.rb +39 -0
  18. data/lib/less/engine/parser.rb +3860 -0
  19. data/lib/vendor/treetop/.gitignore +7 -0
  20. data/lib/vendor/treetop/LICENSE +19 -0
  21. data/lib/vendor/treetop/README +164 -0
  22. data/lib/vendor/treetop/Rakefile +19 -0
  23. data/lib/vendor/treetop/benchmark/seqpar.gnuplot +15 -0
  24. data/lib/vendor/treetop/benchmark/seqpar.treetop +16 -0
  25. data/lib/vendor/treetop/benchmark/seqpar_benchmark.rb +107 -0
  26. data/lib/vendor/treetop/bin/tt +28 -0
  27. data/lib/vendor/treetop/lib/treetop.rb +8 -0
  28. data/lib/vendor/treetop/lib/treetop/bootstrap_gen_1_metagrammar.rb +45 -0
  29. data/lib/vendor/treetop/lib/treetop/compiler.rb +6 -0
  30. data/lib/vendor/treetop/lib/treetop/compiler/grammar_compiler.rb +42 -0
  31. data/lib/vendor/treetop/lib/treetop/compiler/lexical_address_space.rb +17 -0
  32. data/lib/vendor/treetop/lib/treetop/compiler/metagrammar.rb +3097 -0
  33. data/lib/vendor/treetop/lib/treetop/compiler/metagrammar.treetop +408 -0
  34. data/lib/vendor/treetop/lib/treetop/compiler/node_classes.rb +19 -0
  35. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/anything_symbol.rb +18 -0
  36. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/atomic_expression.rb +14 -0
  37. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/character_class.rb +23 -0
  38. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/choice.rb +31 -0
  39. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/declaration_sequence.rb +24 -0
  40. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/grammar.rb +28 -0
  41. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/inline_module.rb +27 -0
  42. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/nonterminal.rb +13 -0
  43. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/optional.rb +19 -0
  44. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parenthesized_expression.rb +9 -0
  45. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parsing_expression.rb +146 -0
  46. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parsing_rule.rb +55 -0
  47. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/predicate.rb +45 -0
  48. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/repetition.rb +55 -0
  49. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/sequence.rb +68 -0
  50. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/terminal.rb +20 -0
  51. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/transient_prefix.rb +9 -0
  52. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/treetop_file.rb +9 -0
  53. data/lib/vendor/treetop/lib/treetop/compiler/ruby_builder.rb +113 -0
  54. data/lib/vendor/treetop/lib/treetop/ruby_extensions.rb +2 -0
  55. data/lib/vendor/treetop/lib/treetop/ruby_extensions/string.rb +42 -0
  56. data/lib/vendor/treetop/lib/treetop/runtime.rb +5 -0
  57. data/lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb +109 -0
  58. data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list.rb +4 -0
  59. data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/head_node.rb +15 -0
  60. data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/interval_skip_list.rb +200 -0
  61. data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/node.rb +164 -0
  62. data/lib/vendor/treetop/lib/treetop/runtime/syntax_node.rb +90 -0
  63. data/lib/vendor/treetop/lib/treetop/runtime/terminal_parse_failure.rb +16 -0
  64. data/lib/vendor/treetop/lib/treetop/runtime/terminal_syntax_node.rb +17 -0
  65. data/lib/vendor/treetop/lib/treetop/version.rb +9 -0
  66. data/lib/vendor/treetop/spec/compiler/and_predicate_spec.rb +36 -0
  67. data/lib/vendor/treetop/spec/compiler/anything_symbol_spec.rb +44 -0
  68. data/lib/vendor/treetop/spec/compiler/character_class_spec.rb +247 -0
  69. data/lib/vendor/treetop/spec/compiler/choice_spec.rb +80 -0
  70. data/lib/vendor/treetop/spec/compiler/circular_compilation_spec.rb +28 -0
  71. data/lib/vendor/treetop/spec/compiler/failure_propagation_functional_spec.rb +21 -0
  72. data/lib/vendor/treetop/spec/compiler/grammar_compiler_spec.rb +84 -0
  73. data/lib/vendor/treetop/spec/compiler/grammar_spec.rb +41 -0
  74. data/lib/vendor/treetop/spec/compiler/nonterminal_symbol_spec.rb +40 -0
  75. data/lib/vendor/treetop/spec/compiler/not_predicate_spec.rb +38 -0
  76. data/lib/vendor/treetop/spec/compiler/one_or_more_spec.rb +35 -0
  77. data/lib/vendor/treetop/spec/compiler/optional_spec.rb +37 -0
  78. data/lib/vendor/treetop/spec/compiler/parenthesized_expression_spec.rb +19 -0
  79. data/lib/vendor/treetop/spec/compiler/parsing_rule_spec.rb +32 -0
  80. data/lib/vendor/treetop/spec/compiler/sequence_spec.rb +115 -0
  81. data/lib/vendor/treetop/spec/compiler/terminal_spec.rb +81 -0
  82. data/lib/vendor/treetop/spec/compiler/terminal_symbol_spec.rb +37 -0
  83. data/lib/vendor/treetop/spec/compiler/test_grammar.treetop +7 -0
  84. data/lib/vendor/treetop/spec/compiler/test_grammar.tt +7 -0
  85. data/lib/vendor/treetop/spec/compiler/test_grammar_do.treetop +7 -0
  86. data/lib/vendor/treetop/spec/compiler/zero_or_more_spec.rb +56 -0
  87. data/lib/vendor/treetop/spec/composition/a.treetop +11 -0
  88. data/lib/vendor/treetop/spec/composition/b.treetop +11 -0
  89. data/lib/vendor/treetop/spec/composition/c.treetop +10 -0
  90. data/lib/vendor/treetop/spec/composition/d.treetop +10 -0
  91. data/lib/vendor/treetop/spec/composition/f.treetop +17 -0
  92. data/lib/vendor/treetop/spec/composition/grammar_composition_spec.rb +40 -0
  93. data/lib/vendor/treetop/spec/composition/subfolder/e_includes_c.treetop +15 -0
  94. data/lib/vendor/treetop/spec/ruby_extensions/string_spec.rb +32 -0
  95. data/lib/vendor/treetop/spec/runtime/compiled_parser_spec.rb +101 -0
  96. data/lib/vendor/treetop/spec/runtime/interval_skip_list/delete_spec.rb +147 -0
  97. data/lib/vendor/treetop/spec/runtime/interval_skip_list/expire_range_spec.rb +349 -0
  98. data/lib/vendor/treetop/spec/runtime/interval_skip_list/insert_and_delete_node.rb +385 -0
  99. data/lib/vendor/treetop/spec/runtime/interval_skip_list/insert_spec.rb +660 -0
  100. data/lib/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.graffle +6175 -0
  101. data/lib/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.rb +58 -0
  102. data/lib/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture.rb +23 -0
  103. data/lib/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb +164 -0
  104. data/lib/vendor/treetop/spec/runtime/interval_skip_list/spec_helper.rb +84 -0
  105. data/lib/vendor/treetop/spec/runtime/syntax_node_spec.rb +68 -0
  106. data/lib/vendor/treetop/spec/spec_helper.rb +106 -0
  107. data/lib/vendor/treetop/spec/spec_suite.rb +4 -0
  108. data/lib/vendor/treetop/treetop.gemspec +17 -0
  109. data/spec/command_spec.rb +2 -6
  110. data/spec/css/accessors-1.0.css +18 -0
  111. data/spec/css/big-1.0.css +3768 -0
  112. data/spec/css/comments-1.0.css +9 -0
  113. data/spec/css/css-1.0.css +40 -0
  114. data/spec/css/functions-1.0.css +6 -0
  115. data/spec/css/import-1.0.css +11 -0
  116. data/spec/css/mixins-1.0.css +28 -0
  117. data/spec/css/operations-1.0.css +28 -0
  118. data/spec/css/rulesets-1.0.css +17 -0
  119. data/spec/css/scope-1.0.css +14 -0
  120. data/spec/css/strings-1.0.css +12 -0
  121. data/spec/css/variables-1.0.css +6 -0
  122. data/spec/css/whitespace-1.0.css +9 -0
  123. data/spec/engine_spec.rb +66 -18
  124. data/spec/less/accessors-1.0.less +20 -0
  125. data/spec/less/big-1.0.less +4810 -0
  126. data/spec/less/colors-1.0.less +0 -0
  127. data/spec/less/comments-1.0.less +46 -0
  128. data/spec/less/css-1.0.less +84 -0
  129. data/spec/less/exceptions/mixed-units-error.less +3 -0
  130. data/spec/less/exceptions/name-error-1.0.less +3 -0
  131. data/spec/less/exceptions/syntax-error-1.0.less +3 -0
  132. data/spec/less/functions-1.0.less +6 -0
  133. data/spec/less/import-1.0.less +7 -0
  134. data/spec/less/import/import-test-a.less +2 -0
  135. data/spec/less/import/import-test-b.less +8 -0
  136. data/spec/less/import/import-test-c.less +5 -0
  137. data/spec/less/mixins-1.0.less +43 -0
  138. data/spec/less/operations-1.0.less +39 -0
  139. data/spec/less/rulesets-1.0.less +30 -0
  140. data/spec/less/scope-1.0.less +33 -0
  141. data/spec/less/strings-1.0.less +14 -0
  142. data/spec/less/variables-1.0.less +18 -0
  143. data/spec/less/whitespace-1.0.less +21 -0
  144. data/spec/spec.css +79 -24
  145. data/spec/spec.less +2 -3
  146. data/spec/spec_helper.rb +4 -1
  147. metadata +136 -13
  148. data/lib/less/tree.rb +0 -82
  149. data/spec/css/less-0.8.10.css +0 -30
  150. data/spec/css/less-0.8.11.css +0 -31
  151. data/spec/css/less-0.8.12.css +0 -28
  152. data/spec/css/less-0.8.5.css +0 -24
  153. data/spec/css/less-0.8.6.css +0 -24
  154. data/spec/css/less-0.8.7.css +0 -24
  155. data/spec/css/less-0.8.8.css +0 -25
  156. data/spec/tree_spec.rb +0 -5
data/README.md CHANGED
@@ -27,4 +27,13 @@ LESS allows you to write CSS the way (I think) it was meant to, that is: with *v
27
27
  If you have CSS nightmares, just
28
28
  $ lessc style.less
29
29
 
30
- For more information, see you at http://lesscss.org
30
+ For more information, see you at [http://lesscss.org]
31
+
32
+ People without whom this wouldn't have happened a.k.a *Credits*
33
+ ---------------------------------------------------------------
34
+
35
+ - **Dmitry Fadeyev**, for pushing me to do this, and designing our awesome website
36
+ - **August Lilleaas**, for initiating the work on the treetop grammar, as well as writing the rails plugin
37
+ - **Nathan Sobo**, for creating treetop
38
+ - **Jason Garber**, for his magical performance optimizations on treetop
39
+ - And finally, the people of #ruby-lang for answering all my ruby questions. **apeiros**, **manveru** and **rue** come to mind
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ begin
3
3
  Jeweler::Tasks.new do |s|
4
4
  s.name = "less"
5
5
  s.authors = ["cloudhead"]
6
- s.email = "alexis@cloudhead.net"
6
+ s.email = "self@cloudhead.net"
7
7
  s.summary = "LESS compiler"
8
8
  s.homepage = "http://www.lesscss.org"
9
9
  s.description = "LESS is leaner CSS"
@@ -17,7 +17,6 @@ end
17
17
  begin
18
18
  require 'rake/contrib/sshpublisher'
19
19
  namespace :rubyforge do
20
-
21
20
  desc "Release gem and RDoc documentation to RubyForge"
22
21
  task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
23
22
 
@@ -58,4 +57,23 @@ begin
58
57
  t.rcov = true
59
58
  t.rcov_opts = ['--exclude', '^spec,/gems/']
60
59
  end
61
- end
60
+ end
61
+
62
+ begin
63
+ require 'lib/less'
64
+
65
+ task :compile do
66
+ puts "compiling #{LESS_GRAMMAR.split('/').last}..."
67
+ File.open(LESS_PARSER, 'w') {|f| f.write Treetop::Compiler::GrammarCompiler.new.ruby_source(LESS_GRAMMAR) }
68
+ end
69
+
70
+ task :benchmark do
71
+ print "benchmarking... "
72
+ less = File.read("spec/less/big-1.0.less")
73
+ start = Time.now.to_f
74
+ Less::Engine.new(less).parse
75
+ total = Time.now.to_f - start
76
+ puts "#{total}s"
77
+ end
78
+ end
79
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.13
1
+ 1.0.4
data/bin/lessc CHANGED
@@ -5,14 +5,11 @@ $:.unshift File.dirname(__FILE__) + "/../lib"
5
5
  require 'optparse'
6
6
  require 'less'
7
7
 
8
- CSS = '.css'
9
-
10
8
  # Argument defaults
11
9
  options = {
12
10
  :watch => false,
13
11
  :compress => false,
14
12
  :debug => false,
15
- :inheritance => :desc
16
13
  }
17
14
 
18
15
  # Get arguments
@@ -25,11 +22,6 @@ opts = OptionParser.new do |o|
25
22
  options[:watch] = true
26
23
  end
27
24
 
28
- # Child-type inheritance
29
- o.on("-c", "--child", "nesting uses child-type inheritance") do
30
- options[:chain] = :child
31
- end
32
-
33
25
  # Compression needs a proper algorithm
34
26
  #
35
27
  # o.on("-x", "--compress", "compress css file") do
@@ -2,14 +2,14 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{less}
5
- s.version = "0.8.13"
5
+ s.version = "1.0.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["cloudhead"]
9
- s.date = %q{2009-06-23}
9
+ s.date = %q{2009-07-13}
10
10
  s.default_executable = %q{lessc}
11
11
  s.description = %q{LESS is leaner CSS}
12
- s.email = %q{alexis@cloudhead.net}
12
+ s.email = %q{self@cloudhead.net}
13
13
  s.executables = ["lessc"]
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -26,20 +26,144 @@ Gem::Specification.new do |s|
26
26
  "lib/less.rb",
27
27
  "lib/less/command.rb",
28
28
  "lib/less/engine.rb",
29
- "lib/less/tree.rb",
29
+ "lib/less/engine/builder.rb",
30
+ "lib/less/engine/less.tt",
31
+ "lib/less/engine/nodes.rb",
32
+ "lib/less/engine/nodes/element.rb",
33
+ "lib/less/engine/nodes/entity.rb",
34
+ "lib/less/engine/nodes/function.rb",
35
+ "lib/less/engine/nodes/literal.rb",
36
+ "lib/less/engine/nodes/property.rb",
37
+ "lib/less/engine/nodes/selector.rb",
38
+ "lib/less/engine/parser.rb",
39
+ "lib/vendor/treetop/.gitignore",
40
+ "lib/vendor/treetop/LICENSE",
41
+ "lib/vendor/treetop/README",
42
+ "lib/vendor/treetop/Rakefile",
43
+ "lib/vendor/treetop/benchmark/seqpar.gnuplot",
44
+ "lib/vendor/treetop/benchmark/seqpar.treetop",
45
+ "lib/vendor/treetop/benchmark/seqpar_benchmark.rb",
46
+ "lib/vendor/treetop/bin/tt",
47
+ "lib/vendor/treetop/lib/treetop.rb",
48
+ "lib/vendor/treetop/lib/treetop/bootstrap_gen_1_metagrammar.rb",
49
+ "lib/vendor/treetop/lib/treetop/compiler.rb",
50
+ "lib/vendor/treetop/lib/treetop/compiler/grammar_compiler.rb",
51
+ "lib/vendor/treetop/lib/treetop/compiler/lexical_address_space.rb",
52
+ "lib/vendor/treetop/lib/treetop/compiler/metagrammar.rb",
53
+ "lib/vendor/treetop/lib/treetop/compiler/metagrammar.treetop",
54
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes.rb",
55
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/anything_symbol.rb",
56
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/atomic_expression.rb",
57
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/character_class.rb",
58
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/choice.rb",
59
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/declaration_sequence.rb",
60
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/grammar.rb",
61
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/inline_module.rb",
62
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/nonterminal.rb",
63
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/optional.rb",
64
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/parenthesized_expression.rb",
65
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/parsing_expression.rb",
66
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/parsing_rule.rb",
67
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/predicate.rb",
68
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/repetition.rb",
69
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/sequence.rb",
70
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/terminal.rb",
71
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/transient_prefix.rb",
72
+ "lib/vendor/treetop/lib/treetop/compiler/node_classes/treetop_file.rb",
73
+ "lib/vendor/treetop/lib/treetop/compiler/ruby_builder.rb",
74
+ "lib/vendor/treetop/lib/treetop/ruby_extensions.rb",
75
+ "lib/vendor/treetop/lib/treetop/ruby_extensions/string.rb",
76
+ "lib/vendor/treetop/lib/treetop/runtime.rb",
77
+ "lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb",
78
+ "lib/vendor/treetop/lib/treetop/runtime/interval_skip_list.rb",
79
+ "lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/head_node.rb",
80
+ "lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/interval_skip_list.rb",
81
+ "lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/node.rb",
82
+ "lib/vendor/treetop/lib/treetop/runtime/syntax_node.rb",
83
+ "lib/vendor/treetop/lib/treetop/runtime/terminal_parse_failure.rb",
84
+ "lib/vendor/treetop/lib/treetop/runtime/terminal_syntax_node.rb",
85
+ "lib/vendor/treetop/lib/treetop/version.rb",
86
+ "lib/vendor/treetop/spec/compiler/and_predicate_spec.rb",
87
+ "lib/vendor/treetop/spec/compiler/anything_symbol_spec.rb",
88
+ "lib/vendor/treetop/spec/compiler/character_class_spec.rb",
89
+ "lib/vendor/treetop/spec/compiler/choice_spec.rb",
90
+ "lib/vendor/treetop/spec/compiler/circular_compilation_spec.rb",
91
+ "lib/vendor/treetop/spec/compiler/failure_propagation_functional_spec.rb",
92
+ "lib/vendor/treetop/spec/compiler/grammar_compiler_spec.rb",
93
+ "lib/vendor/treetop/spec/compiler/grammar_spec.rb",
94
+ "lib/vendor/treetop/spec/compiler/nonterminal_symbol_spec.rb",
95
+ "lib/vendor/treetop/spec/compiler/not_predicate_spec.rb",
96
+ "lib/vendor/treetop/spec/compiler/one_or_more_spec.rb",
97
+ "lib/vendor/treetop/spec/compiler/optional_spec.rb",
98
+ "lib/vendor/treetop/spec/compiler/parenthesized_expression_spec.rb",
99
+ "lib/vendor/treetop/spec/compiler/parsing_rule_spec.rb",
100
+ "lib/vendor/treetop/spec/compiler/sequence_spec.rb",
101
+ "lib/vendor/treetop/spec/compiler/terminal_spec.rb",
102
+ "lib/vendor/treetop/spec/compiler/terminal_symbol_spec.rb",
103
+ "lib/vendor/treetop/spec/compiler/test_grammar.treetop",
104
+ "lib/vendor/treetop/spec/compiler/test_grammar.tt",
105
+ "lib/vendor/treetop/spec/compiler/test_grammar_do.treetop",
106
+ "lib/vendor/treetop/spec/compiler/zero_or_more_spec.rb",
107
+ "lib/vendor/treetop/spec/composition/a.treetop",
108
+ "lib/vendor/treetop/spec/composition/b.treetop",
109
+ "lib/vendor/treetop/spec/composition/c.treetop",
110
+ "lib/vendor/treetop/spec/composition/d.treetop",
111
+ "lib/vendor/treetop/spec/composition/f.treetop",
112
+ "lib/vendor/treetop/spec/composition/grammar_composition_spec.rb",
113
+ "lib/vendor/treetop/spec/composition/subfolder/e_includes_c.treetop",
114
+ "lib/vendor/treetop/spec/ruby_extensions/string_spec.rb",
115
+ "lib/vendor/treetop/spec/runtime/compiled_parser_spec.rb",
116
+ "lib/vendor/treetop/spec/runtime/interval_skip_list/delete_spec.rb",
117
+ "lib/vendor/treetop/spec/runtime/interval_skip_list/expire_range_spec.rb",
118
+ "lib/vendor/treetop/spec/runtime/interval_skip_list/insert_and_delete_node.rb",
119
+ "lib/vendor/treetop/spec/runtime/interval_skip_list/insert_spec.rb",
120
+ "lib/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.graffle",
121
+ "lib/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.rb",
122
+ "lib/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture.rb",
123
+ "lib/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb",
124
+ "lib/vendor/treetop/spec/runtime/interval_skip_list/spec_helper.rb",
125
+ "lib/vendor/treetop/spec/runtime/syntax_node_spec.rb",
126
+ "lib/vendor/treetop/spec/spec_helper.rb",
127
+ "lib/vendor/treetop/spec/spec_suite.rb",
128
+ "lib/vendor/treetop/treetop.gemspec",
30
129
  "spec/command_spec.rb",
31
- "spec/css/less-0.8.10.css",
32
- "spec/css/less-0.8.11.css",
33
- "spec/css/less-0.8.12.css",
34
- "spec/css/less-0.8.5.css",
35
- "spec/css/less-0.8.6.css",
36
- "spec/css/less-0.8.7.css",
37
- "spec/css/less-0.8.8.css",
130
+ "spec/css/accessors-1.0.css",
131
+ "spec/css/big-1.0.css",
132
+ "spec/css/comments-1.0.css",
133
+ "spec/css/css-1.0.css",
134
+ "spec/css/functions-1.0.css",
135
+ "spec/css/import-1.0.css",
136
+ "spec/css/mixins-1.0.css",
137
+ "spec/css/operations-1.0.css",
138
+ "spec/css/rulesets-1.0.css",
139
+ "spec/css/scope-1.0.css",
140
+ "spec/css/strings-1.0.css",
141
+ "spec/css/variables-1.0.css",
142
+ "spec/css/whitespace-1.0.css",
38
143
  "spec/engine_spec.rb",
144
+ "spec/less/accessors-1.0.less",
145
+ "spec/less/big-1.0.less",
146
+ "spec/less/colors-1.0.less",
147
+ "spec/less/comments-1.0.less",
148
+ "spec/less/css-1.0.less",
149
+ "spec/less/exceptions/mixed-units-error.less",
150
+ "spec/less/exceptions/name-error-1.0.less",
151
+ "spec/less/exceptions/syntax-error-1.0.less",
152
+ "spec/less/functions-1.0.less",
153
+ "spec/less/import-1.0.less",
154
+ "spec/less/import/import-test-a.less",
155
+ "spec/less/import/import-test-b.less",
156
+ "spec/less/import/import-test-c.less",
157
+ "spec/less/mixins-1.0.less",
158
+ "spec/less/operations-1.0.less",
159
+ "spec/less/rulesets-1.0.less",
160
+ "spec/less/scope-1.0.less",
161
+ "spec/less/strings-1.0.less",
162
+ "spec/less/variables-1.0.less",
163
+ "spec/less/whitespace-1.0.less",
39
164
  "spec/spec.css",
40
165
  "spec/spec.less",
41
- "spec/spec_helper.rb",
42
- "spec/tree_spec.rb"
166
+ "spec/spec_helper.rb"
43
167
  ]
44
168
  s.has_rdoc = true
45
169
  s.homepage = %q{http://www.lesscss.org}
@@ -51,8 +175,7 @@ Gem::Specification.new do |s|
51
175
  s.test_files = [
52
176
  "spec/command_spec.rb",
53
177
  "spec/engine_spec.rb",
54
- "spec/spec_helper.rb",
55
- "spec/tree_spec.rb"
178
+ "spec/spec_helper.rb"
56
179
  ]
57
180
 
58
181
  if s.respond_to? :specification_version then
@@ -1,24 +1,80 @@
1
- $:.unshift File.dirname(__FILE__)
1
+ $:.unshift File.join(File.dirname(__FILE__), 'vendor', 'treetop', 'lib'),
2
+ File.dirname(__FILE__)
2
3
 
3
4
  require 'cgi'
5
+ require 'treetop'
6
+ require 'delegate'
7
+
8
+ LESS_ROOT = File.expand_path(File.dirname(__FILE__))
9
+ LESS_PARSER = File.join(LESS_ROOT, 'less', 'engine', 'parser.rb')
10
+ LESS_GRAMMAR = File.join(LESS_ROOT, 'less', 'engine', 'less.tt')
4
11
 
5
12
  require 'less/command'
6
13
  require 'less/engine'
7
- require 'less/tree'
8
14
 
9
- module Less
10
- MixedUnitsError = Class.new(Exception)
11
- PathError = Class.new(Exception)
12
- CompoundOperationError = Class.new(Exception)
15
+ module Less
16
+ MixedUnitsError = Class.new(Exception)
17
+ PathError = Class.new(Exception)
18
+ VariableNameError = Class.new(NameError)
19
+ MixinNameError = Class.new(NameError)
20
+ SyntaxError = Class.new(RuntimeError)
21
+ ImportError = Class.new(Exception)
22
+
23
+ $verbose = false
13
24
 
14
25
  def self.version
15
- File.read( File.join( File.dirname(__FILE__), '..', 'VERSION') )
26
+ File.read( File.join( File.dirname(__FILE__), '..', 'VERSION') ).strip
27
+ end
28
+
29
+ def self.parse less
30
+ Engine.new(less).to_css
31
+ end
32
+ end
33
+
34
+ module Treetop
35
+ module Runtime
36
+ class CompiledParser
37
+ def failure_message
38
+ return nil unless (tf = terminal_failures) && tf.size > 0
39
+ "on line #{failure_line}: expected " + (
40
+ tf.size == 1 ?
41
+ tf[0].expected_string :
42
+ "one of #{tf.map {|f| f.expected_string }.uniq * ' '}"
43
+ ) +
44
+ " got `#{input[failure_index]}`" +
45
+ " after:\n\n#{input[index...failure_index]}\n"
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ class Object
52
+ def verbose
53
+ $verbose = true
54
+ yield
55
+ ensure
56
+ $verbose = false
57
+ end
58
+
59
+ def tap
60
+ yield self
61
+ self
62
+ end
63
+
64
+ def log(s = '') puts "* #{s}" if $verbose end
65
+ def log!(s = '') puts "* #{s}" end
66
+ def error(s) $stderr.puts s end
67
+ def error!(s) raise Exception, s end
68
+ end
69
+
70
+ class Class
71
+ def to_sym
72
+ self.to_s.to_sym
16
73
  end
17
74
  end
18
75
 
19
- class Hash
20
- # Convert a hash into a Tree
21
- def to_tree
22
- Less::Tree.new self
76
+ class Symbol
77
+ def to_proc
78
+ proc {|obj, *args| obj.send(self, *args) }
23
79
  end
24
80
  end
@@ -1,12 +1,11 @@
1
1
  module Less
2
2
  class Command
3
- CSS = '.css'
4
-
5
3
  attr_accessor :source, :destination, :options
6
4
 
7
5
  def initialize options
6
+ $verbose = options[:debug]
8
7
  @source = options[:source]
9
- @destination = (options[:destination] || options[:source]).gsub /\.(less|lss)/, CSS
8
+ @destination = (options[:destination] || options[:source]).gsub /\.(less|lss)/, '.css'
10
9
  @options = options
11
10
  end
12
11
 
@@ -16,9 +15,9 @@ module Less
16
15
 
17
16
  # little function which allows us to
18
17
  # Ctrl-C exit inside the passed block
19
- def watch &block
18
+ def watch
20
19
  begin
21
- block.call
20
+ yield
22
21
  rescue Interrupt
23
22
  puts
24
23
  exit 0
@@ -26,10 +25,10 @@ module Less
26
25
  end
27
26
 
28
27
  def run!
29
- compile(true) unless File.exist? @destination
28
+ parse(true) unless File.exist? @destination
30
29
 
31
30
  if watch?
32
- log "Watching for changes in #@source ...Ctrl-C to abort.\n"
31
+ log "Watching for changes in #@source... Ctrl-C to abort.\n: "
33
32
 
34
33
  # Main watch loop
35
34
  loop do
@@ -37,55 +36,55 @@ module Less
37
36
 
38
37
  # File has changed
39
38
  if File.stat( @source ).mtime > File.stat( @destination ).mtime
40
- log "Change detected... "
39
+ print "Change detected... "
41
40
 
42
41
  # Loop until error is fixed
43
- until compile
44
- log "Press [enter] to continue..."
42
+ until parse
43
+ log "Press [return] to continue..."
45
44
  watch { $stdin.gets }
46
45
  end
47
46
  end
48
47
  end
49
48
  else
50
- compile
49
+ parse
51
50
  end
52
51
  end
53
52
 
54
- def compile new = false
53
+ def parse new = false
55
54
  begin
56
55
  # Create a new Less object with the contents of a file
57
- css = Less::Engine.new( File.read( @source ) ).to_css @options[:inheritance]
56
+ css = Less::Engine.new(File.new @source).to_css
58
57
  css = css.delete " \n" if compress?
59
58
 
60
59
  File.open( @destination, "w" ) do |file|
61
60
  file.write css
62
61
  end
63
- puts "#{new ? '* [Created]' : ' [Updated]'} #{@destination.split('/').last}" if watch?
62
+ print "#{new ? '* [Created]' : '* [Updated]'} #{@destination.split('/').last}\n: " if watch?
64
63
  rescue Errno::ENOENT => e
65
64
  abort "#{e}"
66
- rescue SyntaxError
67
- error = debug?? $! : $!.message.split("\n")[1..-1].collect {|e|
68
- e.gsub(/\(eval\)\:(\d+)\:\s/, 'line \1: ')
69
- } * "\n"
70
- err "errors were found in the .less file! \n#{error}\n"
65
+ rescue SyntaxError => e
66
+ err "#{e}\n", "Parse"
71
67
  rescue MixedUnitsError => e
72
68
  err "`#{e}` you're mixing units together! What do you expect?\n"
73
- rescue CompoundOperationError => e
74
- err "`#{e}` operations in compound declarations aren't allowed, sorry!\n"
75
69
  rescue PathError => e
76
- err "`#{e}` was not found.\n"
70
+ err "`#{e}` was not found.\n", "Path"
71
+ rescue VariableNameError => e
72
+ err "`#{e}` is undefined.\n", "Name"
73
+ rescue MixinNameError => e
74
+ err "`#{e}` is undefined.\n", "Name"
77
75
  else
78
76
  true
79
77
  end
80
78
  end
81
79
 
82
- # Just a logging function to avoid typing '}'
80
+ # Just a logging function to avoid typing '*'
83
81
  def log s = ''
84
82
  print '* ' + s.to_s
85
83
  end
86
84
 
87
- def err s = ''
88
- print "!! #{s}"
85
+ def err s = '', type = ''
86
+ type = type.strip + ' ' unless type.empty?
87
+ print "! [#{type}Error] #{s}"
89
88
  end
90
89
  end
91
90
  end