Module: Peg::Parsers::AdvancedParsers

Includes:
Combinators, Peg::Parsers
Defined in:
lib/peg.backup/parsers/advanced_parsers.rb

Instance Method Summary collapse

Methods included from BaseParsers

#char_class_parser, #char_parser, #end_parser, #make_parser, #make_parsers

Methods included from CommonParsers

#id_parser, #int_parser, #literal_set, #ws_parser

Methods included from Combinators

#lookahead, #many, #map, #map_result, #maybe, #satisfy, #select, #sequence

Methods included from Combinators::Implementation

#_debug, #_lookahead, #_many, #_map_result, #_satisfy, #_select, #_sequence

Instance Method Details

#list_parser(element_parser:, seperator_parser:, name: "list parser") ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/peg.backup/parsers/advanced_parsers.rb', line 11

def list_parser(element_parser:, seperator_parser:, name: "list parser")
  sequence(
    element_parser,
    many(
      sequence(
        seperator_parser, element_parser
      )
        .map { it[1] }
    )
  )
    .map { it.flatten.compact }
end