我曾尝试阅读 SLS,但它有一些奇怪的类似 BNF 的符号。任何人都可以澄清这个符号。例如“类型”一章有以下内容:
Type ::= FunctionArgTypes ‘=>’ Type
| InfixType [ExistentialClause]
FunctionArgTypes ::= InfixType
| ‘(’ [ ParamType {‘,’ ParamType } ] ‘)’
ExistentialClause ::= ‘forSome’ ‘{’ ExistentialDcl {semi ExistentialDcl} ‘}’
ExistentialDcl ::= ‘type’ TypeDcl
| ‘val’ ValDcl
InfixType ::= CompoundType {id [nl] CompoundType}
CompoundType ::= AnnotType {‘with’ AnnotType} [Refinement]
| Refinement
AnnotType ::= SimpleType {Annotation}
SimpleType ::= SimpleType TypeArgs
| SimpleType ‘#’ id | StableId
| Path ‘.’ ‘type’
| ‘(’ Types ’)’
TypeArgs ::= ‘[’ Types ‘]’
Types ::= Type {‘,’ Type}
::=
和之类的符号对我来说很清楚,但是和|
之间有什么区别。我也找不到诸如, , ,之类的描述。[]
{}
id
[nl]
Refinment
Type