Skip to content

Commit 12aa5df

Browse files
authored
docs(spec): allow optional numeric suffix in Name grammar (#7396)
Update the Plutus Core specification to reflect that names can include an optional numeric suffix after a dash, consisting of one or more digits. This resolves the discrepancy between the specification and the parser implementation, which already supports patterns like name-42 for representing unique name indexes. The grammar now permits names such as x-0, name-42, and variable-12345, enabling disambiguation of variables that share the same base name. This change is purely documentation-focused and does not affect any implementation code.
1 parent 8444bd0 commit 12aa5df

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

doc/plutus-core-spec/untyped-grammar.tex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ \subsection{Lexical grammar}
1616
\centering
1717
\[\begin{array}{lrclr}
1818
19-
\textrm{Name} & n & ::= & \texttt{[a-zA-Z][a-zA-Z0-9\_\textquotesingle]\textsuperscript{*}} & \textrm{name}\\
19+
\textrm{Name} & n & ::= & \texttt{[a-zA-Z][a-zA-Z0-9\_\textquotesingle]\textsuperscript{*}(-[0-9]\textsuperscript{+})?} & \textrm{name}\\
2020
2121
\textrm{Var} & x & ::= & n & \textrm{term variable}\\
2222
\textrm{BuiltinName} & bn & ::= & n & \textrm{built-in function name}\\
@@ -172,6 +172,13 @@ \subsection{Notes}
172172
\texttt{(lam 0 $M$)}; other variables (ie, those not appearing immediately after
173173
a \texttt{lam} binder) are represented by natural number greater than zero.
174174

175+
\paragraph{Name suffixes.}
176+
Names may include an optional numeric suffix consisting of a dash followed by
177+
one or more digits (for example, \texttt{x-0}, \texttt{name-42}, or
178+
\texttt{variable-12345}). This suffix provides a mechanism for disambiguating
179+
variables that share the same base name, allowing multiple distinct variables
180+
with identical textual representations to coexist within a program.
181+
175182
\paragraph{Lists in constructor and case terms.}
176183
The grammar defines constructor and case terms to have a variable number of
177184
subterms written in sequence with no delimiters. This corresponds to the
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Changed
2+
3+
- Updated the Plutus Core specification to allow names with optional numeric suffixes (e.g., `name-42`) in #7396, resolving the discrepancy between the formal grammar and the parser implementation.

0 commit comments

Comments
 (0)