lib/bel_parser/parsers/ast/node.rb in bel_parser-1.0.0.alpha.13 vs lib/bel_parser/parsers/ast/node.rb in bel_parser-1.0.0.alpha.14

- old
+ new

@@ -207,10 +207,20 @@ # # @see Node#initialize Node class for basic properties def initialize(children = [], properties = {}) super(AnnotationDefinition.ast_type, children, properties) end + + # Get the annotation definition's keyword. + def keyword + children[0] + end + + # Get the annotation definition's domain. + def domain + children[1] + end end # AST node representing the function of a BEL term. # # === Special node properties - _return_type_: {#return_type} @@ -294,18 +304,28 @@ # @see Node#initialize Node class for basic properties def initialize(children = [], properties = {}) super(Domain.ast_type, children, properties) end + # Determine if this is a LIST domain. + def list? + children[0] && children[0].is_a?(List) + end + + # Determine if this is a PATTERN domain. + def pattern? + children[0] && children[0].is_a?(Pattern) + end + # Determine if this is a URL domain. def url? children[0] && children[0].is_a?(Url) end # Get the domain's Url. - def url - url? ? children[0] : nil + def child + children[0] end end # AST node representing a URL. class Url < Node @@ -378,10 +398,14 @@ # # @see Node#initialize Node class for basic properties def initialize(children = [], properties = {}) super(List.ast_type, children, properties) end + + def list_items + children + end end # AST node representing a list item. class ListItem < Node # AST node type @@ -778,11 +802,11 @@ super(Unset.ast_type, children, properties) end # Get what is being unset. def name - # TODO: access children for content + children[0] end end # AST node representing a name. class Name < Node @@ -817,9 +841,12 @@ # # @see Node#initialize Node class for basic properties def initialize(children = [], properties = {}) super(Value.ast_type, children, properties) end + + # Get/Set the namespace prefix. + attr_accessor :prefix # Get/Set the value's encoding. attr_accessor :encoding # Get/Set the value's namespace.