dentaku 3.5.6 → 3.5.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc1bbfde891d6c98eda08b9176f9ed791744b2043176f07d3aac997fae34a3e9
4
- data.tar.gz: b8658f3d74364672f1a4538928e40d7b4d7aff7489273b573dbd1970303a60b3
3
+ metadata.gz: 6992ab2a13558e752be1db54e612dba4230c8e273ebb4bc11b51d655435ab463
4
+ data.tar.gz: fe53f64d1015b13ec909382679e3dbc93ec822fb97d8389a3bd83870fe2dacea
5
5
  SHA512:
6
- metadata.gz: bc53fba03a05ddf47875ffd08aa54266b3f6894a91d292f18236aba4db4c4c270bfeb4f039f84f10d4ac7ce2ca0f6a86580d65c1f5a0169b74bd7c2dfacf9363
7
- data.tar.gz: 88a65a6e103b40fbf3ef0dfc89173ced19e3df7f568514f4a12b451f7d4a91c69b1e25af89b5f9f1c9cadf34b71c200fc4a14ea11ef49aeeb2f2d4be6e36da2e
6
+ metadata.gz: cad7fc2694c626beb952b44c5014bda140ef5e7953de85e333e8482b35ac02ce87f8054e2e752f9f47a0ae2c5af7666224803d28b484c7c2defaa11aa782521f
7
+ data.tar.gz: 53a267501045fce0f6f4cb26bfb7308e65a9b6cb1a1e8d4386cafffbbb865976b0c320fae2553da30b07193a9126be05068c2b7ba7c5034a341698733cf88305
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Change Log
2
2
 
3
+ ## [v3.5.7] 2025-12-16
4
+ - fix misclassification of unary minus as subtraction
5
+ - fix parsing empty function call
6
+
7
+ ## [v3.5.6] 2025-10-20
8
+ - fix comparison of Hash with integer
9
+ - refactor case parsing
10
+ - remove input mutation
11
+ - fix bug with arithmetic node validation
12
+
3
13
  ## [v3.5.5] 2025-08-20
4
14
  - fix percentages in print visitor
5
15
  - repo cleanup
@@ -267,6 +277,7 @@
267
277
  ## [v0.1.0] 2012-01-20
268
278
  - initial release
269
279
 
280
+ [v3.5.6]: https://github.com/rubysolo/dentaku/compare/v3.5.5...v3.5.6
270
281
  [v3.5.5]: https://github.com/rubysolo/dentaku/compare/v3.5.4...v3.5.5
271
282
  [v3.5.4]: https://github.com/rubysolo/dentaku/compare/v3.5.3...v3.5.4
272
283
  [v3.5.3]: https://github.com/rubysolo/dentaku/compare/v3.5.2...v3.5.3
@@ -87,9 +87,10 @@ module Dentaku
87
87
  i += 1
88
88
  next
89
89
  end
90
+
90
91
  token = input[i]
91
92
  lookahead = input[i + 1]
92
- process_token(token, lookahead, i, input)
93
+ process_token(token, lookahead, i)
93
94
  i += 1
94
95
  end
95
96
 
@@ -114,7 +115,7 @@ module Dentaku
114
115
 
115
116
  private
116
117
 
117
- def process_token(token, lookahead, index, tokens)
118
+ def process_token(token, lookahead, index)
118
119
  case token.category
119
120
  when :datetime then output << AST::DateTime.new(token)
120
121
  when :numeric then output << AST::Numeric.new(token)
@@ -134,7 +135,7 @@ module Dentaku
134
135
  when :array
135
136
  handle_array(token)
136
137
  when :grouping
137
- handle_grouping(token, lookahead, tokens)
138
+ handle_grouping(token, lookahead, index)
138
139
  else
139
140
  fail! :not_implemented_token_category, token_category: token.category
140
141
  end
@@ -251,14 +252,13 @@ module Dentaku
251
252
  end
252
253
  end
253
254
 
254
- def handle_grouping(token, lookahead, tokens)
255
+ def handle_grouping(token, lookahead, token_index)
255
256
  case token.value
256
257
  when :open
257
258
  if lookahead && lookahead.value == :close
258
259
  # empty grouping (e.g. function with zero arguments) — we trigger consume later
259
260
  # skip to the end
260
- lookahead_index = tokens.index(lookahead)
261
- @skip_indices << lookahead_index if lookahead_index
261
+ @skip_indices << token_index + 1
262
262
  arities.pop
263
263
  consume(0)
264
264
  else
@@ -114,12 +114,14 @@ module Dentaku
114
114
 
115
115
  def negate
116
116
  new(:operator, '-', lambda { |raw| :negate }, lambda { |last_token|
117
- last_token.nil? ||
118
- last_token.is?(:operator) ||
119
- last_token.is?(:comparator) ||
120
- last_token.is?(:combinator) ||
121
- last_token.value == :open ||
122
- last_token.value == :comma
117
+ last_token.nil? ||
118
+ last_token.is?(:operator) ||
119
+ last_token.is?(:comparator) ||
120
+ last_token.is?(:combinator) ||
121
+ last_token.value == :open ||
122
+ last_token.value == :comma ||
123
+ last_token.value == :lbracket ||
124
+ last_token.value == :array_start
123
125
  })
124
126
  end
125
127
 
@@ -1,3 +1,3 @@
1
1
  module Dentaku
2
- VERSION = "3.5.6"
2
+ VERSION = "3.5.7"
3
3
  end
data/spec/parser_spec.rb CHANGED
@@ -52,6 +52,11 @@ describe Dentaku::Parser do
52
52
  expect(node.value).to eq(2)
53
53
  end
54
54
 
55
+ it 'parses multiple zero-argument functions in sequence' do
56
+ node = parse('count() + count()') # count() without arguments returns 0
57
+ expect(node.value).to eq(0)
58
+ end
59
+
55
60
  it 'represents formulas with variables' do
56
61
  node = parse('5 * x')
57
62
  expect { node.value }.to raise_error(Dentaku::UnboundVariableError)
@@ -49,6 +49,20 @@ describe Dentaku::Tokenizer do
49
49
  expect(tokens.map(&:category)).to eq([:grouping, :operator, :numeric, :grouping])
50
50
  expect(tokens.map(&:value)).to eq([:open, :negate, 5, :close])
51
51
 
52
+ tokens = tokenizer.tokenize('{-5, -2}[-1]')
53
+ expect(tokens.map(&:category)).to eq([
54
+ :array, # {
55
+ :operator, :numeric, :grouping, # -5,
56
+ :operator, :numeric, :array, # -2}
57
+ :access, :operator, :numeric, :access # [-1]
58
+ ])
59
+ expect(tokens.map(&:value)).to eq([
60
+ :array_start, # {
61
+ :negate, 5, :comma, # -5,
62
+ :negate, 2, :array_end, # -2}
63
+ :lbracket, :negate, 1, :rbracket # [-1]
64
+ ])
65
+
52
66
  tokens = tokenizer.tokenize('if(-5 > x, -7, -8) - 9')
53
67
  expect(tokens.map(&:category)).to eq([
54
68
  :function, :grouping, # if(
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dentaku
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.6
4
+ version: 3.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solomon White
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-10-20 00:00:00.000000000 Z
10
+ date: 2025-12-16 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bigdecimal