Sha256: c85872fd9f23fd2c1b233d5392305a59ad7220d4fb1ddb5623d1812a77b24df7

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

# @Opulent
module Opulent
  # @Parser
  class Parser
    # Check if we match a new node definition to use within our page.
    #
    # Definitions will not be recursive because, by the time we parse
    # the definition children, the definition itself is not in the
    # knowledgebase yet.
    #
    # However, we may use previously defined nodes inside new definitions,
    # due to the fact that they are known at parse time.
    #
    # @param nodes [Array] Parent node to which we append to
    #
    def define(parent, indent)
      if(match = accept :def)
        # Process data
        name = accept(:node, :*).to_sym

        # Create node
        definition = [:def, name, {parameters: attributes}, [], indent]

        # Set definition as root node and let the parser know that we're inside
        # a definition. This is used because inside definitions we do not process
        # nodes (we do not check if they are have a definition or not).
        @inside_definition = true
        root(definition, indent)
        @inside_definition = false

        # Add to parent
        @definitions[name] = definition
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opulent-1.4.5 lib/opulent/parser/define.rb
opulent-1.4.3 lib/opulent/parser/define.rb
opulent-1.4.2 lib/opulent/parser/define.rb
opulent-1.4.1 lib/opulent/parser/define.rb
opulent-1.4.0 lib/opulent/parser/define.rb