有一个在线生成工具:http://railroad.my28msec.com/rr/ui
示例1:来自Stack Overflow
object ::= '{' ((string ':' value ) ( ',' string ':' value )*)? '}'
示例2:包含+, -, *,括号的算术表达式描述(EBNF)
exp ::= term (addop term)* term ::= factor ('*' factor)* addop ::= '+' |'-' factor ::= '(' exp ')' | [0-9]+
得到的Syntax/Railroad Diagram
exp:
referenced by:factor
term:
term ::= factor ( '*' factor )*
referenced by:exp
addop:
addop ::= '+' | '-'
referenced by:exp
factor:
referenced by:term
更多示例