rasti-db 2.0.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -3
  3. data/lib/rasti/db.rb +11 -1
  4. data/lib/rasti/db/collection.rb +10 -1
  5. data/lib/rasti/db/computed_attribute.rb +22 -0
  6. data/lib/rasti/db/nql/filter_condition_strategies/base.rb +17 -0
  7. data/lib/rasti/db/nql/filter_condition_strategies/postgres.rb +21 -0
  8. data/lib/rasti/db/nql/filter_condition_strategies/sqlite.rb +21 -0
  9. data/lib/rasti/db/nql/filter_condition_strategies/types/generic.rb +49 -0
  10. data/lib/rasti/db/nql/filter_condition_strategies/types/pg_array.rb +32 -0
  11. data/lib/rasti/db/nql/filter_condition_strategies/types/sqlite_array.rb +34 -0
  12. data/lib/rasti/db/nql/filter_condition_strategies/unsupported_type_comparison.rb +22 -0
  13. data/lib/rasti/db/nql/nodes/array_content.rb +21 -0
  14. data/lib/rasti/db/nql/nodes/attribute.rb +37 -0
  15. data/lib/rasti/db/nql/nodes/binary_node.rb +4 -0
  16. data/lib/rasti/db/nql/nodes/comparisons/base.rb +15 -1
  17. data/lib/rasti/db/nql/nodes/comparisons/equal.rb +0 -4
  18. data/lib/rasti/db/nql/nodes/comparisons/greater_than.rb +0 -4
  19. data/lib/rasti/db/nql/nodes/comparisons/greater_than_or_equal.rb +0 -4
  20. data/lib/rasti/db/nql/nodes/comparisons/include.rb +0 -4
  21. data/lib/rasti/db/nql/nodes/comparisons/less_than.rb +0 -4
  22. data/lib/rasti/db/nql/nodes/comparisons/less_than_or_equal.rb +0 -4
  23. data/lib/rasti/db/nql/nodes/comparisons/like.rb +0 -4
  24. data/lib/rasti/db/nql/nodes/comparisons/not_equal.rb +0 -4
  25. data/lib/rasti/db/nql/nodes/comparisons/not_include.rb +0 -4
  26. data/lib/rasti/db/nql/nodes/conjunction.rb +2 -2
  27. data/lib/rasti/db/nql/nodes/constants/array.rb +17 -0
  28. data/lib/rasti/db/nql/nodes/constants/base.rb +17 -0
  29. data/lib/rasti/db/nql/nodes/constants/false.rb +1 -1
  30. data/lib/rasti/db/nql/nodes/constants/float.rb +1 -1
  31. data/lib/rasti/db/nql/nodes/constants/integer.rb +1 -1
  32. data/lib/rasti/db/nql/nodes/constants/literal_string.rb +1 -1
  33. data/lib/rasti/db/nql/nodes/constants/string.rb +1 -1
  34. data/lib/rasti/db/nql/nodes/constants/time.rb +1 -1
  35. data/lib/rasti/db/nql/nodes/constants/true.rb +1 -1
  36. data/lib/rasti/db/nql/nodes/disjunction.rb +2 -2
  37. data/lib/rasti/db/nql/nodes/parenthesis_sentence.rb +6 -2
  38. data/lib/rasti/db/nql/nodes/sentence.rb +6 -2
  39. data/lib/rasti/db/nql/syntax.rb +262 -44
  40. data/lib/rasti/db/nql/syntax.treetop +27 -14
  41. data/lib/rasti/db/query.rb +42 -14
  42. data/lib/rasti/db/type_converters/postgres.rb +32 -36
  43. data/lib/rasti/db/type_converters/postgres_types/array.rb +11 -9
  44. data/lib/rasti/db/type_converters/postgres_types/hstore.rb +10 -9
  45. data/lib/rasti/db/type_converters/postgres_types/json.rb +17 -14
  46. data/lib/rasti/db/type_converters/postgres_types/jsonb.rb +17 -14
  47. data/lib/rasti/db/type_converters/sqlite.rb +62 -0
  48. data/lib/rasti/db/type_converters/sqlite_types/array.rb +34 -0
  49. data/lib/rasti/db/version.rb +1 -1
  50. data/rasti-db.gemspec +1 -0
  51. data/spec/collection_spec.rb +19 -11
  52. data/spec/computed_attribute_spec.rb +32 -0
  53. data/spec/minitest_helper.rb +32 -5
  54. data/spec/model_spec.rb +1 -1
  55. data/spec/nql/computed_attributes_spec.rb +29 -0
  56. data/spec/nql/filter_condition_spec.rb +23 -4
  57. data/spec/nql/filter_condition_strategies_spec.rb +112 -0
  58. data/spec/nql/syntax_parser_spec.rb +36 -5
  59. data/spec/query_spec.rb +254 -39
  60. data/spec/type_converters/sqlite_spec.rb +66 -0
  61. metadata +38 -3
  62. data/lib/rasti/db/nql/nodes/field.rb +0 -23
@@ -5,10 +5,6 @@ module Rasti
5
5
  module Comparisons
6
6
  class Equal < Base
7
7
 
8
- def filter_condition
9
- { field.identifier => argument.value }
10
- end
11
-
12
8
  end
13
9
  end
14
10
  end
@@ -5,10 +5,6 @@ module Rasti
5
5
  module Comparisons
6
6
  class GreaterThan < Base
7
7
 
8
- def filter_condition
9
- field.identifier > argument.value
10
- end
11
-
12
8
  end
13
9
  end
14
10
  end
@@ -5,10 +5,6 @@ module Rasti
5
5
  module Comparisons
6
6
  class GreaterThanOrEqual < Base
7
7
 
8
- def filter_condition
9
- field.identifier >= argument.value
10
- end
11
-
12
8
  end
13
9
  end
14
10
  end
@@ -5,10 +5,6 @@ module Rasti
5
5
  module Comparisons
6
6
  class Include < Base
7
7
 
8
- def filter_condition
9
- Sequel.ilike(field.identifier, "%#{argument.value}%")
10
- end
11
-
12
8
  end
13
9
  end
14
10
  end
@@ -5,10 +5,6 @@ module Rasti
5
5
  module Comparisons
6
6
  class LessThan < Base
7
7
 
8
- def filter_condition
9
- field.identifier < argument.value
10
- end
11
-
12
8
  end
13
9
  end
14
10
  end
@@ -5,10 +5,6 @@ module Rasti
5
5
  module Comparisons
6
6
  class LessThanOrEqual < Base
7
7
 
8
- def filter_condition
9
- field.identifier <= argument.value
10
- end
11
-
12
8
  end
13
9
  end
14
10
  end
@@ -5,10 +5,6 @@ module Rasti
5
5
  module Comparisons
6
6
  class Like < Base
7
7
 
8
- def filter_condition
9
- Sequel.ilike(field.identifier, argument.value)
10
- end
11
-
12
8
  end
13
9
  end
14
10
  end
@@ -5,10 +5,6 @@ module Rasti
5
5
  module Comparisons
6
6
  class NotEqual < Base
7
7
 
8
- def filter_condition
9
- Sequel.negate(field.identifier => argument.value)
10
- end
11
-
12
8
  end
13
9
  end
14
10
  end
@@ -5,10 +5,6 @@ module Rasti
5
5
  module Comparisons
6
6
  class NotInclude < Base
7
7
 
8
- def filter_condition
9
- ~ Sequel.ilike(field.identifier, "%#{argument.value}%")
10
- end
11
-
12
8
  end
13
9
  end
14
10
  end
@@ -4,8 +4,8 @@ module Rasti
4
4
  module Nodes
5
5
  class Conjunction < BinaryNode
6
6
 
7
- def filter_condition
8
- Sequel.&(*values.map(&:filter_condition))
7
+ def filter_condition(collection_class)
8
+ Sequel.&(*values.map { |value| value.filter_condition(collection_class) } )
9
9
  end
10
10
 
11
11
  end
@@ -0,0 +1,17 @@
1
+ module Rasti
2
+ module DB
3
+ module NQL
4
+ module Nodes
5
+ module Constants
6
+ class Array < Base
7
+
8
+ def value
9
+ contents.is_a?(ArrayContent) ? contents.values : [contents.value]
10
+ end
11
+
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Rasti
2
+ module DB
3
+ module NQL
4
+ module Nodes
5
+ module Constants
6
+ class Base < Treetop::Runtime::SyntaxNode
7
+
8
+ def type
9
+ Inflecto.underscore(Inflecto.demodulize(self.class)).to_sym
10
+ end
11
+
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -3,7 +3,7 @@ module Rasti
3
3
  module NQL
4
4
  module Nodes
5
5
  module Constants
6
- class False < Treetop::Runtime::SyntaxNode
6
+ class False < Base
7
7
 
8
8
  def value
9
9
  false
@@ -3,7 +3,7 @@ module Rasti
3
3
  module NQL
4
4
  module Nodes
5
5
  module Constants
6
- class Float < Treetop::Runtime::SyntaxNode
6
+ class Float < Base
7
7
 
8
8
  def value
9
9
  text_value.to_f
@@ -3,7 +3,7 @@ module Rasti
3
3
  module NQL
4
4
  module Nodes
5
5
  module Constants
6
- class Integer < Treetop::Runtime::SyntaxNode
6
+ class Integer < Base
7
7
 
8
8
  def value
9
9
  text_value.to_i
@@ -3,7 +3,7 @@ module Rasti
3
3
  module NQL
4
4
  module Nodes
5
5
  module Constants
6
- class LiteralString < Treetop::Runtime::SyntaxNode
6
+ class LiteralString < Base
7
7
 
8
8
  def value
9
9
  string.text_value
@@ -3,7 +3,7 @@ module Rasti
3
3
  module NQL
4
4
  module Nodes
5
5
  module Constants
6
- class String < Treetop::Runtime::SyntaxNode
6
+ class String < Base
7
7
 
8
8
  def value
9
9
  text_value.strip
@@ -3,7 +3,7 @@ module Rasti
3
3
  module NQL
4
4
  module Nodes
5
5
  module Constants
6
- class Time < Treetop::Runtime::SyntaxNode
6
+ class Time < Base
7
7
 
8
8
  def value
9
9
  time.to_s
@@ -3,7 +3,7 @@ module Rasti
3
3
  module NQL
4
4
  module Nodes
5
5
  module Constants
6
- class True < Treetop::Runtime::SyntaxNode
6
+ class True < Base
7
7
 
8
8
  def value
9
9
  true
@@ -4,8 +4,8 @@ module Rasti
4
4
  module Nodes
5
5
  class Disjunction < BinaryNode
6
6
 
7
- def filter_condition
8
- Sequel.|(*values.map(&:filter_condition))
7
+ def filter_condition(collection_class)
8
+ Sequel.|(*values.map { |value| value.filter_condition(collection_class) } )
9
9
  end
10
10
 
11
11
  end
@@ -8,8 +8,12 @@ module Rasti
8
8
  sentence.dependency_tables
9
9
  end
10
10
 
11
- def filter_condition
12
- sentence.filter_condition
11
+ def computed_attributes(collection_class)
12
+ sentence.computed_attributes(collection_class)
13
+ end
14
+
15
+ def filter_condition(collection_class)
16
+ sentence.filter_condition collection_class
13
17
  end
14
18
 
15
19
  end
@@ -8,8 +8,12 @@ module Rasti
8
8
  proposition.dependency_tables
9
9
  end
10
10
 
11
- def filter_condition
12
- proposition.filter_condition
11
+ def computed_attributes(collection_class)
12
+ proposition.computed_attributes collection_class
13
+ end
14
+
15
+ def filter_condition(collection_class)
16
+ proposition.filter_condition collection_class
13
17
  end
14
18
 
15
19
  end
@@ -433,14 +433,14 @@ module Rasti
433
433
  r0
434
434
  end
435
435
 
436
- module Field0
436
+ module Attribute0
437
437
  def table
438
438
  elements[0]
439
439
  end
440
440
 
441
441
  end
442
442
 
443
- module Field1
443
+ module Attribute1
444
444
  def _tables
445
445
  elements[0]
446
446
  end
@@ -450,10 +450,10 @@ module Rasti
450
450
  end
451
451
  end
452
452
 
453
- def _nt_field
453
+ def _nt_attribute
454
454
  start_index = index
455
- if node_cache[:field].has_key?(index)
456
- cached = node_cache[:field][index]
455
+ if node_cache[:attribute].has_key?(index)
456
+ cached = node_cache[:attribute][index]
457
457
  if cached
458
458
  cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
459
459
  @index = cached.interval.end
@@ -465,7 +465,7 @@ module Rasti
465
465
  s1, i1 = [], index
466
466
  loop do
467
467
  i2, s2 = index, []
468
- r3 = _nt_field_name
468
+ r3 = _nt_attribute_name
469
469
  s2 << r3
470
470
  if r3
471
471
  if has_terminal?('.', false, index)
@@ -479,7 +479,7 @@ module Rasti
479
479
  end
480
480
  if s2.last
481
481
  r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
482
- r2.extend(Field0)
482
+ r2.extend(Attribute0)
483
483
  else
484
484
  @index = i2
485
485
  r2 = nil
@@ -493,24 +493,24 @@ module Rasti
493
493
  r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
494
494
  s0 << r1
495
495
  if r1
496
- r5 = _nt_field_name
496
+ r5 = _nt_attribute_name
497
497
  s0 << r5
498
498
  end
499
499
  if s0.last
500
- r0 = instantiate_node(Nodes::Field,input, i0...index, s0)
501
- r0.extend(Field1)
500
+ r0 = instantiate_node(Nodes::Attribute,input, i0...index, s0)
501
+ r0.extend(Attribute1)
502
502
  else
503
503
  @index = i0
504
504
  r0 = nil
505
505
  end
506
506
 
507
- node_cache[:field][start_index] = r0
507
+ node_cache[:attribute][start_index] = r0
508
508
 
509
509
  r0
510
510
  end
511
511
 
512
512
  module ComparisonInclude0
513
- def field
513
+ def attribute
514
514
  elements[0]
515
515
  end
516
516
 
@@ -535,7 +535,7 @@ module Rasti
535
535
  end
536
536
 
537
537
  i0, s0 = index, []
538
- r1 = _nt_field
538
+ r1 = _nt_attribute
539
539
  s0 << r1
540
540
  if r1
541
541
  s2, i2 = [], index
@@ -571,7 +571,7 @@ module Rasti
571
571
  r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
572
572
  s0 << r5
573
573
  if r5
574
- r7 = _nt_basic
574
+ r7 = _nt_argument
575
575
  s0 << r7
576
576
  end
577
577
  end
@@ -591,7 +591,7 @@ module Rasti
591
591
  end
592
592
 
593
593
  module ComparisonNotInclude0
594
- def field
594
+ def attribute
595
595
  elements[0]
596
596
  end
597
597
 
@@ -616,7 +616,7 @@ module Rasti
616
616
  end
617
617
 
618
618
  i0, s0 = index, []
619
- r1 = _nt_field
619
+ r1 = _nt_attribute
620
620
  s0 << r1
621
621
  if r1
622
622
  s2, i2 = [], index
@@ -652,7 +652,7 @@ module Rasti
652
652
  r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
653
653
  s0 << r5
654
654
  if r5
655
- r7 = _nt_basic
655
+ r7 = _nt_argument
656
656
  s0 << r7
657
657
  end
658
658
  end
@@ -672,7 +672,7 @@ module Rasti
672
672
  end
673
673
 
674
674
  module ComparisonLike0
675
- def field
675
+ def attribute
676
676
  elements[0]
677
677
  end
678
678
 
@@ -697,7 +697,7 @@ module Rasti
697
697
  end
698
698
 
699
699
  i0, s0 = index, []
700
- r1 = _nt_field
700
+ r1 = _nt_attribute
701
701
  s0 << r1
702
702
  if r1
703
703
  s2, i2 = [], index
@@ -733,7 +733,7 @@ module Rasti
733
733
  r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
734
734
  s0 << r5
735
735
  if r5
736
- r7 = _nt_basic
736
+ r7 = _nt_argument
737
737
  s0 << r7
738
738
  end
739
739
  end
@@ -753,7 +753,7 @@ module Rasti
753
753
  end
754
754
 
755
755
  module ComparisonGreaterThan0
756
- def field
756
+ def attribute
757
757
  elements[0]
758
758
  end
759
759
 
@@ -778,7 +778,7 @@ module Rasti
778
778
  end
779
779
 
780
780
  i0, s0 = index, []
781
- r1 = _nt_field
781
+ r1 = _nt_attribute
782
782
  s0 << r1
783
783
  if r1
784
784
  s2, i2 = [], index
@@ -814,7 +814,7 @@ module Rasti
814
814
  r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
815
815
  s0 << r5
816
816
  if r5
817
- r7 = _nt_basic
817
+ r7 = _nt_argument
818
818
  s0 << r7
819
819
  end
820
820
  end
@@ -834,7 +834,7 @@ module Rasti
834
834
  end
835
835
 
836
836
  module ComparisonGreaterThanOrEqual0
837
- def field
837
+ def attribute
838
838
  elements[0]
839
839
  end
840
840
 
@@ -859,7 +859,7 @@ module Rasti
859
859
  end
860
860
 
861
861
  i0, s0 = index, []
862
- r1 = _nt_field
862
+ r1 = _nt_attribute
863
863
  s0 << r1
864
864
  if r1
865
865
  s2, i2 = [], index
@@ -895,7 +895,7 @@ module Rasti
895
895
  r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
896
896
  s0 << r5
897
897
  if r5
898
- r7 = _nt_basic
898
+ r7 = _nt_argument
899
899
  s0 << r7
900
900
  end
901
901
  end
@@ -915,7 +915,7 @@ module Rasti
915
915
  end
916
916
 
917
917
  module ComparisonLessThan0
918
- def field
918
+ def attribute
919
919
  elements[0]
920
920
  end
921
921
 
@@ -940,7 +940,7 @@ module Rasti
940
940
  end
941
941
 
942
942
  i0, s0 = index, []
943
- r1 = _nt_field
943
+ r1 = _nt_attribute
944
944
  s0 << r1
945
945
  if r1
946
946
  s2, i2 = [], index
@@ -976,7 +976,7 @@ module Rasti
976
976
  r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
977
977
  s0 << r5
978
978
  if r5
979
- r7 = _nt_basic
979
+ r7 = _nt_argument
980
980
  s0 << r7
981
981
  end
982
982
  end
@@ -996,7 +996,7 @@ module Rasti
996
996
  end
997
997
 
998
998
  module ComparisonLessThanOrEqual0
999
- def field
999
+ def attribute
1000
1000
  elements[0]
1001
1001
  end
1002
1002
 
@@ -1021,7 +1021,7 @@ module Rasti
1021
1021
  end
1022
1022
 
1023
1023
  i0, s0 = index, []
1024
- r1 = _nt_field
1024
+ r1 = _nt_attribute
1025
1025
  s0 << r1
1026
1026
  if r1
1027
1027
  s2, i2 = [], index
@@ -1057,7 +1057,7 @@ module Rasti
1057
1057
  r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1058
1058
  s0 << r5
1059
1059
  if r5
1060
- r7 = _nt_basic
1060
+ r7 = _nt_argument
1061
1061
  s0 << r7
1062
1062
  end
1063
1063
  end
@@ -1077,7 +1077,7 @@ module Rasti
1077
1077
  end
1078
1078
 
1079
1079
  module ComparisonNotEqual0
1080
- def field
1080
+ def attribute
1081
1081
  elements[0]
1082
1082
  end
1083
1083
 
@@ -1102,7 +1102,7 @@ module Rasti
1102
1102
  end
1103
1103
 
1104
1104
  i0, s0 = index, []
1105
- r1 = _nt_field
1105
+ r1 = _nt_attribute
1106
1106
  s0 << r1
1107
1107
  if r1
1108
1108
  s2, i2 = [], index
@@ -1138,7 +1138,7 @@ module Rasti
1138
1138
  r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1139
1139
  s0 << r5
1140
1140
  if r5
1141
- r7 = _nt_basic
1141
+ r7 = _nt_argument
1142
1142
  s0 << r7
1143
1143
  end
1144
1144
  end
@@ -1158,7 +1158,7 @@ module Rasti
1158
1158
  end
1159
1159
 
1160
1160
  module ComparisonEqual0
1161
- def field
1161
+ def attribute
1162
1162
  elements[0]
1163
1163
  end
1164
1164
 
@@ -1183,7 +1183,7 @@ module Rasti
1183
1183
  end
1184
1184
 
1185
1185
  i0, s0 = index, []
1186
- r1 = _nt_field
1186
+ r1 = _nt_attribute
1187
1187
  s0 << r1
1188
1188
  if r1
1189
1189
  s2, i2 = [], index
@@ -1219,7 +1219,7 @@ module Rasti
1219
1219
  r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1220
1220
  s0 << r5
1221
1221
  if r5
1222
- r7 = _nt_basic
1222
+ r7 = _nt_argument
1223
1223
  s0 << r7
1224
1224
  end
1225
1225
  end
@@ -1238,6 +1238,36 @@ module Rasti
1238
1238
  r0
1239
1239
  end
1240
1240
 
1241
+ def _nt_argument
1242
+ start_index = index
1243
+ if node_cache[:argument].has_key?(index)
1244
+ cached = node_cache[:argument][index]
1245
+ if cached
1246
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1247
+ @index = cached.interval.end
1248
+ end
1249
+ return cached
1250
+ end
1251
+
1252
+ i0 = index
1253
+ r1 = _nt_array
1254
+ if r1
1255
+ r0 = r1
1256
+ else
1257
+ r2 = _nt_basic
1258
+ if r2
1259
+ r0 = r2
1260
+ else
1261
+ @index = i0
1262
+ r0 = nil
1263
+ end
1264
+ end
1265
+
1266
+ node_cache[:argument][start_index] = r0
1267
+
1268
+ r0
1269
+ end
1270
+
1241
1271
  def _nt_basic
1242
1272
  start_index = index
1243
1273
  if node_cache[:basic].has_key?(index)
@@ -1288,6 +1318,194 @@ module Rasti
1288
1318
  r0
1289
1319
  end
1290
1320
 
1321
+ module Array0
1322
+ def open
1323
+ elements[0]
1324
+ end
1325
+
1326
+ def contents
1327
+ elements[2]
1328
+ end
1329
+
1330
+ def close
1331
+ elements[4]
1332
+ end
1333
+ end
1334
+
1335
+ def _nt_array
1336
+ start_index = index
1337
+ if node_cache[:array].has_key?(index)
1338
+ cached = node_cache[:array][index]
1339
+ if cached
1340
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1341
+ @index = cached.interval.end
1342
+ end
1343
+ return cached
1344
+ end
1345
+
1346
+ i0, s0 = index, []
1347
+ if has_terminal?('[', false, index)
1348
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
1349
+ @index += 1
1350
+ else
1351
+ terminal_parse_failure('[')
1352
+ r1 = nil
1353
+ end
1354
+ s0 << r1
1355
+ if r1
1356
+ s2, i2 = [], index
1357
+ loop do
1358
+ r3 = _nt_space
1359
+ if r3
1360
+ s2 << r3
1361
+ else
1362
+ break
1363
+ end
1364
+ end
1365
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1366
+ s0 << r2
1367
+ if r2
1368
+ i4 = index
1369
+ r5 = _nt_array_content
1370
+ if r5
1371
+ r4 = r5
1372
+ else
1373
+ r6 = _nt_basic
1374
+ if r6
1375
+ r4 = r6
1376
+ else
1377
+ @index = i4
1378
+ r4 = nil
1379
+ end
1380
+ end
1381
+ s0 << r4
1382
+ if r4
1383
+ s7, i7 = [], index
1384
+ loop do
1385
+ r8 = _nt_space
1386
+ if r8
1387
+ s7 << r8
1388
+ else
1389
+ break
1390
+ end
1391
+ end
1392
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
1393
+ s0 << r7
1394
+ if r7
1395
+ if has_terminal?(']', false, index)
1396
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
1397
+ @index += 1
1398
+ else
1399
+ terminal_parse_failure(']')
1400
+ r9 = nil
1401
+ end
1402
+ s0 << r9
1403
+ end
1404
+ end
1405
+ end
1406
+ end
1407
+ if s0.last
1408
+ r0 = instantiate_node(Nodes::Constants::Array,input, i0...index, s0)
1409
+ r0.extend(Array0)
1410
+ else
1411
+ @index = i0
1412
+ r0 = nil
1413
+ end
1414
+
1415
+ node_cache[:array][start_index] = r0
1416
+
1417
+ r0
1418
+ end
1419
+
1420
+ module ArrayContent0
1421
+ def left
1422
+ elements[0]
1423
+ end
1424
+
1425
+ def right
1426
+ elements[4]
1427
+ end
1428
+ end
1429
+
1430
+ def _nt_array_content
1431
+ start_index = index
1432
+ if node_cache[:array_content].has_key?(index)
1433
+ cached = node_cache[:array_content][index]
1434
+ if cached
1435
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1436
+ @index = cached.interval.end
1437
+ end
1438
+ return cached
1439
+ end
1440
+
1441
+ i0, s0 = index, []
1442
+ r1 = _nt_basic
1443
+ s0 << r1
1444
+ if r1
1445
+ s2, i2 = [], index
1446
+ loop do
1447
+ r3 = _nt_space
1448
+ if r3
1449
+ s2 << r3
1450
+ else
1451
+ break
1452
+ end
1453
+ end
1454
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1455
+ s0 << r2
1456
+ if r2
1457
+ if has_terminal?(',', false, index)
1458
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
1459
+ @index += 1
1460
+ else
1461
+ terminal_parse_failure(',')
1462
+ r4 = nil
1463
+ end
1464
+ s0 << r4
1465
+ if r4
1466
+ s5, i5 = [], index
1467
+ loop do
1468
+ r6 = _nt_space
1469
+ if r6
1470
+ s5 << r6
1471
+ else
1472
+ break
1473
+ end
1474
+ end
1475
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
1476
+ s0 << r5
1477
+ if r5
1478
+ i7 = index
1479
+ r8 = _nt_array_content
1480
+ if r8
1481
+ r7 = r8
1482
+ else
1483
+ r9 = _nt_basic
1484
+ if r9
1485
+ r7 = r9
1486
+ else
1487
+ @index = i7
1488
+ r7 = nil
1489
+ end
1490
+ end
1491
+ s0 << r7
1492
+ end
1493
+ end
1494
+ end
1495
+ end
1496
+ if s0.last
1497
+ r0 = instantiate_node(Nodes::ArrayContent,input, i0...index, s0)
1498
+ r0.extend(ArrayContent0)
1499
+ else
1500
+ @index = i0
1501
+ r0 = nil
1502
+ end
1503
+
1504
+ node_cache[:array_content][start_index] = r0
1505
+
1506
+ r0
1507
+ end
1508
+
1291
1509
  def _nt_space
1292
1510
  start_index = index
1293
1511
  if node_cache[:space].has_key?(index)
@@ -1311,10 +1529,10 @@ module Rasti
1311
1529
  r0
1312
1530
  end
1313
1531
 
1314
- def _nt_field_name
1532
+ def _nt_attribute_name
1315
1533
  start_index = index
1316
- if node_cache[:field_name].has_key?(index)
1317
- cached = node_cache[:field_name][index]
1534
+ if node_cache[:attribute_name].has_key?(index)
1535
+ cached = node_cache[:attribute_name][index]
1318
1536
  if cached
1319
1537
  cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1320
1538
  @index = cached.interval.end
@@ -1343,7 +1561,7 @@ module Rasti
1343
1561
  r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1344
1562
  end
1345
1563
 
1346
- node_cache[:field_name][start_index] = r0
1564
+ node_cache[:attribute_name][start_index] = r0
1347
1565
 
1348
1566
  r0
1349
1567
  end
@@ -2015,7 +2233,7 @@ module Rasti
2015
2233
  return cached
2016
2234
  end
2017
2235
 
2018
- if has_terminal?('\G[0-9a-zA-ZÁÀÄÂÃÅĀĂǍáàäâãåāăǎÉÈËÊĒĔĖĚéèëêēĕėěÍÌÏÎĨĬǏíìïîĩĭǐÓÒÖÔÕŌŎŐǑóòöôõōŏőǒÚÙÜÛŨŪŬŮŰǓúùüûũūŭůűǔÑñçÇ%@#+-_\'?!$*/\\s]', true, index)
2236
+ if has_terminal?('\G[0-9a-zA-ZÁÀÄÂÃÅĀĂǍáàäâãåāăǎÉÈËÊĒĔĖĚéèëêēĕėěÍÌÏÎĨĬǏíìïîĩĭǐÓÒÖÔÕŌŎŐǑóòöôõōŏőǒÚÙÜÛŨŪŬŮŰǓúùüûũūŭůűǔÑñçÇ%@#+\\--Z\\\\^_\'?!$*/\\s]', true, index)
2019
2237
  r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
2020
2238
  @index += 1
2021
2239
  else
@@ -2243,7 +2461,7 @@ module Rasti
2243
2461
  return cached
2244
2462
  end
2245
2463
 
2246
- if has_terminal?('\G[&|.():!=<>~]', true, index)
2464
+ if has_terminal?('\G[&|.():!=<>~,\\]\\[]', true, index)
2247
2465
  r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
2248
2466
  @index += 1
2249
2467
  else