14. YANG ABNF语法

YANG中,几乎所有的陈述都是无序的。 ABNF语法[RFC5234] [RFC7405]定义了规范的顺序。 为了提高模块可读性,建议按此顺序输入条款。

ABNF语法中,无序的语句用注释标记。

这个语法假定扫描器用一个空格字符替换YANG的注释。

<CODE BEGINS> file “yang.abnf”

  1. module-stmt = optsep module-keyword sep identifier-arg-str optsep
  2. "{" stmtsep
  3. module-header-stmts
  4. linkage-stmts
  5. meta-stmts
  6. revision-stmts
  7. body-stmts
  8. "}" optsep
  9. submodule-stmt = optsep submodule-keyword sep identifier-arg-str optsep
  10. "{" stmtsep
  11. submodule-header-stmts
  12. linkage-stmts
  13. meta-stmts
  14. revision-stmts
  15. body-stmts
  16. "}" optsep
  17. module-header-stmts = ;; these stmts can appear in any order
  18. yang-version-stmt
  19. namespace-stmt
  20. prefix-stmt
  21. submodule-header-stmts =
  22. ;; these stmts can appear in any order
  23. yang-version-stmt
  24. belongs-to-stmt
  25. meta-stmts = ;; these stmts can appear in any order
  26. [organization-stmt]
  27. [contact-stmt]
  28. [description-stmt]
  29. [reference-stmt]
  30. linkage-stmts = ;; these stmts can appear in any order
  31. *import-stmt
  32. *include-stmt
  33. revision-stmts = *revision-stmt
  34. body-stmts = *(extension-stmt /
  35. feature-stmt /
  36. identity-stmt /
  37. typedef-stmt /
  38. grouping-stmt /
  39. data-def-stmt /
  40. augment-stmt /
  41. rpc-stmt /
  42. notification-stmt /
  43. deviation-stmt)
  44. data-def-stmt = container-stmt /
  45. leaf-stmt /
  46. leaf-list-stmt /
  47. list-stmt /
  48. choice-stmt /
  49. anydata-stmt /
  50. anyxml-stmt /
  51. uses-stmt
  52. yang-version-stmt = yang-version-keyword sep yang-version-arg-str
  53. stmtend
  54. yang-version-arg-str = < a string that matches the rule >
  55. < yang-version-arg >
  56. yang-version-arg = "1.1"
  57. import-stmt = import-keyword sep identifier-arg-str optsep
  58. "{" stmtsep
  59. ;; these stmts can appear in any order
  60. prefix-stmt
  61. [revision-date-stmt]
  62. [description-stmt]
  63. [reference-stmt]
  64. "}" stmtsep
  65. include-stmt = include-keyword sep identifier-arg-str optsep
  66. (";" /
  67. "{" stmtsep
  68. ;; these stmts can appear in any order
  69. [revision-date-stmt]
  70. [description-stmt]
  71. [reference-stmt]
  72. "}") stmtsep
  73. namespace-stmt = namespace-keyword sep uri-str stmtend
  74. uri-str = < a string that matches the rule >
  75. < URI in RFC 3986 >
  76. prefix-stmt = prefix-keyword sep prefix-arg-str stmtend
  77. belongs-to-stmt = belongs-to-keyword sep identifier-arg-str
  78. optsep
  79. "{" stmtsep
  80. prefix-stmt
  81. "}" stmtsep
  82. organization-stmt = organization-keyword sep string stmtend
  83. contact-stmt = contact-keyword sep string stmtend
  84. description-stmt = description-keyword sep string stmtend
  85. reference-stmt = reference-keyword sep string stmtend
  86. units-stmt = units-keyword sep string stmtend
  87. revision-stmt = revision-keyword sep revision-date optsep
  88. (";" /
  89. "{" stmtsep
  90. ;; these stmts can appear in any order
  91. [description-stmt]
  92. [reference-stmt]
  93. "}") stmtsep
  94. revision-date = date-arg-str
  95. revision-date-stmt = revision-date-keyword sep revision-date stmtend
  96. extension-stmt = extension-keyword sep identifier-arg-str optsep
  97. (";" /
  98. "{" stmtsep
  99. ;; these stmts can appear in any order
  100. [argument-stmt]
  101. [status-stmt]
  102. [description-stmt]
  103. [reference-stmt]
  104. "}") stmtsep
  105. argument-stmt = argument-keyword sep identifier-arg-str optsep
  106. (";" /
  107. "{" stmtsep
  108. [yin-element-stmt]
  109. "}") stmtsep
  110. yin-element-stmt = yin-element-keyword sep yin-element-arg-str
  111. stmtend
  112. yin-element-arg-str = < a string that matches the rule >
  113. < yin-element-arg >
  114. yin-element-arg = true-keyword / false-keyword
  115. identity-stmt = identity-keyword sep identifier-arg-str optsep
  116. (";" /
  117. "{" stmtsep
  118. ;; these stmts can appear in any order
  119. *if-feature-stmt
  120. *base-stmt
  121. [status-stmt]
  122. [description-stmt]
  123. [reference-stmt]
  124. "}") stmtsep
  125. base-stmt = base-keyword sep identifier-ref-arg-str
  126. stmtend
  127. feature-stmt = feature-keyword sep identifier-arg-str optsep
  128. (";" /
  129. "{" stmtsep
  130. ;; these stmts can appear in any order
  131. *if-feature-stmt
  132. [status-stmt]
  133. [description-stmt]
  134. [reference-stmt]
  135. "}") stmtsep
  136. if-feature-stmt = if-feature-keyword sep if-feature-expr-str
  137. stmtend
  138. if-feature-expr-str = < a string that matches the rule >
  139. < if-feature-expr >
  140. if-feature-expr = if-feature-term
  141. [sep or-keyword sep if-feature-expr]
  142. if-feature-term = if-feature-factor
  143. [sep and-keyword sep if-feature-term]
  144. if-feature-factor = not-keyword sep if-feature-factor /
  145. "(" optsep if-feature-expr optsep ")" /
  146. identifier-ref-arg
  147. typedef-stmt = typedef-keyword sep identifier-arg-str optsep
  148. "{" stmtsep
  149. ;; these stmts can appear in any order
  150. type-stmt
  151. [units-stmt]
  152. [default-stmt]
  153. [status-stmt]
  154. [description-stmt]
  155. [reference-stmt]
  156. "}" stmtsep
  157. type-stmt = type-keyword sep identifier-ref-arg-str optsep
  158. (";" /
  159. "{" stmtsep
  160. [type-body-stmts]
  161. "}") stmtsep
  162. type-body-stmts = numerical-restrictions /
  163. decimal64-specification /
  164. string-restrictions /
  165. enum-specification /
  166. leafref-specification /
  167. identityref-specification /
  168. instance-identifier-specification /
  169. bits-specification /
  170. union-specification /
  171. binary-specification
  172. numerical-restrictions = [range-stmt]
  173. range-stmt = range-keyword sep range-arg-str optsep
  174. (";" /
  175. "{" stmtsep
  176. ;; these stmts can appear in any order
  177. [error-message-stmt]
  178. [error-app-tag-stmt]
  179. [description-stmt]
  180. [reference-stmt]
  181. "}") stmtsep
  182. decimal64-specification = ;; these stmts can appear in any order
  183. fraction-digits-stmt
  184. [range-stmt]
  185. fraction-digits-stmt = fraction-digits-keyword sep
  186. fraction-digits-arg-str stmtend
  187. fraction-digits-arg-str = < a string that matches the rule >
  188. < fraction-digits-arg >
  189. fraction-digits-arg = ("1" ["0" / "1" / "2" / "3" / "4" /
  190. "5" / "6" / "7" / "8"])
  191. / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9"
  192. string-restrictions = ;; these stmts can appear in any order
  193. [length-stmt]
  194. *pattern-stmt
  195. length-stmt = length-keyword sep length-arg-str optsep
  196. (";" /
  197. "{" stmtsep
  198. ;; these stmts can appear in any order
  199. [error-message-stmt]
  200. [error-app-tag-stmt]
  201. [description-stmt]
  202. [reference-stmt]
  203. "}") stmtsep
  204. pattern-stmt = pattern-keyword sep string optsep
  205. (";" /
  206. "{" stmtsep
  207. ;; these stmts can appear in any order
  208. [modifier-stmt]
  209. [error-message-stmt]
  210. [error-app-tag-stmt]
  211. [description-stmt]
  212. [reference-stmt]
  213. "}") stmtsep
  214. modifier-stmt = modifier-keyword sep modifier-arg-str stmtend
  215. modifier-arg-str = < a string that matches the rule >
  216. < modifier-arg >
  217. modifier-arg = invert-match-keyword
  218. default-stmt = default-keyword sep string stmtend
  219. enum-specification = 1*enum-stmt
  220. enum-stmt = enum-keyword sep string optsep
  221. (";" /
  222. "{" stmtsep
  223. ;; these stmts can appear in any order
  224. *if-feature-stmt
  225. [value-stmt]
  226. [status-stmt]
  227. [description-stmt]
  228. [reference-stmt]
  229. "}") stmtsep
  230. leafref-specification =
  231. ;; these stmts can appear in any order
  232. path-stmt
  233. [require-instance-stmt]
  234. path-stmt = path-keyword sep path-arg-str stmtend
  235. require-instance-stmt = require-instance-keyword sep
  236. require-instance-arg-str stmtend
  237. require-instance-arg-str = < a string that matches the rule >
  238. < require-instance-arg >
  239. require-instance-arg = true-keyword / false-keyword
  240. instance-identifier-specification =
  241. [require-instance-stmt]
  242. identityref-specification =
  243. 1*base-stmt
  244. union-specification = 1*type-stmt
  245. binary-specification = [length-stmt]
  246. bits-specification = 1*bit-stmt
  247. bit-stmt = bit-keyword sep identifier-arg-str optsep
  248. (";" /
  249. "{" stmtsep
  250. ;; these stmts can appear in any order
  251. *if-feature-stmt
  252. [position-stmt]
  253. [status-stmt]
  254. [description-stmt]
  255. [reference-stmt]
  256. "}") stmtsep
  257. position-stmt = position-keyword sep
  258. position-value-arg-str stmtend
  259. position-value-arg-str = < a string that matches the rule >
  260. < position-value-arg >
  261. position-value-arg = non-negative-integer-value
  262. status-stmt = status-keyword sep status-arg-str stmtend
  263. status-arg-str = < a string that matches the rule >
  264. < status-arg >
  265. status-arg = current-keyword /
  266. obsolete-keyword /
  267. deprecated-keyword
  268. config-stmt = config-keyword sep
  269. config-arg-str stmtend
  270. config-arg-str = < a string that matches the rule >
  271. < config-arg >
  272. config-arg = true-keyword / false-keyword
  273. mandatory-stmt = mandatory-keyword sep
  274. mandatory-arg-str stmtend
  275. mandatory-arg-str = < a string that matches the rule >
  276. < mandatory-arg >
  277. mandatory-arg = true-keyword / false-keyword
  278. presence-stmt = presence-keyword sep string stmtend
  279. ordered-by-stmt = ordered-by-keyword sep
  280. ordered-by-arg-str stmtend
  281. ordered-by-arg-str = < a string that matches the rule >
  282. < ordered-by-arg >
  283. ordered-by-arg = user-keyword / system-keyword
  284. must-stmt = must-keyword sep string optsep
  285. (";" /
  286. "{" stmtsep
  287. ;; these stmts can appear in any order
  288. [error-message-stmt]
  289. [error-app-tag-stmt]
  290. [description-stmt]
  291. [reference-stmt]
  292. "}") stmtsep
  293. error-message-stmt = error-message-keyword sep string stmtend
  294. error-app-tag-stmt = error-app-tag-keyword sep string stmtend
  295. min-elements-stmt = min-elements-keyword sep
  296. min-value-arg-str stmtend
  297. min-value-arg-str = < a string that matches the rule >
  298. < min-value-arg >
  299. min-value-arg = non-negative-integer-value
  300. max-elements-stmt = max-elements-keyword sep
  301. max-value-arg-str stmtend
  302. max-value-arg-str = < a string that matches the rule >
  303. < max-value-arg >
  304. max-value-arg = unbounded-keyword /
  305. positive-integer-value
  306. value-stmt = value-keyword sep integer-value-str stmtend
  307. integer-value-str = < a string that matches the rule >
  308. < integer-value >
  309. grouping-stmt = grouping-keyword sep identifier-arg-str optsep
  310. (";" /
  311. "{" stmtsep
  312. ;; these stmts can appear in any order
  313. [status-stmt]
  314. [description-stmt]
  315. [reference-stmt]
  316. *(typedef-stmt / grouping-stmt)
  317. *data-def-stmt
  318. *action-stmt
  319. *notification-stmt
  320. "}") stmtsep
  321. container-stmt = container-keyword sep identifier-arg-str optsep
  322. (";" /
  323. "{" stmtsep
  324. ;; these stmts can appear in any order
  325. [when-stmt]
  326. *if-feature-stmt
  327. *must-stmt
  328. [presence-stmt]
  329. [config-stmt]
  330. [status-stmt]
  331. [description-stmt]
  332. [reference-stmt]
  333. *(typedef-stmt / grouping-stmt)
  334. *data-def-stmt
  335. *action-stmt
  336. *notification-stmt
  337. "}") stmtsep
  338. leaf-stmt = leaf-keyword sep identifier-arg-str optsep
  339. "{" stmtsep
  340. ;; these stmts can appear in any order
  341. [when-stmt]
  342. *if-feature-stmt
  343. type-stmt
  344. [units-stmt]
  345. *must-stmt
  346. [default-stmt]
  347. [config-stmt]
  348. [mandatory-stmt]
  349. [status-stmt]
  350. [description-stmt]
  351. [reference-stmt]
  352. "}" stmtsep
  353. leaf-list-stmt = leaf-list-keyword sep identifier-arg-str optsep
  354. "{" stmtsep
  355. ;; these stmts can appear in any order
  356. [when-stmt]
  357. *if-feature-stmt
  358. type-stmt stmtsep
  359. [units-stmt]
  360. *must-stmt
  361. *default-stmt
  362. [config-stmt]
  363. [min-elements-stmt]
  364. [max-elements-stmt]
  365. [ordered-by-stmt]
  366. [status-stmt]
  367. [description-stmt]
  368. [reference-stmt]
  369. "}" stmtsep
  370. list-stmt = list-keyword sep identifier-arg-str optsep
  371. "{" stmtsep
  372. ;; these stmts can appear in any order
  373. [when-stmt]
  374. *if-feature-stmt
  375. *must-stmt
  376. [key-stmt]
  377. *unique-stmt
  378. [config-stmt]
  379. [min-elements-stmt]
  380. [max-elements-stmt]
  381. [ordered-by-stmt]
  382. [status-stmt]
  383. [description-stmt]
  384. [reference-stmt]
  385. *(typedef-stmt / grouping-stmt)
  386. 1*data-def-stmt
  387. *action-stmt
  388. *notification-stmt
  389. "}" stmtsep
  390. key-stmt = key-keyword sep key-arg-str stmtend
  391. key-arg-str = < a string that matches the rule >
  392. < key-arg >
  393. key-arg = node-identifier *(sep node-identifier)
  394. unique-stmt = unique-keyword sep unique-arg-str stmtend
  395. unique-arg-str = < a string that matches the rule >
  396. < unique-arg >
  397. unique-arg = descendant-schema-nodeid
  398. *(sep descendant-schema-nodeid)
  399. choice-stmt = choice-keyword sep identifier-arg-str optsep
  400. (";" /
  401. "{" stmtsep
  402. ;; these stmts can appear in any order
  403. [when-stmt]
  404. *if-feature-stmt
  405. [default-stmt]
  406. [config-stmt]
  407. [mandatory-stmt]
  408. [status-stmt]
  409. [description-stmt]
  410. [reference-stmt]
  411. *(short-case-stmt / case-stmt)
  412. "}") stmtsep
  413. short-case-stmt = choice-stmt /
  414. container-stmt /
  415. leaf-stmt /
  416. leaf-list-stmt /
  417. list-stmt /
  418. anydata-stmt /
  419. anyxml-stmt
  420. case-stmt = case-keyword sep identifier-arg-str optsep
  421. (";" /
  422. "{" stmtsep
  423. ;; these stmts can appear in any order
  424. [when-stmt]
  425. *if-feature-stmt
  426. [status-stmt]
  427. [description-stmt]
  428. [reference-stmt]
  429. *data-def-stmt
  430. "}") stmtsep
  431. anydata-stmt = anydata-keyword sep identifier-arg-str optsep
  432. (";" /
  433. "{" stmtsep
  434. ;; these stmts can appear in any order
  435. [when-stmt]
  436. *if-feature-stmt
  437. *must-stmt
  438. [config-stmt]
  439. [mandatory-stmt]
  440. [status-stmt]
  441. [description-stmt]
  442. [reference-stmt]
  443. "}") stmtsep
  444. anyxml-stmt = anyxml-keyword sep identifier-arg-str optsep
  445. (";" /
  446. "{" stmtsep
  447. ;; these stmts can appear in any order
  448. [when-stmt]
  449. *if-feature-stmt
  450. *must-stmt
  451. [config-stmt]
  452. [mandatory-stmt]
  453. [status-stmt]
  454. [description-stmt]
  455. [reference-stmt]
  456. "}") stmtsep
  457. uses-stmt = uses-keyword sep identifier-ref-arg-str optsep
  458. (";" /
  459. "{" stmtsep
  460. ;; these stmts can appear in any order
  461. [when-stmt]
  462. *if-feature-stmt
  463. [status-stmt]
  464. [description-stmt]
  465. [reference-stmt]
  466. *refine-stmt
  467. *uses-augment-stmt
  468. "}") stmtsep
  469. refine-stmt = refine-keyword sep refine-arg-str optsep
  470. "{" stmtsep
  471. ;; these stmts can appear in any order
  472. *if-feature-stmt
  473. *must-stmt
  474. [presence-stmt]
  475. *default-stmt
  476. [config-stmt]
  477. [mandatory-stmt]
  478. [min-elements-stmt]
  479. [max-elements-stmt]
  480. [description-stmt]
  481. [reference-stmt]
  482. "}" stmtsep
  483. refine-arg-str = < a string that matches the rule >
  484. < refine-arg >
  485. refine-arg = descendant-schema-nodeid
  486. uses-augment-stmt = augment-keyword sep uses-augment-arg-str optsep
  487. "{" stmtsep
  488. ;; these stmts can appear in any order
  489. [when-stmt]
  490. *if-feature-stmt
  491. [status-stmt]
  492. [description-stmt]
  493. [reference-stmt]
  494. 1*(data-def-stmt / case-stmt /
  495. action-stmt / notification-stmt)
  496. "}" stmtsep
  497. uses-augment-arg-str = < a string that matches the rule >
  498. < uses-augment-arg >
  499. uses-augment-arg = descendant-schema-nodeid
  500. augment-stmt = augment-keyword sep augment-arg-str optsep
  501. "{" stmtsep
  502. ;; these stmts can appear in any order
  503. [when-stmt]
  504. *if-feature-stmt
  505. [status-stmt]
  506. [description-stmt]
  507. [reference-stmt]
  508. 1*(data-def-stmt / case-stmt /
  509. action-stmt / notification-stmt)
  510. "}" stmtsep
  511. augment-arg-str = < a string that matches the rule >
  512. < augment-arg >
  513. augment-arg = absolute-schema-nodeid
  514. when-stmt = when-keyword sep string optsep
  515. (";" /
  516. "{" stmtsep
  517. ;; these stmts can appear in any order
  518. [description-stmt]
  519. [reference-stmt]
  520. "}") stmtsep
  521. rpc-stmt = rpc-keyword sep identifier-arg-str optsep
  522. (";" /
  523. "{" stmtsep
  524. ;; these stmts can appear in any order
  525. *if-feature-stmt
  526. [status-stmt]
  527. [description-stmt]
  528. [reference-stmt]
  529. *(typedef-stmt / grouping-stmt)
  530. [input-stmt]
  531. [output-stmt]
  532. "}") stmtsep
  533. action-stmt = action-keyword sep identifier-arg-str optsep
  534. (";" /
  535. "{" stmtsep
  536. ;; these stmts can appear in any order
  537. *if-feature-stmt
  538. [status-stmt]
  539. [description-stmt]
  540. [reference-stmt]
  541. *(typedef-stmt / grouping-stmt)
  542. [input-stmt]
  543. [output-stmt]
  544. "}") stmtsep
  545. input-stmt = input-keyword optsep
  546. "{" stmtsep
  547. ;; these stmts can appear in any order
  548. *must-stmt
  549. *(typedef-stmt / grouping-stmt)
  550. 1*data-def-stmt
  551. "}" stmtsep
  552. output-stmt = output-keyword optsep
  553. "{" stmtsep
  554. ;; these stmts can appear in any order
  555. *must-stmt
  556. *(typedef-stmt / grouping-stmt)
  557. 1*data-def-stmt
  558. "}" stmtsep
  559. notification-stmt = notification-keyword sep
  560. identifier-arg-str optsep
  561. (";" /
  562. "{" stmtsep
  563. ;; these stmts can appear in any order
  564. *if-feature-stmt
  565. *must-stmt
  566. [status-stmt]
  567. [description-stmt]
  568. [reference-stmt]
  569. *(typedef-stmt / grouping-stmt)
  570. *data-def-stmt
  571. "}") stmtsep
  572. deviation-stmt = deviation-keyword sep
  573. deviation-arg-str optsep
  574. "{" stmtsep
  575. ;; these stmts can appear in any order
  576. [description-stmt]
  577. [reference-stmt]
  578. (deviate-not-supported-stmt /
  579. 1*(deviate-add-stmt /
  580. deviate-replace-stmt /
  581. deviate-delete-stmt))
  582. "}" stmtsep
  583. deviation-arg-str = < a string that matches the rule >
  584. < deviation-arg >
  585. deviation-arg = absolute-schema-nodeid
  586. deviate-not-supported-stmt =
  587. deviate-keyword sep
  588. not-supported-keyword-str stmtend
  589. deviate-add-stmt = deviate-keyword sep add-keyword-str optsep
  590. (";" /
  591. "{" stmtsep
  592. ;; these stmts can appear in any order
  593. [units-stmt]
  594. *must-stmt
  595. *unique-stmt
  596. *default-stmt
  597. [config-stmt]
  598. [mandatory-stmt]
  599. [min-elements-stmt]
  600. [max-elements-stmt]
  601. "}") stmtsep
  602. deviate-delete-stmt = deviate-keyword sep delete-keyword-str optsep
  603. (";" /
  604. "{" stmtsep
  605. ;; these stmts can appear in any order
  606. [units-stmt]
  607. *must-stmt
  608. *unique-stmt
  609. *default-stmt
  610. "}") stmtsep
  611. deviate-replace-stmt = deviate-keyword sep replace-keyword-str optsep
  612. (";" /
  613. "{" stmtsep
  614. ;; these stmts can appear in any order
  615. [type-stmt]
  616. [units-stmt]
  617. [default-stmt]
  618. [config-stmt]
  619. [mandatory-stmt]
  620. [min-elements-stmt]
  621. [max-elements-stmt]
  622. "}") stmtsep
  623. not-supported-keyword-str = < a string that matches the rule >
  624. < not-supported-keyword >
  625. add-keyword-str = < a string that matches the rule >
  626. < add-keyword >
  627. delete-keyword-str = < a string that matches the rule >
  628. < delete-keyword >
  629. replace-keyword-str = < a string that matches the rule >
  630. < replace-keyword >
  631. ;; represents the usage of an extension
  632. unknown-statement = prefix ":" identifier [sep string] optsep
  633. (";" /
  634. "{" optsep
  635. *((yang-stmt / unknown-statement) optsep)
  636. "}") stmtsep
  637. yang-stmt = action-stmt /
  638. anydata-stmt /
  639. anyxml-stmt /
  640. argument-stmt /
  641. augment-stmt /
  642. base-stmt /
  643. belongs-to-stmt /
  644. bit-stmt /
  645. case-stmt /
  646. choice-stmt /
  647. config-stmt /
  648. contact-stmt /
  649. container-stmt /
  650. default-stmt /
  651. description-stmt /
  652. deviate-add-stmt /
  653. deviate-delete-stmt /
  654. deviate-not-supported-stmt /
  655. deviate-replace-stmt /
  656. deviation-stmt /
  657. enum-stmt /
  658. error-app-tag-stmt /
  659. error-message-stmt /
  660. extension-stmt /
  661. feature-stmt /
  662. fraction-digits-stmt /
  663. grouping-stmt /
  664. identity-stmt /
  665. if-feature-stmt /
  666. import-stmt /
  667. include-stmt /
  668. input-stmt /
  669. key-stmt /
  670. leaf-list-stmt /
  671. leaf-stmt /
  672. length-stmt /
  673. list-stmt /
  674. mandatory-stmt /
  675. max-elements-stmt /
  676. min-elements-stmt /
  677. modifier-stmt /
  678. module-stmt /
  679. must-stmt /
  680. namespace-stmt /
  681. notification-stmt /
  682. ordered-by-stmt /
  683. organization-stmt /
  684. output-stmt /
  685. path-stmt /
  686. pattern-stmt /
  687. position-stmt /
  688. prefix-stmt /
  689. presence-stmt /
  690. range-stmt /
  691. reference-stmt /
  692. refine-stmt /
  693. require-instance-stmt /
  694. revision-date-stmt /
  695. revision-stmt /
  696. rpc-stmt /
  697. status-stmt /
  698. submodule-stmt /
  699. typedef-stmt /
  700. type-stmt /
  701. unique-stmt /
  702. units-stmt /
  703. uses-augment-stmt /
  704. uses-stmt /
  705. value-stmt /
  706. when-stmt /
  707. yang-version-stmt /
  708. yin-element-stmt
  709. ;; Ranges
  710. range-arg-str = < a string that matches the rule >
  711. < range-arg >
  712. range-arg = range-part *(optsep "|" optsep range-part)
  713. range-part = range-boundary
  714. [optsep ".." optsep range-boundary]
  715. range-boundary = min-keyword / max-keyword /
  716. integer-value / decimal-value
  717. ;; Lengths
  718. length-arg-str = < a string that matches the rule >
  719. < length-arg >
  720. length-arg = length-part *(optsep "|" optsep length-part)
  721. length-part = length-boundary
  722. [optsep ".." optsep length-boundary]
  723. length-boundary = min-keyword / max-keyword /
  724. non-negative-integer-value
  725. ;; Date
  726. date-arg-str = < a string that matches the rule >
  727. < date-arg >
  728. date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT
  729. ;; Schema Node Identifiers
  730. schema-nodeid = absolute-schema-nodeid /
  731. descendant-schema-nodeid
  732. absolute-schema-nodeid = 1*("/" node-identifier)
  733. descendant-schema-nodeid =
  734. node-identifier
  735. [absolute-schema-nodeid]
  736. node-identifier = [prefix ":"] identifier
  737. ;; Instance Identifiers
  738. instance-identifier = 1*("/" (node-identifier
  739. [1*key-predicate /
  740. leaf-list-predicate /
  741. pos]))
  742. key-predicate = "[" *WSP key-predicate-expr *WSP "]"
  743. key-predicate-expr = node-identifier *WSP "=" *WSP quoted-string
  744. leaf-list-predicate = "[" *WSP leaf-list-predicate-expr *WSP "]"
  745. leaf-list-predicate-expr = "." *WSP "=" *WSP quoted-string
  746. pos = "[" *WSP positive-integer-value *WSP "]"
  747. quoted-string = (DQUOTE string DQUOTE) / (SQUOTE string SQUOTE)
  748. ;; leafref path
  749. path-arg-str = < a string that matches the rule >
  750. < path-arg >
  751. path-arg = absolute-path / relative-path
  752. absolute-path = 1*("/" (node-identifier *path-predicate))
  753. relative-path = 1*("../") descendant-path
  754. descendant-path = node-identifier
  755. [*path-predicate absolute-path]
  756. path-predicate = "[" *WSP path-equality-expr *WSP "]"
  757. path-equality-expr = node-identifier *WSP "=" *WSP path-key-expr
  758. path-key-expr = current-function-invocation *WSP "/" *WSP
  759. rel-path-keyexpr
  760. rel-path-keyexpr = 1*(".." *WSP "/" *WSP)
  761. *(node-identifier *WSP "/" *WSP)
  762. node-identifier
  763. ;;; Keywords, using the syntax for case-sensitive strings (RFC 7405)
  764. ;; statement keywords
  765. action-keyword = %s"action"
  766. anydata-keyword = %s"anydata"
  767. anyxml-keyword = %s"anyxml"
  768. argument-keyword = %s"argument"
  769. augment-keyword = %s"augment"
  770. base-keyword = %s"base"
  771. belongs-to-keyword = %s"belongs-to"
  772. bit-keyword = %s"bit"
  773. case-keyword = %s"case"
  774. choice-keyword = %s"choice"
  775. config-keyword = %s"config"
  776. contact-keyword = %s"contact"
  777. container-keyword = %s"container"
  778. default-keyword = %s"default"
  779. description-keyword = %s"description"
  780. deviate-keyword = %s"deviate"
  781. deviation-keyword = %s"deviation"
  782. enum-keyword = %s"enum"
  783. error-app-tag-keyword = %s"error-app-tag"
  784. error-message-keyword = %s"error-message"
  785. extension-keyword = %s"extension"
  786. feature-keyword = %s"feature"
  787. fraction-digits-keyword = %s"fraction-digits"
  788. grouping-keyword = %s"grouping"
  789. identity-keyword = %s"identity"
  790. if-feature-keyword = %s"if-feature"
  791. import-keyword = %s"import"
  792. include-keyword = %s"include"
  793. input-keyword = %s"input"
  794. key-keyword = %s"key"
  795. leaf-keyword = %s"leaf"
  796. leaf-list-keyword = %s"leaf-list"
  797. length-keyword = %s"length"
  798. list-keyword = %s"list"
  799. mandatory-keyword = %s"mandatory"
  800. max-elements-keyword = %s"max-elements"
  801. min-elements-keyword = %s"min-elements"
  802. modifier-keyword = %s"modifier"
  803. module-keyword = %s"module"
  804. must-keyword = %s"must"
  805. namespace-keyword = %s"namespace"
  806. notification-keyword = %s"notification"
  807. ordered-by-keyword = %s"ordered-by"
  808. organization-keyword = %s"organization"
  809. output-keyword = %s"output"
  810. path-keyword = %s"path"
  811. pattern-keyword = %s"pattern"
  812. position-keyword = %s"position"
  813. prefix-keyword = %s"prefix"
  814. presence-keyword = %s"presence"
  815. range-keyword = %s"range"
  816. reference-keyword = %s"reference"
  817. refine-keyword = %s"refine"
  818. require-instance-keyword = %s"require-instance"
  819. revision-keyword = %s"revision"
  820. revision-date-keyword = %s"revision-date"
  821. rpc-keyword = %s"rpc"
  822. status-keyword = %s"status"
  823. submodule-keyword = %s"submodule"
  824. type-keyword = %s"type"
  825. typedef-keyword = %s"typedef"
  826. unique-keyword = %s"unique"
  827. units-keyword = %s"units"
  828. uses-keyword = %s"uses"
  829. value-keyword = %s"value"
  830. when-keyword = %s"when"
  831. yang-version-keyword = %s"yang-version"
  832. yin-element-keyword = %s"yin-element"
  833. ;; other keywords
  834. add-keyword = %s"add"
  835. current-keyword = %s"current"
  836. delete-keyword = %s"delete"
  837. deprecated-keyword = %s"deprecated"
  838. false-keyword = %s"false"
  839. invert-match-keyword = %s"invert-match"
  840. max-keyword = %s"max"
  841. min-keyword = %s"min"
  842. not-supported-keyword = %s"not-supported"
  843. obsolete-keyword = %s"obsolete"
  844. replace-keyword = %s"replace"
  845. system-keyword = %s"system"
  846. true-keyword = %s"true"
  847. unbounded-keyword = %s"unbounded"
  848. user-keyword = %s"user"
  849. and-keyword = %s"and"
  850. or-keyword = %s"or"
  851. not-keyword = %s"not"
  852. current-function-invocation = current-keyword *WSP "(" *WSP ")"
  853. ;;; Basic Rules
  854. prefix-arg-str = < a string that matches the rule >
  855. < prefix-arg >
  856. prefix-arg = prefix
  857. prefix = identifier
  858. identifier-arg-str = < a string that matches the rule >
  859. < identifier-arg >
  860. identifier-arg = identifier
  861. identifier = (ALPHA / "_")
  862. *(ALPHA / DIGIT / "_" / "-" / ".")
  863. identifier-ref-arg-str = < a string that matches the rule >
  864. < identifier-ref-arg >
  865. identifier-ref-arg = identifier-ref
  866. identifier-ref = [prefix ":"] identifier
  867. string = < an unquoted string, as returned by >
  868. < the scanner, that matches the rule >
  869. < yang-string >
  870. yang-string = *yang-char
  871. ;; any Unicode or ISO/IEC 10646 character, including tab, carriage
  872. ;; return, and line feed but excluding the other C0 control
  873. ;; characters, the surrogate blocks, and the noncharacters
  874. yang-char = %x09 / %x0A / %x0D / %x20-D7FF /
  875. ; exclude surrogate blocks %xD800-DFFF
  876. %xE000-FDCF / ; exclude noncharacters %xFDD0-FDEF
  877. %xFDF0-FFFD / ; exclude noncharacters %xFFFE-FFFF
  878. %x10000-1FFFD / ; exclude noncharacters %x1FFFE-1FFFF
  879. %x20000-2FFFD / ; exclude noncharacters %x2FFFE-2FFFF
  880. %x30000-3FFFD / ; exclude noncharacters %x3FFFE-3FFFF
  881. %x40000-4FFFD / ; exclude noncharacters %x4FFFE-4FFFF
  882. %x50000-5FFFD / ; exclude noncharacters %x5FFFE-5FFFF
  883. %x60000-6FFFD / ; exclude noncharacters %x6FFFE-6FFFF
  884. %x70000-7FFFD / ; exclude noncharacters %x7FFFE-7FFFF
  885. %x80000-8FFFD / ; exclude noncharacters %x8FFFE-8FFFF
  886. %x90000-9FFFD / ; exclude noncharacters %x9FFFE-9FFFF
  887. %xA0000-AFFFD / ; exclude noncharacters %xAFFFE-AFFFF
  888. %xB0000-BFFFD / ; exclude noncharacters %xBFFFE-BFFFF
  889. %xC0000-CFFFD / ; exclude noncharacters %xCFFFE-CFFFF
  890. %xD0000-DFFFD / ; exclude noncharacters %xDFFFE-DFFFF
  891. %xE0000-EFFFD / ; exclude noncharacters %xEFFFE-EFFFF
  892. %xF0000-FFFFD / ; exclude noncharacters %xFFFFE-FFFFF
  893. %x100000-10FFFD ; exclude noncharacters %x10FFFE-10FFFF
  894. integer-value = ("-" non-negative-integer-value) /
  895. non-negative-integer-value
  896. non-negative-integer-value = "0" / positive-integer-value
  897. positive-integer-value = (non-zero-digit *DIGIT)
  898. zero-integer-value = 1*DIGIT
  899. stmtend = optsep (";" / "{" stmtsep "}") stmtsep
  900. sep = 1*(WSP / line-break)
  901. ; unconditional separator
  902. optsep = *(WSP / line-break)
  903. stmtsep = *(WSP / line-break / unknown-statement)
  904. line-break = CRLF / LF
  905. non-zero-digit = %x31-39
  906. decimal-value = integer-value ("." zero-integer-value)
  907. SQUOTE = %x27
  908. ; single quote
  909. ;;; core rules from RFC 5234
  910. ALPHA = %x41-5A / %x61-7A
  911. ; A-Z / a-z
  912. CR = %x0D
  913. ; carriage return
  914. CRLF = CR LF
  915. ; Internet standard newline
  916. DIGIT = %x30-39
  917. ; 0-9
  918. DQUOTE = %x22
  919. ; double quote
  920. HTAB = %x09
  921. ; horizontal tab
  922. LF = %x0A
  923. ; line feed
  924. SP = %x20
  925. ; space
  926. WSP = SP / HTAB
  927. ; whitespace

<CODE ENDS>