aboutsummaryrefslogtreecommitdiff
path: root/lib/Grammar/Version/Semantic.pm6
blob: aac3b728b7b108a45c87110361648dc8c664bc12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! /usr/bin/env false

use v6.d;

unit grammar Grammar::Version::Semantic;

token TOP {
	[ <major> '.' <minor> '.' <patch> ]
	[ '-' <pre-release> ]?
	[ '+' <build> ]?
}

token pre-release {
	[ \w+ % '.' ]+
}

token build {
	<[ \w - ]>+
}

token major {
	\d+
}

token minor {
	\d+
}

token patch {
	\d+
}

=begin pod

=NAME    Grammar::Version::Semantic
=AUTHOR  Patrick Spek <p.spek@tyil.work>
=VERSION 0.0.0

=head1 Synopsis

=item1 Grammar::Version::Semantic.parse(Str $);

=head1 Description

A grammar for parisng the SemVer spec in the Raku programming language.

=head1 Examples

=begin input
use Grammar::Version::Semantic;
say Grammar::Version::Semantic.parse('2020.01.1-rc2');
=end input

=begin output
「2020.01.1-rc2」
 major => 「2020」
 minor => 「01」
 patch => 「1」
 pre-release => 「rc2」
=end output

=head1 See also

=item1 https://semver.org/
=item1 L<Version::Semantic|https://modules.raku.org/dist/Version::Semantic:cpan:TYIL>

=end pod

# vim: ft=perl6 noet