char = _{
!("\\" | "|" | "\t" | "\r" | "\n") ~ ANY
}
comment_char = _{
!("\r" | "\n") ~ ANY
}
char_seq = @{
char+
}
comment_text = @{
comment_char*
}
escaped = {
"\\\\"
| "\\|"
| "\\n"
| "\\t"
| "\\r"
}
content = {
(char_seq | escaped)+
}
tabs = @{
"\t"*
}
new_line = { "\n" | "\r\n" | "\r" }
param_item = { "|" ~ content }
main_line = {
main_line_start_symbol? ~ content ~ param_item* ~ line_continuation?
}
content_for_empty_line = { content }
define_stmt = {
define_stmt_start_symbol ~ content? ~ ("|" ~ content_for_empty_line)? ~ ("||" ~ comment_text)?
}
continued_line = {
tabs ~ (continued_line_with_content | continued_line_without_content)
}
continued_line_with_content = {
content ~ param_item* ~ line_continuation?
}
continued_line_without_content = {
param_item+ ~ line_continuation?
}
continuation = {
tabs ~ param_item+ ~ line_continuation?
}
line_continuation = {
normal_end
| backslash_comment_end
| backslash_end
| single_bar
| triple_bars
| double_bars
}
triple_bars = { "|||" ~ comment_text ~ new_line ~ continued_line }
double_bars = { "||" ~ comment_text ~ (new_line ~ continuation)? }
single_bar = { "|" ~ new_line ~ continued_line }
normal_end = { new_line ~ continuation }
backslash_end = { "\\" ~ new_line ~ continued_line }
backslash_comment_end = { "||\\" ~ comment_text ~ new_line ~ continued_line }
main_line_start_symbol = {
">\\"
| "\\>>>"
| "\\>>"
| "\\>"
}
define_stmt_start_symbol = {
">>>"
| ">>"
| ">"
}
commented_line = {
"||" ~ comment_text
}
line_contents = {
((!">" ~ main_line) | commented_line | (!">\\" ~ &">" ~ define_stmt) | (&">" ~ main_line))
}
file = {
SOI ~ (tabs ~ line_contents? ~ new_line)* ~ tabs ~ line_contents? ~ EOI
}