I am confused with how to properly read this syntax line.
IdentifierName
is defined with an IdentifierName
?How to read this notation?
Syntax
IdentifierName :: IdentifierStart IdentifierName IdentifierPart
It's a recursive definition, which is not uncommon in grammar notations.
IdentifierName
is composed of IdentifierStart
or IdentifierName IdentifierPart
. If we expand IdentifierName
in the second alternative again we get
IdentifierStart IdentifierPart
IdentifierName IdentifierPart IdentifierPart
and so on.
To express this in an informal way: IdentifierName
is compose of IdentifierStart
followed by an arbitrary number of IdentifierPart
s.
From the specifiction itself:
As another example, the syntactic definition:
ArgumentList: AssignmentExpression ArgumentList,AssignmentExpression
states that an
ArgumentList
may represent either a singleAssignmentExpression
or anArgumentList
, followed by a comma, followed by anAssignmentExpression
. This definition ofArgumentList
is recursive, that is, it is defined in terms of itself. The result is that anArgumentList
may contain any positive number of arguments, separated by commas, where each argument expression is anAssignmentExpression
. Such recursive definitions of nonterminals are common.