|
下表使用 <> (角括号) 注明用户使用“合法值”列中显示的值所定义的可能语法。
|
构建受支持单位字符串的语法
|
|
语法
|
合法值
|
<compound_unit>
|
• <known_compound_unit>
• <unknown_compound_unit>
• (<compound_unit>)
• <compound_unit><integer_power>
• <compound_unit><operation><compound_unit>
|
<integer_power>
|
• ** int
• ^ int
|
<real_power>
|
• ** real
^ real
|
<operation>
|
• *
• /
|
<pure_unit>
|
• 纯单位表中的任意符号
|
<base_unit>
|
• 基本单位表中的任意符号
|
<unit_prefix>
|
• 单位前缀表中的任意符号
|
<known_unit>
|
• <pure_unit>
• <unit_prefix><pure_unit>
|
<known_compound_unit>
|
• <known_unit>
• (<known_compound_unit>)
• <known_compound_unit><integer_power>
• <known_compound_unit><operation><known_compound_unit>
|
<unknown_unit>
|
• 不是 <known_unit> 的任意符号
|
<unknown_compound_unit>
|
• <unknown_unit>
• <known_compound_unit><real_power>
• <unknown_compound_unit><real_power>
|
<base_compound_unit>
|
• <base_unit>
• <base_unit><integer_power> (其中 base_unit 指数大于 0,integer_power 大于 0)
• <base_compound_unit><operation><base_unit> (其中 base_unit 指数大于 base_compound_unit 中的所有 base_unit 指数)
|
运算符
|
说明
|
优先级
|
()
|
括号
|
1
|
**
|
乘方
|
2
|
^
|
乘方
|
2
|
*
|
乘
|
3
|
/
|
除
|
3
|
受支持的单位字符串示例
|
||
受支持的单位字符串:
|
示例:
|
定义
|
基本单位字符串:
|
• kg*m/s**2
• cd/m**2
|
基本单位字符串是指所有 <base_compound_unit> 字符串。
所有基本单位字符串均为可转换单位字符串。
|
可转换单位字符串:
|
• kg*m/s**2
• A**2/kg/m**2*s**4
• 1/ um
• oz/s
• ( N*m )**-3
|
可转换单位字符串是指所有 <known_compound_unit> 字符串。
|
不可转换单位字符串:
|
• foo
• foo**1.4
• W**0.5
|
不可转换单位字符串是指所有 <unknown_compound_unit> 字符串。
可转换单位字符串集与不可转换单位字符串集没有交集。
|