Sha256: 8e45f1d717131c72b4a5ed907e9c7a8fec2b54e4c88d7406d36ad5148ff8e670

Contents?: true

Size: 982 Bytes

Versions: 33

Compression:

Stored size: 982 Bytes

Contents

# frozen_string_literal: true

class Code
  class Parser
    class Whitespace < Language
      def space
        str(" ")
      end

      def newline
        str("\n") | str("\r")
      end

      def hashtag
        str("#")
      end

      def slash
        str("/")
      end

      def asterisk
        str("*")
      end

      def hash_comment
        hashtag << (newline.absent << any).repeat << newline.maybe
      end

      def double_slash_comment
        slash << slash << (newline.absent << any).repeat << newline.maybe
      end

      def multi_line_comment
        slash << asterisk << ((asterisk << slash).absent << any).repeat <<
          asterisk.maybe << slash.maybe
      end

      def without_newline
        (space | multi_line_comment).repeat(1).ignore
      end

      def root
        (
          space | newline | hash_comment | double_slash_comment |
            multi_line_comment
        ).repeat(1).ignore | any.absent
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
code-ruby-1.1.3 lib/code/parser/whitespace.rb
code-ruby-1.1.1 lib/code/parser/whitespace.rb
code-ruby-1.1.0 lib/code/parser/whitespace.rb
code-ruby-1.0.0 lib/code/parser/whitespace.rb
code-ruby-0.15.16 lib/code/parser/whitespace.rb
code-ruby-0.15.15 lib/code/parser/whitespace.rb
code-ruby-0.15.14 lib/code/parser/whitespace.rb
code-ruby-0.15.13 lib/code/parser/whitespace.rb
code-ruby-0.15.12 lib/code/parser/whitespace.rb
code-ruby-0.15.11 lib/code/parser/whitespace.rb
code-ruby-0.15.10 lib/code/parser/whitespace.rb
code-ruby-0.15.9 lib/code/parser/whitespace.rb
code-ruby-0.15.8 lib/code/parser/whitespace.rb
code-ruby-0.15.7 lib/code/parser/whitespace.rb
code-ruby-0.15.6 lib/code/parser/whitespace.rb
code-ruby-0.15.5 lib/code/parser/whitespace.rb
code-ruby-0.15.4 lib/code/parser/whitespace.rb
code-ruby-0.15.3 lib/code/parser/whitespace.rb
code-ruby-0.15.2 lib/code/parser/whitespace.rb
code-ruby-0.15.0 lib/code/parser/whitespace.rb