BNF 创建具有相同长度的向量
是否可以用 BNF 描述一对相同长度的向量?例如,我想使用这样的语法来捕获有效的点积运算,因为这样的运算需要相同长度的向量。
我可以描述一个向量(我认为这是可以的): [1,2,3]
<vector> ::= "[" <vectorItems> "]"
<vectorItems> ::= <wholeNumber>|<wholeNumber>","<vectorItems>
但是我如何描述以下内容(即向量可以是任意长度但两个向量的长度相同;是这甚至可能吗?我对此有点陌生)?:[1,2,3,4],[5,6,7,8]
Is it possible to describe in BNF a pair of vectors of the same length? For instance, I would like to use such a grammar to capture valid dot product operations as such an operation requires vectors of the same length.
I can describe one vector (I think this is okay): [1,2,3]
<vector> ::= "[" <vectorItems> "]"
<vectorItems> ::= <wholeNumber>|<wholeNumber>","<vectorItems>
But how can I describe the following (that is, the vectors can be of any length but the lengths of the two vectors are the same; Is this even possible? I am kind of new at this)?: [1,2,3,4], [5,6,7,8]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的东西吗?
该语言中的字符串按从小到大的顺序排列,其中 N 代表任意数字:
L = { [N],[N], [N,N],[ N,N], [N,N,N],[N,N,N], ...}
= {aBcDe | a=[ 和 c=],[ 和 e=] 和 B=(N,)^k N 和 D=(N,)^k N
且k> 0)
(端子符号以粗体显示)
Something like this?
The strings in this language are, in order from smallest to largest, where N stands for an arbitrary number:
L = { [N],[N], [N,N],[N,N], [N,N,N],[N,N,N], ...}
= {aBcDe | a=[ and c=],[ and e=] and B=(N,)^k N and D=(N,)^k N
and k > 0)
(terminal symbols shown in bold)