A. BNF notation for syntax

本文详细介绍了增强型巴科斯范式(ABNF)语法的基本概念和使用规则,包括命名规则、选择项、局部选择项、重复规则等,并针对HTTP数据格式进行了解析。
A. BNF notation for syntax
https://www.w3.org/Notation.html
1. RULE NAMING--命名规则
SPACE, TAB, CRLF, DIGIT, ALPHA, etc.--这些通用基本规则用的大写
"<" and ">" --表示字段中是 < and > 
 <name> --必选项尖括号不使用,直接用name,用尖括号只是更明显,

2. RULE1 / RULE2: ALTERNATIVES --二选一
RULE1 | RULE2  -- RULE1和RULE2二选一

3. (RULE1 RULE2): LOCAL ALTERNATIVES--局部可选项
(elem (foo | bar) elem)--得到的是(elem foo elem)|(elem bar elem)二选一

4. *RULE: REPETITION--规则重复
*RULE--表示0个或者无穷个RULE== ""|RULE|(RULE RULE)|3*RULE
1*RULE--表示至少一个RULE== RULE|(RULE RULE)|3*RULE
1*2RULE--标识至少一个之多两个RULE==RULE|(RULE RULE)

5. [RULE]: OPTIONAL--可选项
[option]--表示1个或多个option ==1*option

6. NRULE: SPECIFIC REPETITION--规则重复次数
nRULE--规定重复次数n
3option--这里option option option ==3*3option

7. #RULE: LISTS--规则重复 逗号间隔
#RULE--表示0个或者无穷个RULE,逗号间隔
1#RULE--表示至少一个RULE,逗号间隔== RULE|(RULE "," RULE)|3#RULE==RULE *(","RULE)
1#2RULE--标识至少一个之多两个RULE,逗号间隔==RULE|(RULE"," RULE)==RULE *1(","RULE)

8. ; COMMENTS--注释
;单行注释。类似C语的//

修改补充:
1)规则定义(编译原理)
   NonTerminal ::= RuleOfTerminalsAndNonTerminals
   非终结符::=终结符和非终结符规则
2)路径中大量使用斜线/所以二选一用竖线|
3)有时候需要特地布局,Cstring字符串中使用
  \n换行符newline
  \r回车键carriage—return
  \t分隔符tab
  \b空格backspace
  \f换页 
  http://www.360doc.com/content/11/1029/16/5482098_160101381.shtml

通用规则

HTTP data are written in line format, ie. line breaks are significant.
http数据写成一行,在
Line breaks--换行规则
  CrLf ::= \r\n
Strings输出字符串中用到引号要用转义\"(反斜杠和英文下的引号)也可以用反斜杠和八进制的对应ascii码(八进制0开始)

Notation

A. BNF notation for syntax

This section has three parts:
(a) a straight copy of a section of RFC #822	Standard for ARPA Internet Text Messages, August 13, 1982,

(b) changes and additions to (a),

(c) a set of rules that we use everywhere and that are listed here once.

(a) NOTATIONAL CONVENTIONS

This specification uses an augmented Backus-Naur Form (BNF) notation. The differences from standard BNF involve naming rules and indicating repetition and "local" alternatives.
1. RULE NAMING

Angle brackets
				"<" and ">"
are not used, in general. The name of a rule is simply the name itself, rather than
				<name>
Quotation-marks enclose literal text (which may be upper and/or lower case). Certain basic rules are in uppercase, such as SPACE, TAB, CRLF, DIGIT, ALPHA, etc. Angle brackets are used in rule definitions, and in the rest of this document, whenever their presence will facilitate discerning the use of rule names.(Note for WWW: we never use them)
2. RULE1 / RULE2: ALTERNATIVES

Elements separated by slash ("/") are alternatives. Therefore "foo / bar" will accept foo or bar. NOTE: this rule is changed to use the vertical bar character "|" instead of slash, since the syntax for directory paths uses slashes heavily.
3. (RULE1 RULE2): LOCAL ALTERNATIVES

Elements enclosed in parentheses are treated as a single element. Thus, "(elem (foo | bar) elem)" allows the token sequences "elem foo elem" and "elem bar elem".
4. *RULE: REPETITION

The character "*" preceding an element indicates repetition. The full form is:
 		<l>*<m>element

indicating at least l and at most m occurrences of element. Default values are 0 and infinity so that "*(element)" allows any number, including zero; "1*element" requires at least one; and "1*2element" allows one or two.
5. [RULE]: OPTIONAL

Square brackets enclose optional elements; "[foo bar]" is equivalent to "*1(foo bar)".
6. NRULE: SPECIFIC REPETITION

		"<n>(element)" 
is equivalent to
		"<n>*<n>(element)"
that is, exactly n occurrences of (element). Thus 2DIGIT is a 2-digit number, and 3ALPHA is a string of three alphabetic characters.
7. #RULE: LISTS

A construct "#" is defined, similar to "*", as follows:
 		<l>#<m>element

indicating at least l and at most m elements, each separated by one or more commas (","). This makes the usual form of lists very easy; a rule such as '(element *("," element))' can be shown as "1#element". Wherever this construct is used, null elements are allowed, but do not contribute to the count of elements present. That is, "(element),,(element)" is permitted, but counts as only two elements. Therefore, where at least one element is required, at least one non-null element must be present. Default values are 0 and infinity so that "#(element)" allows any number, including zero; "1#element" requires at least one; and "1#2element" allows one or two.
8. ; COMMENTS

A semi-colon, set off some distance to the right of rule text, starts a comment that continues to the end of line. This is a simple way of including useful notes in parallel with the specifications.
(b) Changes and additions

2) a rule is written as
		NonTerminal ::= RuleOfTerminalsAndNonTerminals

3) because the slash is heavily used in directory path names, the alternatives are separated by a vertical bar "|" rather than a slash.
4) sometimes it is necessary to specify a layout character sequence, such as newline. We have here adopted the conventions used in C strings:

		\n	newline
		\r	carriage-return
		\t	tab
		\b	backspace
		\f	form feed

(c) General rules

HTTP data are written in line format, ie. line breaks are significant.
Line breaks

		CrLf ::= \r\n
Strings:

The purpose of a string is to allow any sequence of printable characters and the space to be transmitted. A string is a sequence of ASCII characters, written using C's notation for strings. Thus, a string is surrounded by double-quote characters and excludes control characters.
If a double-quote character is used inside a string, it must appear as the sequence \" (backslash followed by double quote).

A control character can be represented by a backslash followed by its ASCII sequence number in octal notation.

The NUL is not representable.

内容概要:本文系统介绍了算术优化算法(AOA)的基本原理、核心思想及Python实现方法,并通过图像分割的实际案例展示了其应用价值。AOA是一种基于种群的元启发式算法,其核心思想来源于四则运算,利用乘除运算进行全局勘探,加减运算进行局部开发,通过数学优化器加速函数(MOA)和数学优化概率(MOP)动态控制搜索过程,在全局探索与局部开发之间实现平衡。文章详细解析了算法的初始化、勘探与开发阶段的更新策略,并提供了完整的Python代码实现,结合Rastrigin函数进行测试验证。进一步地,以Flask框架搭建前后端分离系统,将AOA应用于图像分割任务,展示了其在实际工程中的可行性与高效性。最后,通过收敛速度、寻优精度等指标评估算法性能,并提出自适应参数调整、模型优化和并行计算等改进策略。; 适合人群:具备一定Python编程基础和优化算法基础知识的高校学生、科研人员及工程技术人员,尤其适合从事人工智能、图像处理、智能优化等领域的从业者;; 使用场景及目标:①理解元启发式算法的设计思想与实现机制;②掌握AOA在函数优化、图像分割等实际问题中的建模与求解方法;③学习如何将优化算法集成到Web系统中实现工程化应用;④为算法性能评估与改进提供实践参考; 阅读建议:建议读者结合代码逐行调试,深入理解算法流程中MOA与MOP的作用机制,尝试在不同测试函数上运行算法以观察性能差异,并可进一步扩展图像分割模块,引入更复杂的预处理或后处理技术以提升分割效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值