progs/re1.scala
changeset 546 6589afc6789b
parent 513 676e6484f29b
child 550 71fc4a7a7039
equal deleted inserted replaced
545:76a98ed71a2a 546:6589afc6789b
    47 
    47 
    48 val r = STAR(ALT(SEQ(CHAR('a'), CHAR('b')), CHAR('b')))
    48 val r = STAR(ALT(SEQ(CHAR('a'), CHAR('b')), CHAR('b')))
    49 der('a', r)
    49 der('a', r)
    50 der('b', r)
    50 der('b', r)
    51 der('c', r)
    51 der('c', r)
       
    52 
       
    53 val r = SEQ(SEQ(CHAR('x'), CHAR('y')), CHAR('z'))
       
    54 der('x', r)
       
    55 der('y', der('x', r))
       
    56 der('z', der('y', der('x', r)))
       
    57 
    52 
    58 
    53 //optional regular expression (one or zero times)
    59 //optional regular expression (one or zero times)
    54 def OPT(r: Rexp) = ALT(r, ONE)
    60 def OPT(r: Rexp) = ALT(r, ONE)
    55 
    61 
    56 //n-times regular expression (explicitly expanded)
    62 //n-times regular expression (explicitly expanded)