我想找到下一个问题的解决方案,但我需要以年-月-日和月-日-年两种格式编写时间的 EBNF 以查看差异:
确定将日期写为结构化整数的一个优点:年、月、日 (1954-02-10),而不是按正常顺序 (02-10-1954)。
格式:年-月-日。这是我想出的:
<NonZeroDigit> ::= ("1" | "2" | ... | "9")
<Month> ::= ( "0" <NonZeroDigit> ) | ( "1" ( "0" | "1" | "2" ) )
<Day> ::= ( "0" <NonZeroDigit> ) | ( ("1" | "2") <NonZeroDigit> ) | ("3" ( "0" | "1" ) )
<Year> ::= ( "000" <NonZeroDigit> ) |
( "00" <NonZeroDigit> <NonZeroDigit> ) |
( "0" <NonZeroDigit> <NonZeroDigit> <NonZeroDigit> ) |
( "1" <NonZeroDigit> <NonZeroDigit> <NonZeroDigit>) |
( "20" <NonZeroDigit> <NonZeroDigit> ) )
这一年到 2099 年,我想它还可以,这些规则有效,但是当时有没有更好的方法来编写 EBNF?我错过了什么吗?