ometa Initialflow <: Parser { Init_timing = "88bps", Init_key = "c", Init_scale = "major c", Init_position = "" } ometa M <: Parser { digit = super(#digit):d -> d.digitValue() , number = number:n digit:d -> (n*10 + d) | digit , notes = number:n ?(n<20) -> ( n ), notation = '+' -> '"+"' | '-' -> '"-"' | '*' -> '"*"' | '/' -> '"/"', octave = 'v' -> '"v"' | '^' -> '"^"', octave_elements = unit:x spaces octave_elements:y -> (x+', '+y) | unit:x -> (x), octave_unit = octave:x spaces octave_elements:y -> ('['+x+', '+y+']'), notation_unit = unit:x spaces notation:y spaces unit:z -> ( '['+y+', '+x+', '+z+']' ) , testtta = notation_unit , unit = octave_unit:x -> x | notation_unit:x -> x | notes:x -> x , unit_and_space = ' ' unit | unit , tune_string = unit_and_space* , tune = '"' tune_string:x '"' -> x , beat = number:n ? (n<64) -> ( n ) , beat_and_space = ' ' beat | beat , timing_string = beat_and_space* , timing = ':' timing_string:x ':' -> x, scalenote = number:n ? (n<15) -> ( n ), scalenote_and_space = ' ' scalenote | scalenote , scale_string = scalenote_and_space* , scale = '$' scale_string:x '$' -> x, position_2 = '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12' | '13' , position_1 = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' , position = '@' position_1:x position_2:y -> [x+y], definition = anything:x '=' tune spaces timing spaces scale spaces position , program = definition spaces ',' program | definition } M.matchAll('16','notes') M.matchAll('x="1 2 3" :4 4 4: $1 3 5$ @c4','definition') M.matchAll('$1 2 3 4 5 6$','scale') M.matchAll(':4 4 4 4 4 4:','timing') M.matchAll('"1 3 v 5 3 1 ^ 1 2 3 3 + 2"','tune') M.matchAll('1 + 3 + 5','notation_unit') M.matchAll('1 + 3','testtta') M.matchAll('1 + 3','unit') M.matchAll('+','notation') M.matchAll('v','octave') /* ---------------------How To play Music----------------------- MusicCode = "----------------------------" code = M.matchAll(MusicCode,expr) eval(code) -------------------------------- */ ometa L <: Parser { theChars = "aaa" "bbb" "ccc" "Ddd" "eee", theALL = [ theChars ] , thetest = "aaa" | "bbb" } input = "aaa bbb ccc Ddd eee" L.matchAll(input,"theChars") L.match(input,"theALL") L.matchAll('aaa','thetest')