BNF 巴科斯范式

BNF通常用来定义一些表达式。

• The notation “{}” denotes an optional token within the braces; the braces do not appear in the output token list.
• The notation "( )" groups a sequence of tokens into a single token; the parentheses do not appear in theoutput token list.
• The notation "*" after a token denotes the optional use of multiple instances of that token.
• A character string without any modifying symbols denotes an instance of that character string as a single token.
• The notation "|" denotes a choice of two tokens, and do not appear in the output token list,
• The notation "< >" denotes a production defined elsewhere in the list or a basic type.
• The notation ":=" is a production and the grammar on the left may be replaced with the grammar on the right of this symbol. Production is terminated when no undefined production equations are left unresolved.

 

现在,几乎每一位新编程语言书籍的作者都使用巴科斯范式来定义编程语言的语法规则。

  -----------------------------------------------------------------------------

  巴科斯范式的内容

  在双引号中的字("word")代表着这些字符本身。而double_quote用来代表双引号。

  在双引号外的字(有可能有下划线)代表着语法部分。

  尖括号( < > )内包含的为必选项。

  方括号( [ ] )内包含的为可选项。

  大括号( { } )内包含的为可重复0至无数次的项。

  竖线( | )表示在其左右两边任选一项,相当于"OR"的意思。

  ::= 是“被定义为”的意思

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值