Sha256: e85c73eff57dbba3dbfc70e0672de32a676a1897178cbc0964d04f554897b24d

Contents?: true

Size: 1.2 KB

Versions: 20

Compression:

Stored size: 1.2 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)
      return unless accept(:def)

      # Definition parent check
      Logger.error :parse, @code, @i, @j, :definition if parent[@type] != :root

      # Process data
      name = accept(:node, :*).to_sym

      # Create node
      definition = [
        :def,
        name,
        { parameters: attributes({}, true) },
        [],
        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).
      root definition, indent

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
opulent-1.8.5 lib/opulent/parser/define.rb
opulent-1.8.4 lib/opulent/parser/define.rb
opulent-1.8.3 lib/opulent/parser/define.rb
opulent-1.8.2 lib/opulent/parser/define.rb
opulent-1.8.1 lib/opulent/parser/define.rb
opulent-1.8.0 lib/opulent/parser/define.rb
opulent-1.7.11 lib/opulent/parser/define.rb
opulent-1.7.10 lib/opulent/parser/define.rb
opulent-1.7.9 lib/opulent/parser/define.rb
opulent-1.7.8 lib/opulent/parser/define.rb
opulent-1.7.7 lib/opulent/parser/define.rb
opulent-1.7.6 lib/opulent/parser/define.rb
opulent-1.7.5 lib/opulent/parser/define.rb
opulent-1.7.4 lib/opulent/parser/define.rb
opulent-1.7.3 lib/opulent/parser/define.rb
opulent-1.7.2 lib/opulent/parser/define.rb
opulent-1.7.1 lib/opulent/parser/define.rb
opulent-1.7.0 lib/opulent/parser/define.rb
opulent-1.6.9 lib/opulent/parser/define.rb
opulent-1.6.8 lib/opulent/parser/define.rb