liquid2 0.2.0 → 0.3.1

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/sig/liquid2.rbs CHANGED
@@ -82,7 +82,75 @@ module Liquid2
82
82
 
83
83
  @globals: Hash[String, untyped]?
84
84
 
85
- @scanner: StringScanner
85
+ @scanner: singleton(Scanner)
86
+
87
+ @parser: singleton(Parser)
88
+
89
+ @string_scanner: StringScanner
90
+
91
+ @arithmetic_operators: bool
92
+
93
+ # The string of characters that indicate the start of a Liquid output statement.
94
+ @markup_out_start: String
95
+
96
+ # The string of characters that indicate the end of a Liquid output statement.
97
+ @markup_out_end: String
98
+
99
+ # The string of characters that indicate the start of a Liquid tag.
100
+ @markup_tag_start: String
101
+
102
+ # The string of characters that indicate the end of a Liquid tag.
103
+ @markup_tag_end: String
104
+
105
+ # The string of characters that indicate the start of a Liquid comment. This should
106
+ # include a single trailing `#`. Additional, variable length hashes will be handled
107
+ # by the tokenizer. It is not possible to change comment syntax to not use `#`.
108
+ @markup_comment_prefix: String
109
+
110
+ # The string of characters that indicate the end of a Liquid comment, excluding any
111
+ # hashes.
112
+ @markup_comment_suffix: String
113
+
114
+ # A regex pattern matching Liquid tag names. Should include `#` for inline comments.
115
+ @re_tag_name: Regexp
116
+
117
+ @re_word: Regexp
118
+
119
+ @re_int: Regexp
120
+
121
+ @re_float: Regexp
122
+
123
+ @re_double_quote_string_special: Regexp
124
+
125
+ @re_single_quote_string_special: Regexp
126
+
127
+ # A regex pattern matching the start of some Liquid markup. Could be the start of an
128
+ # output statement, tag or comment. Traditionally `{{`, `{%` and `{#`, respectively.
129
+ @re_markup_start: Regexp
130
+
131
+ # A regex pattern matching the end of some Liquid markup. Could be the end of
132
+ # an output statement or tag. Traditionally `}}`, `%}`, respectively.
133
+ # respectively.
134
+ @re_markup_end: Regexp
135
+
136
+ # A regex pattern matching any one of the possible characters ending some Liquid
137
+ # markup. This is used to detect incomplete and malformed markup and provide
138
+ # helpful error messages.
139
+ @re_markup_end_chars: Regexp
140
+
141
+ @re_up_to_markup_start: Regexp
142
+
143
+ @re_punctuation: Regexp
144
+
145
+ @re_up_to_inline_comment_end: Regexp
146
+
147
+ @re_up_to_raw_end: Regexp
148
+
149
+ @re_block_comment_chunk: Regexp
150
+
151
+ @re_up_to_doc_end: Regexp
152
+
153
+ @re_line_statement_comment: Regexp
86
154
 
87
155
  attr_reader tags: Hash[String, _Tag]
88
156
 
@@ -102,7 +170,53 @@ module Liquid2
102
170
 
103
171
  attr_reader falsy_undefined: bool
104
172
 
105
- def initialize: (?context_depth_limit: ::Integer, ?globals: Hash[String, untyped]?, ?loader: TemplateLoader?, ?local_namespace_limit: Integer?, ?loop_iteration_limit: Integer?, ?output_stream_limit: Integer?, ?shorthand_indexes: bool, ?suppress_blank_control_flow_blocks: bool, ?undefined: singleton(Undefined), ?falsy_undefined: bool) -> void
173
+ attr_reader arithmetic_operators: bool
174
+
175
+ attr_reader markup_comment_prefix: String
176
+
177
+ attr_reader markup_comment_suffix: String
178
+
179
+ attr_reader markup_out_end: String
180
+
181
+ attr_reader markup_out_start: String
182
+
183
+ attr_reader markup_tag_end: String
184
+
185
+ attr_reader markup_tag_start: String
186
+
187
+ attr_reader re_tag_name: Regexp
188
+
189
+ attr_reader re_word: Regexp
190
+
191
+ attr_reader re_int: Regexp
192
+
193
+ attr_reader re_float: Regexp
194
+
195
+ attr_reader re_double_quote_string_special: Regexp
196
+
197
+ attr_reader re_single_quote_string_special: Regexp
198
+
199
+ attr_reader re_markup_start: Regexp
200
+
201
+ attr_reader re_markup_end: Regexp
202
+
203
+ attr_reader re_markup_end_chars: Regexp
204
+
205
+ attr_reader re_up_to_markup_start: Regexp
206
+
207
+ attr_reader re_punctuation: Regexp
208
+
209
+ attr_reader re_up_to_inline_comment_end: Regexp
210
+
211
+ attr_reader re_up_to_raw_end: Regexp
212
+
213
+ attr_reader re_block_comment_chunk: Regexp
214
+
215
+ attr_reader re_up_to_doc_end: Regexp
216
+
217
+ attr_reader re_line_statement_comment: Regexp
218
+
219
+ def initialize: (?arithmetic_operators: bool, ?context_depth_limit: ::Integer, ?falsy_undefined: bool, ?globals: untyped?, ?loader: TemplateLoader?, ?local_namespace_limit: Integer?, ?loop_iteration_limit: Integer?, ?markup_comment_prefix: ::String, ?markup_comment_suffix: ::String, ?markup_out_end: ::String, ?markup_out_start: ::String, ?markup_tag_end: ::String, ?markup_tag_start: ::String, ?output_stream_limit: Integer?, ?parser: singleton(Parser), ?scanner: singleton(Scanner), ?shorthand_indexes: bool, ?suppress_blank_control_flow_blocks: bool, ?undefined: singleton(Undefined)) -> void
106
220
 
107
221
  # @param source [String] template source text.
108
222
  # @return [Template]
@@ -132,6 +246,8 @@ module Liquid2
132
246
  def delete_tag: (String name) -> (_Tag | nil)
133
247
 
134
248
  def setup_tags_and_filters: () -> void
249
+
250
+ def setup_scanner: () -> void
135
251
 
136
252
  def undefined: (String name, ?node: _HasToken?) -> Undefined
137
253
 
@@ -167,37 +283,59 @@ module Liquid2
167
283
  # A pointer to the start of the current token.
168
284
  @start: Integer
169
285
 
170
- # Tokens are arrays of (kind, value, start index)
171
- @tokens: Array[[Symbol, String?, Integer]]
286
+ @s_out_start: String
172
287
 
173
- attr_reader tokens: Array[[Symbol, String?, Integer]]
288
+ @s_out_end: String
289
+
290
+ @s_tag_start: String
291
+
292
+ @s_tag_end: String
293
+
294
+ @s_comment_prefix: String
295
+
296
+ @s_comment_suffix: String
174
297
 
175
- RE_MARKUP_START: ::Regexp
298
+ @re_tag_name: Regexp
176
299
 
177
- RE_WHITESPACE: ::Regexp
300
+ @re_word: Regexp
178
301
 
179
- RE_LINE_SPACE: ::Regexp
302
+ @re_int: Regexp
180
303
 
181
- RE_WORD: ::Regexp
304
+ @re_float: Regexp
182
305
 
183
- RE_INT: ::Regexp
306
+ @re_double_quote_string_special: Regexp
184
307
 
185
- RE_FLOAT: ::Regexp
308
+ @re_single_quote_string_special: Regexp
186
309
 
187
- RE_PUNCTUATION: ::Regexp
310
+ @re_markup_start: Regexp
188
311
 
189
- RE_SINGLE_QUOTE_STRING_SPECIAL: ::Regexp
312
+ @re_markup_end: Regexp
190
313
 
191
- RE_DOUBLE_QUOTE_STRING_SPECIAL: ::Regexp
314
+ @re_markup_end_chars: Regexp
315
+
316
+ @re_up_to_markup_start: Regexp
317
+
318
+ @re_punctuation: Regexp
319
+
320
+ @re_up_to_inline_comment_end: Regexp
321
+ @re_up_to_raw_end: Regexp
322
+ @re_block_comment_chunk: Regexp
323
+ @re_up_to_doc_end: Regexp
324
+ @re_line_statement_comment: Regexp
325
+
326
+ # Tokens are arrays of (kind, value, start index)
327
+ @tokens: Array[[Symbol, String?, Integer]]
328
+
329
+ attr_reader tokens: Array[[Symbol, String?, Integer]]
192
330
 
193
331
  # Keywords and symbols that get their own token kind.
194
332
  TOKEN_MAP: Hash[String, Symbol]
195
333
 
196
- def self.tokenize: (String source, StringScanner scanner) -> Array[[Symbol, String?, Integer]]
334
+ def self.tokenize: (Environment env, String source, StringScanner scanner) -> Array[[Symbol, String?, Integer]]
197
335
 
198
336
  # @param source [String]
199
337
  # @param scanner [StringScanner]
200
- def initialize: (String source, StringScanner scanner) -> void
338
+ def initialize: (Environment env, String source, StringScanner scanner) -> void
201
339
 
202
340
  def run: () -> void
203
341
 
@@ -375,6 +513,12 @@ module Liquid2
375
513
  MEMBERSHIP: 6
376
514
 
377
515
  PREFIX: 7
516
+
517
+ ADD_SUB: 8
518
+
519
+ MUL_DIV: 9
520
+
521
+ POW: 10
378
522
  end
379
523
 
380
524
  PRECEDENCES: Hash[Symbol, Integer]
@@ -609,29 +753,33 @@ module Liquid2
609
753
 
610
754
  def []: (*untyped) ?{ (?) -> untyped } -> self
611
755
 
612
- def key?: (*untyped) ?{ (?) -> untyped } -> false
756
+ def key?: (*untyped) ?{ (?) -> untyped } -> untyped
613
757
 
614
- def include?: (*untyped) ?{ (?) -> untyped } -> false
758
+ def include?: (*untyped) ?{ (?) -> untyped } -> untyped
615
759
 
616
- def member?: (*untyped) ?{ (?) -> untyped } -> false
760
+ def member?: (*untyped) ?{ (?) -> untyped } -> untyped
617
761
 
618
762
  def fetch: (*untyped) ?{ (?) -> untyped } -> self
619
763
 
620
- def !: () -> true
764
+ def !: () -> untyped
621
765
 
622
766
  def ==: (untyped other) -> untyped
623
767
 
624
768
  alias eql? ==
625
769
 
626
- def size: () -> 0
770
+ def size: () -> untyped
627
771
 
628
- def length: () -> 0
772
+ def length: () -> untyped
629
773
 
630
774
  def to_s: () -> ""
631
775
 
632
- def to_i: () -> 0
776
+ def to_i: () -> untyped
777
+
778
+ def +@: () -> untyped
779
+
780
+ def -@: () -> untyped
633
781
 
634
- def to_f: () -> ::Float
782
+ def to_f: () -> untyped
635
783
 
636
784
  def each: (*untyped) ?{ (?) -> untyped } -> untyped
637
785
 
@@ -639,9 +787,9 @@ module Liquid2
639
787
 
640
788
  def join: (*untyped) -> ""
641
789
 
642
- def to_liquid: (RenderContext _context) -> nil
790
+ def to_liquid: (RenderContext _context) -> untyped
643
791
 
644
- def poke: () -> true
792
+ def poke: () -> bool
645
793
  end
646
794
 
647
795
  # An undefined type that always raises an exception.
@@ -679,6 +827,10 @@ module Liquid2
679
827
  def to_s: () -> untyped
680
828
 
681
829
  def to_i: () -> untyped
830
+
831
+ def +@: () -> untyped
832
+
833
+ def -@: () -> untyped
682
834
 
683
835
  def to_f: () -> untyped
684
836
 
@@ -1593,7 +1745,7 @@ module Liquid2
1593
1745
  def self.to_integer: (untyped obj) -> Integer
1594
1746
 
1595
1747
  # Cast _obj_ to a number, favouring BigDecimal over Float.
1596
- def self.to_decimal: (untyped obj, ?default: ::Integer) -> (Integer | BigDecimal | Numeric)
1748
+ def self.to_decimal: (untyped obj, ?default: untyped) -> (Integer | BigDecimal | Numeric)
1597
1749
 
1598
1750
  # Cast _obj_ to a date and time. Return `nil` if casting fails.
1599
1751
  def self.to_date: (untyped obj) -> untyped
@@ -1742,6 +1894,8 @@ module Liquid2
1742
1894
 
1743
1895
  # Return the subsequence of _left_ starting at _start_ up to _length_.
1744
1896
  def self.slice: (untyped left, untyped start, ?untyped length) -> untyped
1897
+
1898
+ def self.better_slice: (untyped left, ?untyped start_, ?untyped stop_, ?untyped step_, ?start: untyped, ?stop: untyped, ?step: untyped) -> untyped
1745
1899
 
1746
1900
  # Return _left_ with all characters converted to uppercase.
1747
1901
  # Coerce _left_ to a string if it is not one already.
@@ -2551,4 +2705,71 @@ module Liquid2
2551
2705
 
2552
2706
  def block_scope: () -> Array[Identifier]
2553
2707
  end
2554
- end
2708
+ end
2709
+
2710
+ module Liquid2
2711
+ # Base class for all arithmetic expressions.
2712
+ class ArithmeticExpression < Expression
2713
+ @left: untyped
2714
+
2715
+ @right: untyped
2716
+
2717
+ # @param left [Expression]
2718
+ # @param right [Expression]
2719
+ def initialize: ([Symbol, String?, Integer] token, untyped left, untyped right) -> void
2720
+
2721
+ def children: () -> ::Array[untyped]
2722
+
2723
+ def inner_evaluate: (untyped context) -> ::Array[untyped]
2724
+ end
2725
+
2726
+ # Infix addition
2727
+ class Plus < ArithmeticExpression
2728
+ def evaluate: (RenderContext context) -> untyped
2729
+ end
2730
+
2731
+ # Infix subtraction
2732
+ class Minus < ArithmeticExpression
2733
+ def evaluate: (RenderContext context) -> untyped
2734
+ end
2735
+
2736
+ # Infix multiplication
2737
+ class Times < ArithmeticExpression
2738
+ def evaluate: (RenderContext context) -> untyped
2739
+ end
2740
+
2741
+ # Infix division
2742
+ class Divide < ArithmeticExpression
2743
+ def evaluate: (RenderContext context) -> untyped
2744
+ end
2745
+
2746
+ # Infix modulo
2747
+ class Modulo < ArithmeticExpression
2748
+ def evaluate: (RenderContext context) -> untyped
2749
+ end
2750
+
2751
+ # Infix exponentiation
2752
+ class Pow < ArithmeticExpression
2753
+ def evaluate: (RenderContext context) -> untyped
2754
+ end
2755
+
2756
+ # Prefix negation
2757
+ class Negative < Expression
2758
+ @right: untyped
2759
+
2760
+ # @param right [Expression]
2761
+ def initialize: ([Symbol, String?, Integer] token, untyped right) -> void
2762
+
2763
+ def evaluate: (RenderContext context) -> untyped
2764
+ end
2765
+
2766
+ # Prefix positive
2767
+ class Positive < Expression
2768
+ @right: untyped
2769
+
2770
+ # @param right [Expression]
2771
+ def initialize: ([Symbol, String?, Integer] token, untyped right) -> void
2772
+
2773
+ def evaluate: (RenderContext context) -> untyped
2774
+ end
2775
+ end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liquid2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Prior
@@ -85,6 +85,7 @@ files:
85
85
  - lib/liquid2/errors.rb
86
86
  - lib/liquid2/expression.rb
87
87
  - lib/liquid2/expressions/arguments.rb
88
+ - lib/liquid2/expressions/arithmetic.rb
88
89
  - lib/liquid2/expressions/array.rb
89
90
  - lib/liquid2/expressions/blank.rb
90
91
  - lib/liquid2/expressions/boolean.rb
metadata.gz.sig CHANGED
Binary file