-
-
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.
Merge pull request #392 from tayloraswift/doclink-equivalence
support disambiguation filters in doclinks
- Loading branch information
Showing
17 changed files
with
155 additions
and
40 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
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
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
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
29 changes: 29 additions & 0 deletions
29
Sources/UCF/Codelinks/Grammar/UCF.DisambiguationSuffixRule.swift
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Grammar | ||
|
||
extension UCF | ||
{ | ||
/// DisambiguationSuffix ::= SignatureSuffix Clauses ? | Clauses | ||
/// | ||
/// Note that the leading whitespace is considered part of the disambiguator. | ||
enum DisambiguationSuffixRule:ParsingRule | ||
{ | ||
typealias Location = String.Index | ||
typealias Terminal = Unicode.Scalar | ||
typealias Construction = (SignaturePattern?, [(String, String?)]) | ||
|
||
static func parse<Diagnostics>( | ||
_ input:inout ParsingInput<Diagnostics>) throws -> Construction where | ||
Diagnostics:ParsingDiagnostics, | ||
Diagnostics.Source.Element == Terminal, | ||
Diagnostics.Source.Index == Location | ||
{ | ||
if let clauses:[(String, String?)] = input.parse(as: DisambiguatorRule.Clauses?.self) | ||
{ | ||
return (nil, clauses) | ||
} | ||
|
||
let signature:SignaturePattern = try input.parse(as: SignatureSuffixRule.self) | ||
return (signature, input.parse(as: DisambiguatorRule.Clauses?.self) ?? []) | ||
} | ||
} | ||
} |
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Grammar | ||
|
||
extension UCF | ||
{ | ||
/// Space ::= \s + | '-' | ||
enum SpaceRule:ParsingRule | ||
{ | ||
typealias Location = String.Index | ||
typealias Terminal = Unicode.Scalar | ||
|
||
static func parse<Diagnostics>( | ||
_ input:inout ParsingInput<Diagnostics>) throws -> Void where | ||
Diagnostics:ParsingDiagnostics, | ||
Diagnostics.Source.Element == Terminal, | ||
Diagnostics.Source.Index == Location | ||
{ | ||
if case ()? = input.parse(as: UnicodeEncoding<Location, Terminal>.Space?.self) | ||
{ | ||
input.parse(as: UnicodeEncoding<Location, Terminal>.Space.self, in: Void.self) | ||
} | ||
else | ||
{ | ||
try input.parse(as: UnicodeEncoding<Location, Terminal>.Hyphen.self) | ||
} | ||
} | ||
} | ||
} |
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
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
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
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
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