less 1.0.14 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -69,7 +69,7 @@ begin
69
69
 
70
70
  task :benchmark do
71
71
  print "benchmarking... "
72
- less = File.read("spec/less/big-1.0.less")
72
+ less = File.read("spec/less/big.less")
73
73
  start = Time.now.to_f
74
74
  Less::Engine.new(less).parse
75
75
  total = Time.now.to_f - start
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.14
1
+ 1.0.15
data/less.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{less}
5
- s.version = "1.0.14"
5
+ s.version = "1.0.15"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["cloudhead"]
@@ -622,8 +622,8 @@ module Less
622
622
  else
623
623
  s4, i4 = [], index
624
624
  loop do
625
- if has_terminal?('[-a-zA-Z0-9_%$/.&=:;#+?]', true, index)
626
- r5 = true
625
+ if has_terminal?('\G[-a-zA-Z0-9_%$/.&=:;#+?]', true, index)
626
+ r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
627
627
  @index += 1
628
628
  else
629
629
  r5 = nil
@@ -698,8 +698,8 @@ module Less
698
698
  i0, s0 = index, []
699
699
  s1, i1 = [], index
700
700
  loop do
701
- if has_terminal?('[-a-z]', true, index)
702
- r2 = true
701
+ if has_terminal?('\G[-a-z]', true, index)
702
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
703
703
  @index += 1
704
704
  else
705
705
  r2 = nil
@@ -738,8 +738,8 @@ module Less
738
738
  if r7
739
739
  s8, i8 = [], index
740
740
  loop do
741
- if has_terminal?('[a-z]', true, index)
742
- r9 = true
741
+ if has_terminal?('\G[a-z]', true, index)
742
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
743
743
  @index += 1
744
744
  else
745
745
  r9 = nil
@@ -1509,8 +1509,8 @@ module Less
1509
1509
 
1510
1510
  i0 = index
1511
1511
  i1, s1 = index, []
1512
- if has_terminal?('[a-zA-Z]', true, index)
1513
- r2 = true
1512
+ if has_terminal?('\G[a-zA-Z]', true, index)
1513
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
1514
1514
  @index += 1
1515
1515
  else
1516
1516
  r2 = nil
@@ -1519,8 +1519,8 @@ module Less
1519
1519
  if r2
1520
1520
  s3, i3 = [], index
1521
1521
  loop do
1522
- if has_terminal?('[-a-zA-Z0-9]', true, index)
1523
- r4 = true
1522
+ if has_terminal?('\G[-a-zA-Z0-9]', true, index)
1523
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
1524
1524
  @index += 1
1525
1525
  else
1526
1526
  r4 = nil
@@ -1602,8 +1602,8 @@ module Less
1602
1602
  if r3
1603
1603
  s5, i5 = [], index
1604
1604
  loop do
1605
- if has_terminal?('[-a-z0-9_]', true, index)
1606
- r6 = true
1605
+ if has_terminal?('\G[-a-z0-9_]', true, index)
1606
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
1607
1607
  @index += 1
1608
1608
  else
1609
1609
  r6 = nil
@@ -1665,8 +1665,8 @@ module Less
1665
1665
  if r1
1666
1666
  s2, i2 = [], index
1667
1667
  loop do
1668
- if has_terminal?('[-a-zA-Z0-9_]', true, index)
1669
- r3 = true
1668
+ if has_terminal?('\G[-a-zA-Z0-9_]', true, index)
1669
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
1670
1670
  @index += 1
1671
1671
  else
1672
1672
  r3 = nil
@@ -1961,8 +1961,8 @@ module Less
1961
1961
  s1 << r3
1962
1962
  if r3
1963
1963
  i4, s4 = index, []
1964
- if has_terminal?('[|~*$^]', true, index)
1965
- r6 = true
1964
+ if has_terminal?('\G[|~*$^]', true, index)
1965
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
1966
1966
  @index += 1
1967
1967
  else
1968
1968
  r6 = nil
@@ -2105,8 +2105,8 @@ module Less
2105
2105
  end
2106
2106
  s0 << r1
2107
2107
  if r1
2108
- if has_terminal?('[_a-z]', true, index)
2109
- r2 = true
2108
+ if has_terminal?('\G[_a-z]', true, index)
2109
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
2110
2110
  @index += 1
2111
2111
  else
2112
2112
  r2 = nil
@@ -2115,8 +2115,8 @@ module Less
2115
2115
  if r2
2116
2116
  s3, i3 = [], index
2117
2117
  loop do
2118
- if has_terminal?('[-a-zA-Z0-9_]', true, index)
2119
- r4 = true
2118
+ if has_terminal?('\G[-a-zA-Z0-9_]', true, index)
2119
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
2120
2120
  @index += 1
2121
2121
  else
2122
2122
  r4 = nil
@@ -2165,8 +2165,8 @@ module Less
2165
2165
  end
2166
2166
  s0 << r1
2167
2167
  if r1
2168
- if has_terminal?('[_a-z]', true, index)
2169
- r2 = true
2168
+ if has_terminal?('\G[_a-z]', true, index)
2169
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
2170
2170
  @index += 1
2171
2171
  else
2172
2172
  r2 = nil
@@ -2175,8 +2175,8 @@ module Less
2175
2175
  if r2
2176
2176
  s3, i3 = [], index
2177
2177
  loop do
2178
- if has_terminal?('[-a-zA-Z0-9_]', true, index)
2179
- r4 = true
2178
+ if has_terminal?('\G[-a-zA-Z0-9_]', true, index)
2179
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
2180
2180
  @index += 1
2181
2181
  else
2182
2182
  r4 = nil
@@ -2217,8 +2217,8 @@ module Less
2217
2217
 
2218
2218
  i0 = index
2219
2219
  i1, s1 = index, []
2220
- if has_terminal?('[a-zA-Z]', true, index)
2221
- r2 = true
2220
+ if has_terminal?('\G[a-zA-Z]', true, index)
2221
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
2222
2222
  @index += 1
2223
2223
  else
2224
2224
  r2 = nil
@@ -2227,8 +2227,8 @@ module Less
2227
2227
  if r2
2228
2228
  s3, i3 = [], index
2229
2229
  loop do
2230
- if has_terminal?('[-a-zA-Z]', true, index)
2231
- r4 = true
2230
+ if has_terminal?('\G[-a-zA-Z]', true, index)
2231
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
2232
2232
  @index += 1
2233
2233
  else
2234
2234
  r4 = nil
@@ -2242,8 +2242,8 @@ module Less
2242
2242
  r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
2243
2243
  s1 << r3
2244
2244
  if r3
2245
- if has_terminal?('[0-9]', true, index)
2246
- r6 = true
2245
+ if has_terminal?('\G[0-9]', true, index)
2246
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
2247
2247
  @index += 1
2248
2248
  else
2249
2249
  r6 = nil
@@ -2316,8 +2316,8 @@ module Less
2316
2316
  r3 = _nt_s
2317
2317
  s2 << r3
2318
2318
  if r3
2319
- if has_terminal?('[+>~]', true, index)
2320
- r4 = true
2319
+ if has_terminal?('\G[+>~]', true, index)
2320
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
2321
2321
  @index += 1
2322
2322
  else
2323
2323
  r4 = nil
@@ -2506,8 +2506,8 @@ module Less
2506
2506
  r2 = _nt_S
2507
2507
  s1 << r2
2508
2508
  if r2
2509
- if has_terminal?('[-+*/]', true, index)
2510
- r3 = true
2509
+ if has_terminal?('\G[-+*/]', true, index)
2510
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
2511
2511
  @index += 1
2512
2512
  else
2513
2513
  r3 = nil
@@ -2529,7 +2529,7 @@ module Less
2529
2529
  if r1
2530
2530
  r0 = r1
2531
2531
  else
2532
- if has_terminal?('[-+*/]', true, index)
2532
+ if has_terminal?('\G[-+*/]', true, index)
2533
2533
  r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
2534
2534
  r5.extend(Operator2)
2535
2535
  @index += 1
@@ -2604,8 +2604,8 @@ module Less
2604
2604
  else
2605
2605
  s5, i5 = [], index
2606
2606
  loop do
2607
- if has_terminal?('[-a-z]', true, index)
2608
- r6 = true
2607
+ if has_terminal?('\G[-a-z]', true, index)
2608
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
2609
2609
  @index += 1
2610
2610
  else
2611
2611
  r6 = nil
@@ -2738,8 +2738,8 @@ module Less
2738
2738
  i0, s0 = index, []
2739
2739
  s1, i1 = [], index
2740
2740
  loop do
2741
- if has_terminal?('[-a-zA-Z]', true, index)
2742
- r2 = true
2741
+ if has_terminal?('\G[-a-zA-Z]', true, index)
2742
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
2743
2743
  @index += 1
2744
2744
  else
2745
2745
  r2 = nil
@@ -2899,8 +2899,8 @@ module Less
2899
2899
  r0 = r1
2900
2900
  else
2901
2901
  i9, s9 = index, []
2902
- if has_terminal?('["]', true, index)
2903
- r10 = true
2902
+ if has_terminal?('\G["]', true, index)
2903
+ r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
2904
2904
  @index += 1
2905
2905
  else
2906
2906
  r10 = nil
@@ -2911,8 +2911,8 @@ module Less
2911
2911
  loop do
2912
2912
  i12, s12 = index, []
2913
2913
  i13 = index
2914
- if has_terminal?('["]', true, index)
2915
- r14 = true
2914
+ if has_terminal?('\G["]', true, index)
2915
+ r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
2916
2916
  @index += 1
2917
2917
  else
2918
2918
  r14 = nil
@@ -2950,8 +2950,8 @@ module Less
2950
2950
  r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
2951
2951
  s9 << r11
2952
2952
  if r11
2953
- if has_terminal?('["]', true, index)
2954
- r16 = true
2953
+ if has_terminal?('\G["]', true, index)
2954
+ r16 = instantiate_node(SyntaxNode,input, index...(index + 1))
2955
2955
  @index += 1
2956
2956
  else
2957
2957
  r16 = nil
@@ -3050,8 +3050,8 @@ module Less
3050
3050
  if r2
3051
3051
  s4, i4 = [], index
3052
3052
  loop do
3053
- if has_terminal?('[0-9]', true, index)
3054
- r5 = true
3053
+ if has_terminal?('\G[0-9]', true, index)
3054
+ r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
3055
3055
  @index += 1
3056
3056
  else
3057
3057
  r5 = nil
@@ -3076,8 +3076,8 @@ module Less
3076
3076
  if r6
3077
3077
  s7, i7 = [], index
3078
3078
  loop do
3079
- if has_terminal?('[0-9]', true, index)
3080
- r8 = true
3079
+ if has_terminal?('\G[0-9]', true, index)
3080
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
3081
3081
  @index += 1
3082
3082
  else
3083
3083
  r8 = nil
@@ -3125,8 +3125,8 @@ module Less
3125
3125
  if r10
3126
3126
  s12, i12 = [], index
3127
3127
  loop do
3128
- if has_terminal?('[0-9]', true, index)
3129
- r13 = true
3128
+ if has_terminal?('\G[0-9]', true, index)
3129
+ r13 = instantiate_node(SyntaxNode,input, index...(index + 1))
3130
3130
  @index += 1
3131
3131
  else
3132
3132
  r13 = nil
@@ -3584,7 +3584,7 @@ module Less
3584
3584
  return cached
3585
3585
  end
3586
3586
 
3587
- if has_terminal?('[a-fA-F0-9]', true, index)
3587
+ if has_terminal?('\G[a-fA-F0-9]', true, index)
3588
3588
  r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
3589
3589
  @index += 1
3590
3590
  else
@@ -3623,8 +3623,8 @@ module Less
3623
3623
  i0, s0 = index, []
3624
3624
  s1, i1 = [], index
3625
3625
  loop do
3626
- if has_terminal?('[-a-zA-Z_]', true, index)
3627
- r2 = true
3626
+ if has_terminal?('\G[-a-zA-Z_]', true, index)
3627
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
3628
3628
  @index += 1
3629
3629
  else
3630
3630
  r2 = nil
@@ -3884,8 +3884,8 @@ module Less
3884
3884
  i6, s6 = index, []
3885
3885
  s7, i7 = [], index
3886
3886
  loop do
3887
- if has_terminal?('[a-zA-Z]', true, index)
3888
- r8 = true
3887
+ if has_terminal?('\G[a-zA-Z]', true, index)
3888
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
3889
3889
  @index += 1
3890
3890
  else
3891
3891
  r8 = nil
@@ -3930,8 +3930,8 @@ module Less
3930
3930
  else
3931
3931
  s11, i11 = [], index
3932
3932
  loop do
3933
- if has_terminal?('[-a-zA-Z0-9_%$/.&=:;#+?]', true, index)
3934
- r12 = true
3933
+ if has_terminal?('\G[-a-zA-Z0-9_%$/.&=:;#+?]', true, index)
3934
+ r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
3935
3935
  @index += 1
3936
3936
  else
3937
3937
  r12 = nil
@@ -3975,8 +3975,8 @@ module Less
3975
3975
 
3976
3976
  s0, i0 = [], index
3977
3977
  loop do
3978
- if has_terminal?('[ ]', true, index)
3979
- r1 = true
3978
+ if has_terminal?('\G[ ]', true, index)
3979
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
3980
3980
  @index += 1
3981
3981
  else
3982
3982
  r1 = nil
@@ -4004,8 +4004,8 @@ module Less
4004
4004
 
4005
4005
  s0, i0 = [], index
4006
4006
  loop do
4007
- if has_terminal?('[ ]', true, index)
4008
- r1 = true
4007
+ if has_terminal?('\G[ ]', true, index)
4008
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
4009
4009
  @index += 1
4010
4010
  else
4011
4011
  r1 = nil
@@ -4038,8 +4038,8 @@ module Less
4038
4038
 
4039
4039
  s0, i0 = [], index
4040
4040
  loop do
4041
- if has_terminal?('[\\n ]', true, index)
4042
- r1 = true
4041
+ if has_terminal?('\G[\\n ]', true, index)
4042
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
4043
4043
  @index += 1
4044
4044
  else
4045
4045
  r1 = nil
@@ -4067,8 +4067,8 @@ module Less
4067
4067
 
4068
4068
  s0, i0 = [], index
4069
4069
  loop do
4070
- if has_terminal?('[\\n ]', true, index)
4071
- r1 = true
4070
+ if has_terminal?('\G[\\n ]', true, index)
4071
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
4072
4072
  @index += 1
4073
4073
  else
4074
4074
  r1 = nil
@@ -4104,8 +4104,8 @@ module Less
4104
4104
 
4105
4105
  i0, s0 = index, []
4106
4106
  i1 = index
4107
- if has_terminal?('[ ;\\n]', true, index)
4108
- r2 = true
4107
+ if has_terminal?('\G[ ;\\n]', true, index)
4108
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
4109
4109
  @index += 1
4110
4110
  else
4111
4111
  r2 = nil
@@ -4,13 +4,9 @@ module Treetop
4
4
  def compile(address, builder, parent_expression = nil)
5
5
  super
6
6
 
7
- builder.if__ "has_terminal?(#{single_quote(text_value)}, true, index)" do
8
- if address == 0 || decorated?
9
- assign_result "instantiate_node(#{node_class_name},input, index...(index + 1))"
10
- extend_result_with_inline_module
11
- else
12
- assign_lazily_instantiated_node
13
- end
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
14
10
  builder << "@index += 1"
15
11
  end
16
12
  builder.else_ do
@@ -18,6 +14,11 @@ module Treetop
18
14
  assign_result 'nil'
19
15
  end
20
16
  end
17
+
18
+ def grounded_regexp(string)
19
+ # Double any backslashes, then backslash any single-quotes:
20
+ "'\\G#{string.gsub(/\\/) { '\\\\' }.gsub(/'/) { "\\'"}}'"
21
+ end
21
22
  end
22
23
  end
23
24
  end
@@ -21,10 +21,6 @@ module Treetop
21
21
  parent_expression && parent_expression.inline_module_name
22
22
  end
23
23
 
24
- def decorated?
25
- parent_expression && (parent_expression.node_class_name || parent_expression.node_class_name || parent_expression.inline_module_name)
26
- end
27
-
28
24
  def optional_arg(arg)
29
25
  if arg
30
26
  ", #{arg}"
@@ -93,10 +89,6 @@ module Treetop
93
89
  def assign_failure(start_index_var)
94
90
  assign_result("nil")
95
91
  end
96
-
97
- def assign_lazily_instantiated_node
98
- assign_result("true")
99
- end
100
92
 
101
93
  def var_initialization
102
94
  left, right = [], []
@@ -3,7 +3,7 @@ module Treetop
3
3
  class CompiledParser
4
4
  include Treetop::Runtime
5
5
 
6
- attr_reader :input, :index, :max_terminal_failure_index
6
+ attr_reader :input, :index, :terminal_failures, :max_terminal_failure_index
7
7
  attr_writer :root
8
8
  attr_accessor :consume_all_input
9
9
  alias :consume_all_input? :consume_all_input
@@ -25,26 +25,22 @@ module Treetop
25
25
  end
26
26
 
27
27
  def failure_line
28
- @terminal_failures && input.line_of(failure_index)
28
+ terminal_failures && input.line_of(failure_index)
29
29
  end
30
30
 
31
31
  def failure_column
32
- @terminal_failures && input.column_of(failure_index)
32
+ terminal_failures && input.column_of(failure_index)
33
33
  end
34
34
 
35
35
  def failure_reason
36
36
  return nil unless (tf = terminal_failures) && tf.size > 0
37
- "Expected " +
38
- (tf.size == 1 ?
39
- tf[0].expected_string :
40
- "one of #{tf.map{|f| f.expected_string}.uniq*', '}"
41
- ) +
42
- " at line #{failure_line}, column #{failure_column} (byte #{failure_index+1})" +
43
- " after #{input[index...failure_index]}"
44
- end
45
-
46
- def terminal_failures
47
- @terminal_failures.map! {|tf_ary| TerminalParseFailure.new(*tf_ary) }
37
+ "Expected " +
38
+ (tf.size == 1 ?
39
+ tf[0].expected_string :
40
+ "one of #{tf.map{|f| f.expected_string}.uniq*', '}"
41
+ ) +
42
+ " at line #{failure_line}, column #{failure_column} (byte #{failure_index+1})" +
43
+ " after #{input[index...failure_index]}"
48
44
  end
49
45
 
50
46
 
@@ -91,7 +87,7 @@ module Treetop
91
87
  rx = @regexps[terminal] ||= Regexp.new(terminal)
92
88
  input.index(rx, index) == index
93
89
  else
94
- input[index] == terminal[0] && input.index(terminal, index) == index
90
+ input[index, terminal.size] == terminal
95
91
  end
96
92
  end
97
93
 
@@ -101,7 +97,7 @@ module Treetop
101
97
  @max_terminal_failure_index = index
102
98
  @terminal_failures = []
103
99
  end
104
- @terminal_failures << [index, expected_string]
100
+ terminal_failures << TerminalParseFailure.new(index, expected_string)
105
101
  return nil
106
102
  end
107
103
  end
@@ -1,33 +1,19 @@
1
1
  module Treetop
2
2
  module Runtime
3
3
  class SyntaxNode
4
- attr_reader :input, :interval
4
+ attr_reader :input, :interval, :elements
5
5
  attr_accessor :parent
6
6
 
7
7
  def initialize(input, interval, elements = nil)
8
8
  @input = input
9
9
  @interval = interval
10
10
  if @elements = elements
11
- @comprehensive_elements = @elements unless @elements.delete(true)
12
- @elements.each do |element|
11
+ elements.each do |element|
13
12
  element.parent = self
14
13
  end
15
14
  end
16
15
  end
17
16
 
18
- def elements
19
- return @elements if terminal?
20
- # fill in any gaps in the sequence (lazy instantiation) if needed
21
- @comprehensive_elements ||= interval.inject(@elements) do |elements, index|
22
- unless @elements.any? {|element| element.interval.include?(index) }
23
- node = SyntaxNode.new(input, index...(index + 1))
24
- node.parent = self
25
- elements << node
26
- end
27
- elements
28
- end.sort
29
- end
30
-
31
17
  def terminal?
32
18
  @elements.nil?
33
19
  end
@@ -43,10 +29,6 @@ module Treetop
43
29
  def empty?
44
30
  interval.first == interval.last && interval.exclude_end?
45
31
  end
46
-
47
- def <=>(other)
48
- self.interval.first <=> other.interval.first
49
- end
50
32
 
51
33
  def extension_modules
52
34
  local_extensions =
@@ -1,8 +1,8 @@
1
1
  module Treetop #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
- MINOR = 2
5
- TINY = 6
4
+ MINOR = 3
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -69,18 +69,6 @@ module CharacterClassSpec
69
69
  parse(' 1', :index => 1).should be_nil
70
70
  end
71
71
  end
72
-
73
- describe "a character class followed by a node class declaration and a block" do
74
-
75
- testing_expression "[A-Z] <CharacterClassSpec::Foo>"
76
-
77
- it "actively generates nodes for the character when it is the primary node" do
78
- result = parse('A')
79
- result.should be_a(Treetop::Runtime::SyntaxNode)
80
- result.elements.should be_nil
81
- end
82
-
83
- end
84
72
 
85
73
  describe "A character class containing quotes" do
86
74
  testing_expression "[\"']"
@@ -190,58 +178,5 @@ module CharacterClassSpec
190
178
  parse("0").should be_nil
191
179
  end
192
180
  end
193
-
194
- describe "a character class" do
195
- testing_expression "[A-Z]"
196
- it "actively generates a node for the character because it is the primary node" do
197
- result = parse('A')
198
- result.should be_a(Treetop::Runtime::SyntaxNode)
199
- result.elements.should be_nil
200
- end
201
- end
202
-
203
- describe "a character class mixed with other expressions" do
204
- testing_expression '[A-Z] "a"'
205
- it "lazily instantiates a node for the character" do
206
- result = parse('Aa')
207
- result.instance_variable_get("@elements").size.should == 1
208
- result.elements.size.should == 2
209
- end
210
- end
211
-
212
- describe "a character class with a node class declaration mixed with other expressions" do
213
- testing_expression '([A-Z] <CharacterClassSpec::Foo>) "a"'
214
- it "actively generates a node for the character because it has a node class declared" do
215
- result = parse('Aa')
216
- result.instance_variable_get("@elements").size.should == 2
217
- result.elements.size.should == 2
218
- end
219
- end
220
-
221
- describe "a character class with a node module declaration mixed with other expressions" do
222
- testing_expression '([A-Z] <CharacterClassSpec::ModFoo>) "a"'
223
- it "actively generates a node for the character because it has a node module declared" do
224
- result = parse('Aa')
225
- result.instance_variable_get("@elements").size.should == 2
226
- result.elements.size.should == 2
227
- end
228
- end
229
-
230
- describe "a character class with an inline block mixed with other expressions" do
231
- testing_expression '([A-Z] { def a_method; end }) "a"'
232
- it "actively generates a node for the character because it has an inline block" do
233
- result = parse('Aa')
234
- result.instance_variable_get("@elements").size.should == 2
235
- result.elements.size.should == 2
236
- end
237
- end
238
-
239
- describe "a character class with a label mixed with other expressions" do
240
- testing_expression 'upper:([A-Z]) "b"'
241
- it "returns the correct element for the labeled expression" do
242
- result = parse('Ab')
243
- result.upper.text_value.should == "A"
244
- end
245
- end
246
181
 
247
182
  end
@@ -50,19 +50,4 @@ module SyntaxNodeSpec
50
50
  end
51
51
  end
52
52
  end
53
-
54
- describe "A new nonterminal syntax node with all children lazily instantiated" do
55
- attr_reader :node
56
-
57
- before do
58
- @input = 'test input'
59
- @node = Runtime::SyntaxNode.new('input', 0...3, [true, true, true])
60
- end
61
-
62
- it "should lazily instantiate its child nodes" do
63
- node.elements.size.should == 3
64
- node.elements.first.interval.should == (0...1)
65
- node.elements.first.parent.should == @node
66
- end
67
- end
68
53
  end
@@ -7,7 +7,7 @@ $gemspec = Gem::Specification.new do |s|
7
7
  s.homepage = "http://functionalform.blogspot.com"
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.summary = "A Ruby-based text parsing and interpretation DSL"
10
- s.files = ["README", "Rakefile", "{test,lib,bin,doc,examples}/**/*"].map{|p| Dir[p]}.flatten
10
+ s.files = ["LICENSE", "README", "Rakefile", "{test,lib,bin,doc,examples}/**/*"].map{|p| Dir[p]}.flatten
11
11
  s.bindir = "bin"
12
12
  s.executables = ["tt"]
13
13
  s.require_path = "lib"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: less
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.14
4
+ version: 1.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - cloudhead