Snippets

Milfeulle Wakabamark BNF

Created by Milfeulle last modified

                 Formal definition

initial := 2 ;

NL  ::= (‘\r’)? ‘\n’ ;
BOS ::= begin of string ;
EOS ::= end of string ;
BOL ::= (BOS | NL) ;
EOL ::= (NL | EOS) ;

digit  ::= Character.isDigit () ;
space  ::= Character.isSpace () ;
symbol ::= Character ;

message ::= BOS (message_blocks)+ EOS ;

message_blocks ::= (cite_block
                 |  list_block
                 |  code_block
                 |  text_block initial) ;

list_block        ::= (bullet_list | tiret_list | ordered_list) ;
bullet_list       ::= (bullet_list_item (BOL list_item_content)*)+ ;
bullet_list_item  ::= BOL ‘*’ list_item_content ;
tiret_list        ::= (tiret_list_item (BOL list_item_content)*)+ ;
tiret_list_item   ::= BOL ‘-’ list_item_content ;
ordered_list      ::= (ordered_list_item (BOL list_item_content)*)+ ;
ordered_list_item ::= BOL digit ‘.’ list_item_content ;
list_item_content ::= (‘□’)+ (text initial)+ EOL ;

code_block ::= BOL (‘`’{initial,}) EOL (symbol)* BOL $1 EOL ;

cite_block   ::= BOL cite_body EOL ;
cite_body    ::= ‘>’ cite_content ;
cite_content ::= (‘□’)+ (cite_body | (text initial)+) ;

text_block ::= (text initial)+ EOL (empty_line)+ ;
empty_line ::= (BOL (space)* EOL)+ ;

text (actual)    ::= (format (actual) | atom)+ ;
format (actual)  ::= (spoiler (actual) | cursive | semibold) ;
spoiler (actual) ::= (‘%’{actual})   text actual+1 $1 ;
cursive          ::= (‘_’{initial,}) text actual   $1 ;
semibold         ::= (‘*’{initial,}) text actual   $1 ;
atom             ::= (inline_code | link | symbol) ;
inline_code      ::= (‘`’{initial,}) (symbol)* $1 ;

link          ::= (internal_link | external_link) ;
internal_link ::= “>>” (‘/’ forum_link_id ‘/’)? topic_link_id ;
forum_link_id ::= alpha ;
topic_link_id ::= digit ;
external_link ::= (“http” | “https” | “ftp”) “://” ... ;

Comments (1)

  1. Milfeulle
    • Recursive quoting
    • Recursive text formating
    • Missed strickes — need find a way (formal way) to deal with marks (maybe limit by the current buffer length?)
    • Need backtrack support in implementation (increase algorithm complexity)