Sha256: 617006214cfa568170b5a9763573f58ae73a1ed9f6594f06a366d37076d33dfa

Contents?: true

Size: 774 Bytes

Versions: 2

Compression:

Stored size: 774 Bytes

Contents

# frozen_string_literal: true

class Template
  class Parser
    class Template < Language
      def code
        ::Code::Parser::Code
      end

      def opening_curly_bracket
        str("{")
      end

      def closing_curly_bracket
        str("}")
      end

      def backslash
        str('\\')
      end

      def code_part
        opening_curly_bracket << code << (closing_curly_bracket | any.absent)
      end

      def text_character
        (backslash.ignore << opening_curly_bracket) |
          (opening_curly_bracket.absent << any)
      end

      def text_part
        text_character.repeat(1)
      end

      def root
        (code_part.aka(:code) | text_part.aka(:text)).repeat |
          str("").aka(:text).repeat(1, 1)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
template-ruby-1.1.2 lib/template/parser/template.rb
template-ruby-1.1.0 lib/template/parser/template.rb