Sha256: 130e139eeb4830d79ac18ac3720f143749b5297c64e0ba1f2bbe46dc445af47e

Contents?: true

Size: 955 Bytes

Versions: 19

Compression:

Stored size: 955 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)
      end

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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
code-ruby-0.10.1 lib/code/parser/whitespace.rb
code-ruby-0.10.0 lib/code/parser/whitespace.rb
code-ruby-0.9.3 lib/code/parser/whitespace.rb
code-ruby-0.9.2 lib/code/parser/whitespace.rb
code-ruby-0.9.1 lib/code/parser/whitespace.rb
code-ruby-0.9.0 lib/code/parser/whitespace.rb
code-ruby-0.8.5 lib/code/parser/whitespace.rb
code-ruby-0.8.4 lib/code/parser/whitespace.rb
code-ruby-0.8.3 lib/code/parser/whitespace.rb
code-ruby-0.8.2 lib/code/parser/whitespace.rb
code-ruby-0.8.1 lib/code/parser/whitespace.rb
code-ruby-0.8.0 lib/code/parser/whitespace.rb
code-ruby-0.7.8 lib/code/parser/whitespace.rb
code-ruby-0.7.7 lib/code/parser/whitespace.rb
code-ruby-0.7.6 lib/code/parser/whitespace.rb
code-ruby-0.7.5 lib/code/parser/whitespace.rb
code-ruby-0.7.4 lib/code/parser/whitespace.rb
code-ruby-0.7.3 lib/code/parser/whitespace.rb
code-ruby-0.7.2 lib/code/parser/whitespace.rb