less 1.1.13 → 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/Rakefile +13 -41
  2. data/VERSION +1 -1
  3. data/bin/lessc +8 -2
  4. data/less.gemspec +13 -92
  5. data/lib/ext.rb +15 -19
  6. data/lib/less.rb +2 -2
  7. data/lib/less/command.rb +14 -15
  8. data/lib/less/engine.rb +3 -2
  9. data/lib/less/engine/grammar/common.tt +1 -1
  10. data/lib/less/engine/grammar/entity.tt +5 -5
  11. data/lib/less/engine/grammar/less.tt +107 -77
  12. data/lib/less/engine/nodes/element.rb +103 -24
  13. data/lib/less/engine/nodes/entity.rb +3 -3
  14. data/lib/less/engine/nodes/function.rb +11 -6
  15. data/lib/less/engine/nodes/literal.rb +8 -4
  16. data/lib/less/engine/nodes/property.rb +98 -38
  17. data/lib/less/engine/nodes/selector.rb +1 -1
  18. data/spec/css/css-3.css +14 -0
  19. data/spec/css/mixins-args.css +31 -0
  20. data/spec/css/variables.css +1 -0
  21. data/spec/css/whitespace.css +1 -0
  22. data/spec/engine_spec.rb +4 -3
  23. data/spec/less/css-3.less +30 -0
  24. data/spec/less/hidden.less +25 -0
  25. data/spec/less/import.less +1 -0
  26. data/spec/less/literal-css.less +11 -0
  27. data/spec/less/mixins-args.less +50 -0
  28. data/spec/less/variables.less +7 -1
  29. data/spec/less/whitespace.less +1 -0
  30. data/spec/spec_helper.rb +2 -2
  31. metadata +25 -94
  32. data/lib/vendor/treetop/.gitignore +0 -7
  33. data/lib/vendor/treetop/LICENSE +0 -19
  34. data/lib/vendor/treetop/README +0 -164
  35. data/lib/vendor/treetop/Rakefile +0 -19
  36. data/lib/vendor/treetop/benchmark/seqpar.gnuplot +0 -15
  37. data/lib/vendor/treetop/benchmark/seqpar.treetop +0 -16
  38. data/lib/vendor/treetop/benchmark/seqpar_benchmark.rb +0 -107
  39. data/lib/vendor/treetop/bin/tt +0 -28
  40. data/lib/vendor/treetop/lib/treetop.rb +0 -8
  41. data/lib/vendor/treetop/lib/treetop/bootstrap_gen_1_metagrammar.rb +0 -45
  42. data/lib/vendor/treetop/lib/treetop/compiler.rb +0 -6
  43. data/lib/vendor/treetop/lib/treetop/compiler/grammar_compiler.rb +0 -42
  44. data/lib/vendor/treetop/lib/treetop/compiler/lexical_address_space.rb +0 -17
  45. data/lib/vendor/treetop/lib/treetop/compiler/metagrammar.rb +0 -3097
  46. data/lib/vendor/treetop/lib/treetop/compiler/metagrammar.treetop +0 -408
  47. data/lib/vendor/treetop/lib/treetop/compiler/node_classes.rb +0 -19
  48. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/anything_symbol.rb +0 -18
  49. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/atomic_expression.rb +0 -14
  50. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/character_class.rb +0 -24
  51. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/choice.rb +0 -31
  52. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/declaration_sequence.rb +0 -24
  53. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/grammar.rb +0 -28
  54. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/inline_module.rb +0 -27
  55. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/nonterminal.rb +0 -13
  56. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/optional.rb +0 -19
  57. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parenthesized_expression.rb +0 -9
  58. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parsing_expression.rb +0 -138
  59. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parsing_rule.rb +0 -55
  60. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/predicate.rb +0 -45
  61. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/repetition.rb +0 -55
  62. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/sequence.rb +0 -68
  63. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/terminal.rb +0 -20
  64. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/transient_prefix.rb +0 -9
  65. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/treetop_file.rb +0 -9
  66. data/lib/vendor/treetop/lib/treetop/compiler/ruby_builder.rb +0 -113
  67. data/lib/vendor/treetop/lib/treetop/ruby_extensions.rb +0 -2
  68. data/lib/vendor/treetop/lib/treetop/ruby_extensions/string.rb +0 -42
  69. data/lib/vendor/treetop/lib/treetop/runtime.rb +0 -5
  70. data/lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb +0 -105
  71. data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list.rb +0 -4
  72. data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/head_node.rb +0 -15
  73. data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/interval_skip_list.rb +0 -200
  74. data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/node.rb +0 -164
  75. data/lib/vendor/treetop/lib/treetop/runtime/syntax_node.rb +0 -72
  76. data/lib/vendor/treetop/lib/treetop/runtime/terminal_parse_failure.rb +0 -16
  77. data/lib/vendor/treetop/lib/treetop/runtime/terminal_syntax_node.rb +0 -17
  78. data/lib/vendor/treetop/lib/treetop/version.rb +0 -9
  79. data/lib/vendor/treetop/spec/compiler/and_predicate_spec.rb +0 -36
  80. data/lib/vendor/treetop/spec/compiler/anything_symbol_spec.rb +0 -44
  81. data/lib/vendor/treetop/spec/compiler/character_class_spec.rb +0 -182
  82. data/lib/vendor/treetop/spec/compiler/choice_spec.rb +0 -80
  83. data/lib/vendor/treetop/spec/compiler/circular_compilation_spec.rb +0 -28
  84. data/lib/vendor/treetop/spec/compiler/failure_propagation_functional_spec.rb +0 -21
  85. data/lib/vendor/treetop/spec/compiler/grammar_compiler_spec.rb +0 -84
  86. data/lib/vendor/treetop/spec/compiler/grammar_spec.rb +0 -41
  87. data/lib/vendor/treetop/spec/compiler/nonterminal_symbol_spec.rb +0 -40
  88. data/lib/vendor/treetop/spec/compiler/not_predicate_spec.rb +0 -38
  89. data/lib/vendor/treetop/spec/compiler/one_or_more_spec.rb +0 -35
  90. data/lib/vendor/treetop/spec/compiler/optional_spec.rb +0 -37
  91. data/lib/vendor/treetop/spec/compiler/parenthesized_expression_spec.rb +0 -19
  92. data/lib/vendor/treetop/spec/compiler/parsing_rule_spec.rb +0 -32
  93. data/lib/vendor/treetop/spec/compiler/sequence_spec.rb +0 -115
  94. data/lib/vendor/treetop/spec/compiler/terminal_spec.rb +0 -81
  95. data/lib/vendor/treetop/spec/compiler/terminal_symbol_spec.rb +0 -37
  96. data/lib/vendor/treetop/spec/compiler/test_grammar.treetop +0 -7
  97. data/lib/vendor/treetop/spec/compiler/test_grammar.tt +0 -7
  98. data/lib/vendor/treetop/spec/compiler/test_grammar_do.treetop +0 -7
  99. data/lib/vendor/treetop/spec/compiler/zero_or_more_spec.rb +0 -56
  100. data/lib/vendor/treetop/spec/composition/a.treetop +0 -11
  101. data/lib/vendor/treetop/spec/composition/b.treetop +0 -11
  102. data/lib/vendor/treetop/spec/composition/c.treetop +0 -10
  103. data/lib/vendor/treetop/spec/composition/d.treetop +0 -10
  104. data/lib/vendor/treetop/spec/composition/f.treetop +0 -17
  105. data/lib/vendor/treetop/spec/composition/grammar_composition_spec.rb +0 -40
  106. data/lib/vendor/treetop/spec/composition/subfolder/e_includes_c.treetop +0 -15
  107. data/lib/vendor/treetop/spec/ruby_extensions/string_spec.rb +0 -32
  108. data/lib/vendor/treetop/spec/runtime/compiled_parser_spec.rb +0 -101
  109. data/lib/vendor/treetop/spec/runtime/interval_skip_list/delete_spec.rb +0 -147
  110. data/lib/vendor/treetop/spec/runtime/interval_skip_list/expire_range_spec.rb +0 -349
  111. data/lib/vendor/treetop/spec/runtime/interval_skip_list/insert_and_delete_node.rb +0 -385
  112. data/lib/vendor/treetop/spec/runtime/interval_skip_list/insert_spec.rb +0 -660
  113. data/lib/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.graffle +0 -6175
  114. data/lib/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.rb +0 -58
  115. data/lib/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture.rb +0 -23
  116. data/lib/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb +0 -164
  117. data/lib/vendor/treetop/spec/runtime/interval_skip_list/spec_helper.rb +0 -84
  118. data/lib/vendor/treetop/spec/runtime/syntax_node_spec.rb +0 -53
  119. data/lib/vendor/treetop/spec/spec_helper.rb +0 -106
  120. data/lib/vendor/treetop/spec/spec_suite.rb +0 -4
  121. data/lib/vendor/treetop/treetop.gemspec +0 -17
@@ -1,24 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class CharacterClass < AtomicExpression
4
- def compile(address, builder, parent_expression = nil)
5
- super
6
-
7
- builder.if__ "has_terminal?(#{grounded_regexp(text_value)}, true, index)" do
8
- assign_result "instantiate_node(#{node_class_name},input, index...(index + 1))"
9
- extend_result_with_inline_module
10
- builder << "@index += 1"
11
- end
12
- builder.else_ do
13
- "terminal_parse_failure(#{single_quote(characters)})"
14
- assign_result 'nil'
15
- end
16
- end
17
-
18
- def grounded_regexp(string)
19
- # Double any backslashes, then backslash any single-quotes:
20
- "'\\G#{string.gsub(/\\/) { '\\\\' }.gsub(/'/) { "\\'"}}'"
21
- end
22
- end
23
- end
24
- end
@@ -1,31 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class Choice < ParsingExpression
4
- def compile(address, builder, parent_expression = nil)
5
- super
6
- begin_comment(self)
7
- use_vars :result, :start_index
8
- compile_alternatives(alternatives)
9
- end_comment(self)
10
- end
11
-
12
- def compile_alternatives(alternatives)
13
- obtain_new_subexpression_address
14
- alternatives.first.compile(subexpression_address, builder)
15
- builder.if__ subexpression_success? do
16
- assign_result subexpression_result_var
17
- extend_result_with_declared_module
18
- extend_result_with_inline_module
19
- end
20
- builder.else_ do
21
- if alternatives.size == 1
22
- reset_index
23
- assign_failure start_index_var
24
- else
25
- compile_alternatives(alternatives[1..-1])
26
- end
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,24 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class DeclarationSequence < Runtime::SyntaxNode
4
-
5
- def compile(builder)
6
- unless rules.empty?
7
- builder.method_declaration("root") do
8
- builder << "@root || :#{rules.first.name}"
9
- end
10
- builder.newline
11
- end
12
-
13
- declarations.each do |declaration|
14
- declaration.compile(builder)
15
- builder.newline
16
- end
17
- end
18
-
19
- def rules
20
- declarations.select { |declaration| declaration.instance_of?(ParsingRule) }
21
- end
22
- end
23
- end
24
- end
@@ -1,28 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class Grammar < Runtime::SyntaxNode
4
- def compile
5
- builder = RubyBuilder.new
6
-
7
- builder.module_declaration "#{grammar_name.text_value}" do
8
- builder.in(indent_level) # account for initial indentation of grammar declaration
9
- builder << "include Treetop::Runtime"
10
- builder.newline
11
- declaration_sequence.compile(builder)
12
- end
13
- builder.newline
14
- builder.class_declaration "#{parser_name} < Treetop::Runtime::CompiledParser" do
15
- builder << "include #{grammar_name.text_value}"
16
- end
17
- end
18
-
19
- def indent_level
20
- input.column_of(interval.begin) - 1
21
- end
22
-
23
- def parser_name
24
- grammar_name.text_value + 'Parser'
25
- end
26
- end
27
- end
28
- end
@@ -1,27 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- module InlineModuleMixin
4
- attr_reader :module_name
5
-
6
- def compile(index, builder, rule)
7
- @module_name = "#{rule.name.treetop_camelize}#{index}"
8
- end
9
- end
10
-
11
- class InlineModule < Runtime::SyntaxNode
12
-
13
- include InlineModuleMixin
14
-
15
- def compile(index, builder, rule)
16
- super
17
- builder.module_declaration(module_name) do
18
- builder << ruby_code.gsub(/\A\n/, '').rstrip
19
- end
20
- end
21
-
22
- def ruby_code
23
- elements[1].text_value
24
- end
25
- end
26
- end
27
- end
@@ -1,13 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class Nonterminal < AtomicExpression
4
- def compile(address, builder, parent_expression = nil)
5
- super
6
- use_vars :result
7
- assign_result text_value == 'super' ? 'super' : "_nt_#{text_value}"
8
- extend_result_with_declared_module
9
- extend_result_with_inline_module
10
- end
11
- end
12
- end
13
- end
@@ -1,19 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class Optional < ParsingExpression
4
- def compile(address, builder, parent_expression)
5
- super
6
- use_vars :result
7
- obtain_new_subexpression_address
8
- parent_expression.atomic.compile(subexpression_address, builder)
9
-
10
- builder.if__ subexpression_success? do
11
- assign_result subexpression_result_var
12
- end
13
- builder.else_ do
14
- assign_result epsilon_node
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,9 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class ParenthesizedExpression < ParsingExpression
4
- def compile(address, builder, parent_expression = nil)
5
- elements[2].compile(address, builder, parent_expression)
6
- end
7
- end
8
- end
9
- end
@@ -1,138 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class ParsingExpression < Runtime::SyntaxNode
4
- attr_reader :address, :builder, :subexpression_address, :var_symbols, :parent_expression
5
-
6
- def compile(address, builder, parent_expression)
7
- @address = address
8
- @builder = builder
9
- @parent_expression = parent_expression
10
- end
11
-
12
- def node_class_name
13
- parent_expression && parent_expression.node_class_name || 'SyntaxNode'
14
- end
15
-
16
- def declared_module_name
17
- parent_expression && parent_expression.node_class_name
18
- end
19
-
20
- def inline_module_name
21
- parent_expression && parent_expression.inline_module_name
22
- end
23
-
24
- def optional_arg(arg)
25
- if arg
26
- ", #{arg}"
27
- else
28
- ''
29
- end
30
- end
31
-
32
- def use_vars(*var_symbols)
33
- @var_symbols = var_symbols
34
- builder << var_initialization
35
- end
36
-
37
- def result_var
38
- var(:result)
39
- end
40
-
41
- def accumulator_var
42
- var(:accumulator)
43
- end
44
-
45
- def start_index_var
46
- var(:start_index)
47
- end
48
-
49
- def subexpression_result_var
50
- "r#{subexpression_address}"
51
- end
52
-
53
- def subexpression_success?
54
- subexpression_result_var
55
- end
56
-
57
- def obtain_new_subexpression_address
58
- @subexpression_address = builder.next_address
59
- end
60
-
61
- def accumulate_subexpression_result
62
- builder.accumulate accumulator_var, subexpression_result_var
63
- end
64
-
65
- def assign_result(value_ruby)
66
- builder.assign result_var, value_ruby
67
- end
68
-
69
- def extend_result(module_name)
70
- builder.extend result_var, module_name
71
- end
72
-
73
- def extend_result_with_declared_module
74
- extend_result declared_module_name if declared_module_name
75
- end
76
-
77
- def extend_result_with_inline_module
78
- extend_result inline_module_name if inline_module_name
79
- end
80
-
81
- def reset_index
82
- builder.assign '@index', start_index_var
83
- end
84
-
85
- def epsilon_node
86
- "instantiate_node(SyntaxNode,input, index...index)"
87
- end
88
-
89
- def assign_failure(start_index_var)
90
- assign_result("nil")
91
- end
92
-
93
- def var_initialization
94
- left, right = [], []
95
- var_symbols.each do |symbol|
96
- if init_value(symbol)
97
- left << var(symbol)
98
- right << init_value(symbol)
99
- end
100
- end
101
- if left.empty?
102
- ""
103
- else
104
- left.join(', ') + ' = ' + right.join(', ')
105
- end
106
- end
107
-
108
- def var(var_symbol)
109
- case var_symbol
110
- when :result then "r#{address}"
111
- when :accumulator then "s#{address}"
112
- when :start_index then "i#{address}"
113
- else raise "Unknown var symbol #{var_symbol}."
114
- end
115
- end
116
-
117
- def init_value(var_symbol)
118
- case var_symbol
119
- when :accumulator then '[]'
120
- when :start_index then 'index'
121
- else nil
122
- end
123
- end
124
-
125
- def begin_comment(expression)
126
- #builder << "# begin #{on_one_line(expression)}"
127
- end
128
-
129
- def end_comment(expression)
130
- #builder << "# end #{on_one_line(expression)}"
131
- end
132
-
133
- def on_one_line(expression)
134
- expression.text_value.tr("\n", ' ')
135
- end
136
- end
137
- end
138
- end
@@ -1,55 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class ParsingRule < Runtime::SyntaxNode
4
-
5
- def compile(builder)
6
- compile_inline_module_declarations(builder)
7
- generate_method_definition(builder)
8
- end
9
-
10
- def compile_inline_module_declarations(builder)
11
- parsing_expression.inline_modules.each_with_index do |inline_module, i|
12
- inline_module.compile(i, builder, self)
13
- builder.newline
14
- end
15
- end
16
-
17
- def generate_method_definition(builder)
18
- builder.reset_addresses
19
- expression_address = builder.next_address
20
- result_var = "r#{expression_address}"
21
-
22
- builder.method_declaration(method_name) do
23
- builder.assign 'start_index', 'index'
24
- generate_cache_lookup(builder)
25
- builder.newline
26
- parsing_expression.compile(expression_address, builder)
27
- builder.newline
28
- generate_cache_storage(builder, result_var)
29
- builder.newline
30
- builder << result_var
31
- end
32
- end
33
-
34
- def generate_cache_lookup(builder)
35
- builder.if_ "node_cache[:#{name}].has_key?(index)" do
36
- builder.assign 'cached', "node_cache[:#{name}][index]"
37
- builder << '@index = cached.interval.end if cached'
38
- builder << 'return cached'
39
- end
40
- end
41
-
42
- def generate_cache_storage(builder, result_var)
43
- builder.assign "node_cache[:#{name}][start_index]", result_var
44
- end
45
-
46
- def method_name
47
- "_nt_#{name}"
48
- end
49
-
50
- def name
51
- nonterminal.text_value
52
- end
53
- end
54
- end
55
- end
@@ -1,45 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class Predicate < ParsingExpression
4
- def compile(address, builder, parent_expression)
5
- super
6
- begin_comment(parent_expression)
7
- use_vars :result, :start_index
8
- obtain_new_subexpression_address
9
- parent_expression.prefixed_expression.compile(subexpression_address, builder)
10
- builder.if__(subexpression_success?) { when_success }
11
- builder.else_ { when_failure }
12
- end_comment(parent_expression)
13
- end
14
-
15
- def assign_failure
16
- super(start_index_var)
17
- end
18
-
19
- def assign_success
20
- reset_index
21
- assign_result epsilon_node
22
- end
23
- end
24
-
25
- class AndPredicate < Predicate
26
- def when_success
27
- assign_success
28
- end
29
-
30
- def when_failure
31
- assign_failure
32
- end
33
- end
34
-
35
- class NotPredicate < Predicate
36
- def when_success
37
- assign_failure
38
- end
39
-
40
- def when_failure
41
- assign_success
42
- end
43
- end
44
- end
45
- end
@@ -1,55 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class Repetition < ParsingExpression
4
- def compile(address, builder, parent_expression)
5
- super
6
- repeated_expression = parent_expression.atomic
7
- begin_comment(parent_expression)
8
- use_vars :result, :accumulator, :start_index
9
-
10
- builder.loop do
11
- obtain_new_subexpression_address
12
- repeated_expression.compile(subexpression_address, builder)
13
- builder.if__ subexpression_success? do
14
- accumulate_subexpression_result
15
- end
16
- builder.else_ do
17
- builder.break
18
- end
19
- end
20
- end
21
-
22
- def inline_module_name
23
- parent_expression.inline_module_name
24
- end
25
-
26
- def assign_and_extend_result
27
- assign_result "instantiate_node(#{node_class_name},input, #{start_index_var}...index, #{accumulator_var})"
28
- extend_result_with_inline_module
29
- end
30
- end
31
-
32
-
33
- class ZeroOrMore < Repetition
34
- def compile(address, builder, parent_expression)
35
- super
36
- assign_and_extend_result
37
- end_comment(parent_expression)
38
- end
39
- end
40
-
41
- class OneOrMore < Repetition
42
- def compile(address, builder, parent_expression)
43
- super
44
- builder.if__ "#{accumulator_var}.empty?" do
45
- reset_index
46
- assign_failure start_index_var
47
- end
48
- builder.else_ do
49
- assign_and_extend_result
50
- end
51
- end_comment(parent_expression)
52
- end
53
- end
54
- end
55
- end