Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2015-12-11 06:22:07 +0300
committerForrest L Norvell <forrest@npmjs.com>2015-12-11 07:00:04 +0300
commitb835b72d1dd23b0a17321a85d8d395322d18005d (patch)
tree21cd38b3c1717f1936bdbd14b0b135a15205e4b2 /doc
parent95e99faadcdc85a16210dd79c0e7d83add1b9f3e (diff)
semver@5.1.0
Add BNF grammar to documentation. Credit: @isaacs Reviewed-By: @othiym23
Diffstat (limited to 'doc')
-rw-r--r--doc/misc/semver.md26
1 files changed, 25 insertions, 1 deletions
diff --git a/doc/misc/semver.md b/doc/misc/semver.md
index 2bd5acc29..97a50cdf0 100644
--- a/doc/misc/semver.md
+++ b/doc/misc/semver.md
@@ -107,7 +107,7 @@ The method `.inc` takes an additional `identifier` string argument that
will append the value of the string as a prerelease identifier:
```javascript
-> semver.inc('1.2.3', 'pre', 'beta')
+> semver.inc('1.2.3', 'prerelease', 'beta')
'1.2.4-beta.0'
```
@@ -228,6 +228,30 @@ zero.
* `^1.x` := `>=1.0.0 <2.0.0`
* `^0.x` := `>=0.0.0 <1.0.0`
+### Range Grammar
+
+Putting all this together, here is a Backus-Naur grammar for ranges,
+for the benefit of parser authors:
+
+```bnf
+range-set ::= range ( logical-or range ) *
+logical-or ::= ( ' ' ) * '||' ( ' ' ) *
+range ::= hyphen | simple ( ' ' simple ) * | ''
+hyphen ::= partial ' - ' partial
+simple ::= primitive | partial | tilde | caret
+primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | ) partial
+partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
+xr ::= 'x' | 'X' | '*' | nr
+nr ::= '0' | ['1'-'9']['0'-'9']+
+tilde ::= '~' partial
+caret ::= '^' partial
+qualifier ::= ( '-' pre )? ( '+' build )?
+pre ::= parts
+build ::= parts
+parts ::= part ( '.' part ) *
+part ::= nr | [-0-9A-Za-z]+
+```
+
## Functions
All methods and classes take a final `loose` boolean argument that, if