Sha256: 617d92ce8ff24d09dd99923751f8d8e1a24152bd715b8a72701a09ab8fd452b1

Contents?: true

Size: 771 Bytes

Versions: 2

Compression:

Stored size: 771 Bytes

Contents

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

2 entries across 2 versions & 1 rubygems

Version Path
basic101-0.4.0 lib/basic101/parser/reference.rb
basic101-0.2.0 lib/basic101/parser/reference.rb