-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,46 @@ | ||
private enum CharRefState { | ||
case begin | ||
case octothorpe | ||
case numeric(base: UInt32) | ||
case numericSemicolon | ||
case named | ||
case bogusName | ||
} | ||
|
||
struct CharRef { | ||
var chars: (Character, Character) | ||
var num: UInt8 | ||
} | ||
|
||
enum CharRefStatus: ~Copyable { | ||
case stuck | ||
case progress | ||
case done(CharRef) | ||
} | ||
|
||
struct CharRefTokenizer { | ||
mutating func tokenize(_ input: inout String.Iterator) {} | ||
private var state: CharRefState | ||
private var result: Optional<CharRef> | ||
|
||
init() { | ||
self.state = .begin | ||
self.result = nil | ||
} | ||
|
||
mutating func step(tokenizer: inout Tokenizer<some TokenSink>, input: inout String.Iterator) -> CharRefStatus { | ||
if let result = self.result { return .done(result) } | ||
|
||
return switch self.state { | ||
case .begin: self.doBegin(tokenizer: &tokenizer, input: &input) | ||
case .octothorpe: fatalError("not implemented") | ||
case .numeric(_): fatalError("not implemented") | ||
case .numericSemicolon: fatalError("not implemented") | ||
case .named: fatalError("not implemented") | ||
case .bogusName: fatalError("not implemented") | ||
} | ||
} | ||
|
||
mutating func doBegin(tokenizer: inout Tokenizer<some TokenSink>, input: inout String.Iterator) -> CharRefStatus { | ||
fatalError("not implemented") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters