start <- expr %eof; expr <- add; add <- a:mult ( "+" b:mult {{ @matches[:a] += @matches[:b] }} / "-" b:mult {{ @matches[:a] -= @matches[:b] }} )* {{ @value = @matches[:a] }}; mult <- a:log ( "*" b:log {{ @matches[:a] *= @matches[:b] }} / "/" b:log {{ @matches[:a] /= @matches[:b] }} )* {{ @value = @matches[:a] }}; log <- LN a:log {{ @value = Math.log(@matches[:a]) }} / value:atom; atom <- value:number / OPEN value:expr CLOSE / PI {{ @value = Math::PI }} / E {{ @value = Math::E }}; number <- float:(([0-9]* "." [0-9]+)([eE][-+]?[0-9]+)?) {{ @value = @matches[:float].to_f }} / int:([+-]?[0-9]+) {{ @value = @matches[:int].to_i }}; LN <- "ln" spacing; OPEN <- "(" spacing; CLOSE <- ")" spacing; PI <- "PI" spacing; E <- "E" spacing; spacing <- [ \n\r\t\f]*;