solutions/cw2/lexer.sc
changeset 919 53f08d873e09
parent 897 904de68a27a4
child 920 7af2eea19646
equal deleted inserted replaced
918:53e7da9f372a 919:53f08d873e09
    35 }
    35 }
    36 
    36 
    37 implicit def string2rexp(s : String) : Rexp = 
    37 implicit def string2rexp(s : String) : Rexp = 
    38   charlist2rexp(s.toList)
    38   charlist2rexp(s.toList)
    39 
    39 
    40 implicit def RexpOps(r: Rexp) = new {
    40 extension (r: Rexp) {
       
    41   def ~ (s: Rexp) = SEQ(r, s)
       
    42   def % = STAR(r)
    41   def | (s: Rexp) = ALT(r, s)
    43   def | (s: Rexp) = ALT(r, s)
    42   def % = STAR(r)
    44 }
    43   def ~ (s: Rexp) = SEQ(r, s)
    45 
    44 }
    46 
    45 
    47 extension (s: String) {
    46 implicit def stringOps(s: String) = new {
       
    47   def | (r: Rexp) = ALT(s, r)
    48   def | (r: Rexp) = ALT(s, r)
    48   def | (r: String) = ALT(s, r)
    49   def | (r: String) = ALT(s, r)
    49   def % = STAR(s)
    50   def % = STAR(s)
    50   def ~ (r: Rexp) = SEQ(s, r)
    51   def ~ (r: Rexp) = SEQ(s, r)
    51   def ~ (r: String) = SEQ(s, r)
    52   def ~ (r: String) = SEQ(s, r)