Skip to content

Commit c47458f

Browse files
Rework and rename package
1 parent 1688943 commit c47458f

File tree

7 files changed

+474
-12
lines changed

7 files changed

+474
-12
lines changed

.spi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
version: 1
22
builder:
33
configs:
4-
- documentation_targets: [LightTableParser]
4+
- documentation_targets: [CollectionParser]

Package.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
// swift-tools-version: 5.10
1+
// swift-tools-version: 6.0
22
import PackageDescription
33

44
let package = Package(
5-
name: "LightTableParser",
5+
name: "swift-collection-parser",
66
products: [
77
.library(
8-
name: "LightTableParser",
9-
targets: ["LightTableParser"]),
8+
name: "CollectionParser",
9+
targets: ["CollectionParser"]),
1010
],
1111
targets: [
1212
.target(
13-
name: "LightTableParser"),
13+
name: "CollectionParser"),
1414
.testTarget(
15-
name: "LightTableParserTests",
16-
dependencies: ["LightTableParser"]),
15+
name: "CollectionParserTests",
16+
dependencies: ["CollectionParser"]),
1717
]
1818
)

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# LightTableParser
1+
# Swift Collection Parser
22

3-
A Swift package for a type `Parser<Subject: Collection>`.
3+
Swift Collection Parser is a package for a type `Parser<Subject: Collection>`.
44

55
## Description
66

@@ -9,11 +9,11 @@ The `Parser` type provides a simple parser that can be used to parse arbitrary c
99
```swift
1010
var parser = Parser(subject: data)
1111

12-
guard let version = parser.read() else {
12+
guard let version = parser.pop() else {
1313
throw DecodingError.missingVersion
1414
}
1515
guard let string = String(bytes: parser.read(while: { $0 != 0 }), encoding: .utf8),
16-
parser.read() == 0 else {
16+
parser.pop(0) else {
1717
throw DecodingError.invalidStringValue
1818
}
1919
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# ``CollectionParser``
2+
3+
A simple parser that can be used to parse arbitrary collections.
4+
5+
## Overview
6+
7+
The parser takes a collection as its subject and operates on the elements and subsequences of this subject.
8+
There are general methods for processing any type of element, but there are also specialized methods for working with strings and regular expressions.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# ``Parser``
2+
3+
## Topics
4+
5+
### Creating Parsers
6+
7+
- ``Parser/init(subject:)``
8+
- ``Parser/init(subject:position:)``
9+
10+
### Parser State
11+
12+
The position is the only mutable state of the parser.
13+
14+
- ``Parser/subject``
15+
- ``Parser/position``
16+
17+
### Remaining Subject
18+
19+
- ``Parser/remainder()``
20+
- ``Parser/isAtEnd``
21+
22+
### Peeking Ahead
23+
24+
Look ahead by peeking at the next elements without advancing the parser.
25+
26+
- ``Parser/peek()-1zib3``
27+
- ``Parser/peek()-2q40y``
28+
- ``Parser/peek()-76suw``
29+
30+
### Remainder Prefix
31+
32+
Look ahead by matching the prefix of the remainder without advancing the parser.
33+
34+
- ``Parser/hasPrefix(_:)-5sp1u``
35+
- ``Parser/hasPrefix(_:)-71nio``
36+
- ``Parser/hasPrefix(_:)-6dwmk``
37+
- ``Parser/hasPrefix(_:)-215bz``
38+
39+
### Reading Elements
40+
41+
Read the current element, advancing the parser on success.
42+
43+
- ``Parser/pop()``
44+
- ``Parser/pop(_:)``
45+
- ``Parser/pop(where:)``
46+
47+
### Reading Subsequences
48+
49+
Read elements, advancing the parser on success.
50+
51+
- ``Parser/read(_:)-35dei``
52+
- ``Parser/read(_:)-2o7et``
53+
- ``Parser/read(count:)``
54+
- ``Parser/read(while:)``
55+
- ``Parser/read(_:)-23mio``
56+
57+
### Advancing the Parser
58+
59+
Advance the parser position without reading elements.
60+
61+
- ``Parser/advance()``
62+
- ``Parser/advance(by:)``
63+
- ``Parser/advance(while:)-22vnw``
64+
- ``Parser/advance(while:)-414fk``
65+
- ``Parser/advance(matching:)``
66+
67+
### Views
68+
69+
Work with different views of the subject.
70+
71+
- ``Parser/withView(_:_:)``

0 commit comments

Comments
 (0)