bel_parser 1.0.0.alpha.38-java → 1.0.0.alpha.39-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/bel_parser/ast_filter.rb +6 -2
  4. data/lib/bel_parser/parsers/ast/node.rb +113 -58
  5. data/lib/bel_parser/parsers/bel_script/define_annotation.rb +4175 -3097
  6. data/lib/bel_parser/parsers/bel_script/define_annotation.rl +142 -49
  7. data/lib/bel_parser/parsers/bel_script/define_namespace.rb +980 -461
  8. data/lib/bel_parser/parsers/bel_script/define_namespace.rl +79 -39
  9. data/lib/bel_parser/parsers/bel_script/set.rb +4878 -2743
  10. data/lib/bel_parser/parsers/bel_script/set.rl +114 -32
  11. data/lib/bel_parser/parsers/bel_script/set_document.rb +5839 -5292
  12. data/lib/bel_parser/parsers/bel_script/set_document.rl +130 -27
  13. data/lib/bel_parser/parsers/bel_script/unset.rb +321 -234
  14. data/lib/bel_parser/parsers/bel_script/unset.rl +49 -21
  15. data/lib/bel_parser/parsers/common/blank_line.rb +12 -11
  16. data/lib/bel_parser/parsers/common/blank_line.rl +12 -12
  17. data/lib/bel_parser/parsers/common/comment_line.rb +65 -40
  18. data/lib/bel_parser/parsers/common/comment_line.rl +26 -26
  19. data/lib/bel_parser/parsers/common/common.rl +60 -0
  20. data/lib/bel_parser/parsers/common/function.rb +319 -0
  21. data/lib/bel_parser/parsers/common/function.rl +149 -0
  22. data/lib/bel_parser/parsers/common/identifier.rb +72 -68
  23. data/lib/bel_parser/parsers/common/identifier.rl +73 -29
  24. data/lib/bel_parser/parsers/common/list.rb +1617 -1243
  25. data/lib/bel_parser/parsers/common/list.rl +120 -60
  26. data/lib/bel_parser/parsers/common/string.rb +114 -41
  27. data/lib/bel_parser/parsers/common/string.rl +91 -28
  28. data/lib/bel_parser/parsers/common.rb +1 -0
  29. data/lib/bel_parser/parsers/expression/comment.rb +70 -38
  30. data/lib/bel_parser/parsers/expression/comment.rl +37 -20
  31. data/lib/bel_parser/parsers/expression/nested_statement.rb +63116 -13958
  32. data/lib/bel_parser/parsers/expression/nested_statement.rl +53 -23
  33. data/lib/bel_parser/parsers/expression/observed_term.rb +32497 -5188
  34. data/lib/bel_parser/parsers/expression/observed_term.rl +25 -20
  35. data/lib/bel_parser/parsers/expression/parameter.rb +2861 -847
  36. data/lib/bel_parser/parsers/expression/parameter.rl +178 -21
  37. data/lib/bel_parser/parsers/expression/relationship.rb +73 -55
  38. data/lib/bel_parser/parsers/expression/relationship.rl +41 -23
  39. data/lib/bel_parser/parsers/expression/simple_statement.rb +42895 -7846
  40. data/lib/bel_parser/parsers/expression/simple_statement.rl +41 -24
  41. data/lib/bel_parser/parsers/expression/term.rb +16498 -2602
  42. data/lib/bel_parser/parsers/expression/term.rl +52 -35
  43. data/lib/bel_parser/parsers/line_parser.rb +1 -0
  44. data/lib/bel_parser/parsers/mixin/buffer.rb +4 -0
  45. data/lib/bel_parser/parsers/tracer.rb +19 -0
  46. data/lib/bel_parser/script/state/namespace_definition.rb +1 -0
  47. metadata +10 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8054ff03d78df3934f61db423d11059802405f5
4
- data.tar.gz: 456a92fc5131cf4a59c53bf18771383db86a8fe4
3
+ metadata.gz: b7551ea8874262a96c2623bccbc0b78873f9d1f3
4
+ data.tar.gz: bd52f9cd988e9eb57fcea386da40ec33b71f7b32
5
5
  SHA512:
6
- metadata.gz: 887008830f084cf37e994e15a79ae991a4a6d268f319d673f9234f6d498a0171c9d1b65ea1d315891f59de7c5775e50ae9ecad208cf96e5b095b4f6c5a5686ee
7
- data.tar.gz: f3a7824168869bce31ce8c1f2f834cfe64c8335e231acb059691100075826405b77c8013f361e7f665c528bef59efc79be0ec4419891b0afa2f4387aecc25ba4
6
+ metadata.gz: 7d348dbd7674466b52d19a357b1561b9e02e6a7748931da8e0a32cee14c0b58fcdf11df308dce3e5f47360f1f15d079c07e967f3739a8098ed2384387675b64e
7
+ data.tar.gz: c288f3d3f77eae55d791ce8f272990a3c67b753a3fb7a77a0518cd6048974af9602a21ee01f20d0da79d5a02f85f0bf68f7d9b50b7e1d63a39d070ff93dca88f
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.alpha.38
1
+ 1.0.0.alpha.39
@@ -5,7 +5,7 @@ module BELParser
5
5
  class ASTFilter
6
6
  def initialize(ast_enum, *types)
7
7
  @ast_enum = ast_enum
8
- @types = types
8
+ @types = Hash[types.map { |t| [t, true] }]
9
9
  end
10
10
 
11
11
  def each(enum = @ast_enum)
@@ -21,7 +21,11 @@ module BELParser
21
21
 
22
22
  def filter(ast_enum)
23
23
  ast_enum.select do |node|
24
- @types.include?(node.type)
24
+ if node.nil?
25
+ @types[nil]
26
+ else
27
+ @types[node.type]
28
+ end
25
29
  end
26
30
  end
27
31
  end
@@ -148,6 +148,53 @@ module BELParser
148
148
  updated(@children + [element])
149
149
  end
150
150
 
151
+ # Get the child at the specified _index_.
152
+ #
153
+ # @param [Fixnum] index the index to get
154
+ # @return [Node, nil] the child of this node at the indicated index
155
+ # or nil if not present
156
+ def child(index)
157
+ @children[index]
158
+ end
159
+
160
+ # Get the child at index 0.
161
+ # @see #child
162
+ def first_child
163
+ child 0
164
+ end
165
+
166
+ # Get the child at index 1.
167
+ # @see #child
168
+ def second_child
169
+ child 1
170
+ end
171
+
172
+ # Get the child at index 2.
173
+ # @see #child
174
+ def third_child
175
+ child 2
176
+ end
177
+
178
+ # Get the child at index 3.
179
+ # @see #child
180
+ def fourth_child
181
+ child 3
182
+ end
183
+
184
+ # Get the number of children.
185
+ #
186
+ # @return [Fixnum] the number of children
187
+ def num_children
188
+ @children.size
189
+ end
190
+
191
+ # Get whether this node has children.
192
+ #
193
+ # @return [true, false]
194
+ def children?
195
+ !@children.empty?
196
+ end
197
+
151
198
  alias << append
152
199
  end
153
200
 
@@ -803,8 +850,12 @@ module BELParser
803
850
  end
804
851
 
805
852
  # Get what is being unset.
853
+ #
854
+ # @return [String, nil] what is being unset
806
855
  def name
807
- children[0]
856
+ return nil unless children?
857
+ return nil unless first_child.children?
858
+ first_child.first_child
808
859
  end
809
860
  end
810
861
 
@@ -862,124 +913,128 @@ module BELParser
862
913
  #
863
914
  # @see https://en.wikipedia.org/wiki/S-expression S-expression
864
915
  module Sexp
865
- def nested_statement(*children)
866
- NestedStatement.new(children)
916
+ def nested_statement(*children, **props)
917
+ NestedStatement.new(children, props)
867
918
  end
868
919
 
869
- def simple_statement(*children)
870
- SimpleStatement.new(children)
920
+ def simple_statement(*children, **props)
921
+ SimpleStatement.new(children, props)
871
922
  end
872
923
 
873
- def observed_term(*children)
874
- ObservedTerm.new(children)
924
+ def observed_term(*children, **props)
925
+ ObservedTerm.new(children, props)
875
926
  end
876
927
 
877
- def statement(*children)
878
- Statement.new(children)
928
+ def statement(*children, **props)
929
+ Statement.new(children, props)
879
930
  end
880
931
 
881
- def subject(*children)
882
- Subject.new(children)
932
+ def subject(*children, **props)
933
+ Subject.new(children, props)
883
934
  end
884
935
 
885
- def object(*children)
886
- Object.new(children)
936
+ def object(*children, **props)
937
+ Object.new(children, props)
887
938
  end
888
939
 
889
- def relationship(*children)
890
- Relationship.new(children)
940
+ def relationship(*children, **props)
941
+ Relationship.new(children, props)
891
942
  end
892
943
 
893
- def term(*children)
894
- Term.new(children)
944
+ def term(*children, **props)
945
+ Term.new(children, props)
895
946
  end
896
947
 
897
- def function(*children)
898
- Function.new(children)
948
+ def function(*children, **props)
949
+ Function.new(children, props)
899
950
  end
900
951
 
901
- def argument(*children)
902
- Argument.new(children)
952
+ def argument(*children, **props)
953
+ Argument.new(children, props)
903
954
  end
904
955
 
905
- def parameter(*children)
906
- Parameter.new(children)
956
+ def parameter(*children, **props)
957
+ Parameter.new(children, props)
907
958
  end
908
959
 
909
- def prefix(*children)
910
- Prefix.new(children)
960
+ def prefix(*children, **props)
961
+ Prefix.new(children, props)
911
962
  end
912
963
 
913
- def name(*children)
914
- Name.new(children)
964
+ def name(*children, **props)
965
+ Name.new(children, props)
915
966
  end
916
967
 
917
- def value(*children)
918
- Value.new(children)
968
+ def value(*children, **props)
969
+ Value.new(children, props)
919
970
  end
920
971
 
921
- def identifier(*children)
922
- Identifier.new(children)
972
+ def identifier(*children, **props)
973
+ Identifier.new(children, props)
923
974
  end
924
975
 
925
- def string(*children)
926
- String.new(children)
976
+ def string(*children, **props)
977
+ String.new(children, props)
927
978
  end
928
979
 
929
- def list(*children)
930
- List.new(children)
980
+ def list(*children, **props)
981
+ List.new(children, props)
931
982
  end
932
983
 
933
- def list_item(*children)
934
- ListItem.new(children)
984
+ def list_item(*children, **props)
985
+ ListItem.new(children, props)
935
986
  end
936
987
 
937
- def comment(*children)
938
- Comment.new(children)
988
+ def comment(*children, **props)
989
+ Comment.new(children, props)
939
990
  end
940
991
 
941
- def comment_line(*children)
942
- CommentLine.new(children)
992
+ def comment_line(*children, **props)
993
+ CommentLine.new(children, props)
943
994
  end
944
995
 
945
996
  def blank_line
946
- BlankLine.new
997
+ BlankLine.new([], complete: true)
947
998
  end
948
999
 
949
- def set(*children)
950
- Set.new(children)
1000
+ def set(*children, **props)
1001
+ Set.new(children, props)
951
1002
  end
952
1003
 
953
1004
  def unset(*children)
954
1005
  Unset.new(children)
955
1006
  end
956
1007
 
957
- def document_property(*children)
958
- DocumentProperty.new(children)
1008
+ def document_property(*children, **props)
1009
+ DocumentProperty.new(children, props)
1010
+ end
1011
+
1012
+ def annotation_definition(*children, **props)
1013
+ AnnotationDefinition.new(children, props)
959
1014
  end
960
1015
 
961
- def annotation_definition(*children)
962
- AnnotationDefinition.new(children)
1016
+ def namespace_definition(*children, **props)
1017
+ NamespaceDefinition.new(children, props)
963
1018
  end
964
1019
 
965
- def namespace_definition(*children)
966
- NamespaceDefinition.new(children)
1020
+ def keyword(*children, **props)
1021
+ Keyword.new(children, props)
967
1022
  end
968
1023
 
969
- def keyword(*children)
970
- Keyword.new(children)
1024
+ def domain(*children, **props)
1025
+ Domain.new(children, props)
971
1026
  end
972
1027
 
973
- def domain(*children)
974
- Domain.new(children)
1028
+ def url(*children, **props)
1029
+ Url.new(children, props)
975
1030
  end
976
1031
 
977
- def url(*children)
978
- Url.new(children)
1032
+ def pattern(*children, **props)
1033
+ Pattern.new(children, props)
979
1034
  end
980
1035
 
981
- def pattern(*children)
982
- Pattern.new(children)
1036
+ def unset(*children, **props)
1037
+ Unset.new(children, props)
983
1038
  end
984
1039
  end
985
1040
  end