newline = ${ "\n" | "\r" }
space = ${ " "+ }
other = ${ !(string) ~ ANY }
comment = ${ single_line_comment | multiline_comment }
single_line_comment = _{ "#" ~ (!(newline) ~ ANY)* }
multiline_comment = _{ "/*" ~ (!("*/") ~ ANY)* ~ "*/"}
string = ${ string_val }
string_val = _{
("'" ~ (!(newline | "'") ~ ANY)* ~ "'")
| ("\"" ~ (!(newline | "\"") ~ ANY)* ~ "\"")
}
regexp = ${
(PUSH("/") ~ (!(newline | "/") ~ ANY)* ~ POP )
| ( "%r{" ~ (!(newline | "}") ~ ANY)* ~ "}" )
| ("Regexp.new(" ~ " "* ~ string_val ~ (!")" ~ ANY)* ~ ")")
}
line = _{ string | regexp | comment | space | other | newline }
item = _{ SOI ~ line* ~ EOI }