Sha256: 3d9d6db4845fa568a670b64c5ed3bb8e7b00f9fd317bc39d8f83d0f52f5010bd

Contents?: true

Size: 1.63 KB

Versions: 49

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

class Code
  class Parser
    class String < Language
      def code
        Code
      end

      def name
        Name
      end

      def single_quote
        str("'")
      end

      def double_quote
        str('"')
      end

      def backslash
        str("\\")
      end

      def opening_curly_bracket
        str("{")
      end

      def closing_curly_bracket
        str("}")
      end

      def colon
        str(":")
      end

      def code_part
        opening_curly_bracket << code << closing_curly_bracket.maybe
      end

      def single_quoted_text_part
        (
          backslash.ignore << opening_curly_bracket |
            backslash.ignore << single_quote |
            single_quote.absent << opening_curly_bracket.absent << any
        ).repeat(1)
      end

      def double_quoted_text_part
        (
          backslash.ignore << opening_curly_bracket |
            backslash.ignore << double_quote |
            double_quote.absent << opening_curly_bracket.absent << any
        ).repeat(1)
      end

      def single_quoted_string
        single_quote.ignore << (
          code_part.aka(:code) | single_quoted_text_part.aka(:text)
        ).repeat << single_quote.ignore.maybe
      end

      def double_quoted_string
        double_quote.ignore << (
          code_part.aka(:code) | double_quoted_text_part.aka(:text)
        ).repeat << double_quote.ignore.maybe
      end

      def symbol
        (colon.ignore << name).aka(:text).repeat(1, 1)
      end

      def root
        (single_quoted_string | double_quoted_string | symbol).aka(:string) |
          Number
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
code-ruby-1.0.0 lib/code/parser/string.rb
code-ruby-0.15.16 lib/code/parser/string.rb
code-ruby-0.15.15 lib/code/parser/string.rb
code-ruby-0.15.14 lib/code/parser/string.rb
code-ruby-0.15.13 lib/code/parser/string.rb
code-ruby-0.15.12 lib/code/parser/string.rb
code-ruby-0.15.11 lib/code/parser/string.rb
code-ruby-0.15.10 lib/code/parser/string.rb
code-ruby-0.15.9 lib/code/parser/string.rb
code-ruby-0.15.8 lib/code/parser/string.rb
code-ruby-0.15.7 lib/code/parser/string.rb
code-ruby-0.15.6 lib/code/parser/string.rb
code-ruby-0.15.5 lib/code/parser/string.rb
code-ruby-0.15.4 lib/code/parser/string.rb
code-ruby-0.15.3 lib/code/parser/string.rb
code-ruby-0.15.2 lib/code/parser/string.rb
code-ruby-0.15.0 lib/code/parser/string.rb
code-ruby-0.14.9 lib/code/parser/string.rb
code-ruby-0.14.8 lib/code/parser/string.rb
code-ruby-0.14.6 lib/code/parser/string.rb