Class: Ciphr::Parser

Inherits:
Parslet::Parser
  • Object
show all
Defined in:
lib/ciphr/parser.rb

Instance Method Summary collapse

Instance Method Details

#pad(&p) ⇒ Object



4
5
6
# File 'lib/ciphr/parser.rb', line 4

def pad(&p)
    spaces? >> p.call >> spaces?
end

#wrapbraces(bs, &p) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/ciphr/parser.rb', line 12

def wrapbraces(bs,&p)
    exp = str('')
    bs.each{|b|
        exp = ( str(b[0]) >> p.call >> str(b[1]) ) | exp
    }
    exp
end

#wrapstr(d) ⇒ Object



8
9
10
# File 'lib/ciphr/parser.rb', line 8

def wrapstr(d)
    str(d) >> ( str('\\') >> any | str(d).absent? >> any ).repeat.maybe.as(:string) >> str(d)
end