Clarification on docs regarding EBNF

47 views
Skip to first unread message

IK

unread,
Dec 12, 2025, 4:32:45 AM (5 days ago) Dec 12
to lua-l
Hi team,

I'm playing around with a toy parser for Lua. While reviewing The Complete Syntax of Lua in the manual: https://www.lua.org/manual/5.4/manual.html#9. I found a suspicious bit that looks as follows:

attnamelist ::= Name attrib {‘,’ Name attrib} 
attrib ::= [‘<’ Name ‘>’]

1. As I understand the attrib is optional, and should therefore be denoted using braces:
attrib ::= {‘<’ Name ‘>’}

2. The attrib symbol is currently referencing the overloaded Name symbol.
As of version v5.4 there exist only 2 possibilities for the attrib value
- const
- close

I believe it would make more sense to declare attrib as
attrib ::= {‘<’ closed | close ‘>’}

Best,
IK


Philippe Verdy

unread,
Dec 12, 2025, 4:41:51 AM (5 days ago) Dec 12
to lu...@googlegroups.com
Rounded braces in EBNF syntax are for optional *unlimited repetitions* of its content (so 0 to n):
  attnamelist ::= Name attrib {‘,’ Name attrib} 

Square brackets in EBNF syntax are for an optional *single* occurences (so 0 to 1). So the following is correct (no braces):
   attrib ::= [‘<’ Name ‘>’]

And it is *currently* the same as the following as the attribute Name is only defined for closed and close (no braces):
   attrib ::= [‘<’ closed | close ‘>’]


--
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lua-l+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lua-l/f2f2fa3b-639c-488a-9f57-1833d55b7e97n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages