Sha256: 4f519ae8409b98d883cba3f2b0a00fc27b6719058db4071bf6ceb511a43269d0

Contents?: true

Size: 802 Bytes

Versions: 3

Compression:

Stored size: 802 Bytes

Contents

# frozen_string_literal: true

module Basic101

  class Parser < Parslet::Parser

    rule(:scalar_reference_list) do
      scalar_reference >>
        (space? >> str(',') >>
         space? >> scalar_reference).repeat(0)
    end

    rule(:reference_list) do
      reference >> (space? >> str(',') >> space? >> reference).repeat(0)
    end

    rule(:reference) do
      array_reference | scalar_reference
    end

    rule(:array_reference) do
      identifier.as(:subscript_base) >> space? >> 
        str('(') >> space? >> argument_list.as(:argument_list) >>
        space? >> str(')')
    end

    rule(:scalar_reference) do
      identifier.as(:scalar_reference)
    end

    rule(:argument_list) do
      expression >> (space? >> str(',') >> space? >> expression).repeat(0)
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
basic101-1.0.2 lib/basic101/parser/reference.rb
basic101-1.0.1 lib/basic101/parser/reference.rb
basic101-1.0.0 lib/basic101/parser/reference.rb