You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/SWBMacro/MacroConfigFileParser.swift
+17Lines changed: 17 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,15 @@ public final class MacroConfigFileParser {
42
42
/// Current line number. Starts at one.
43
43
varcurrLine:Int
44
44
45
+
/// The final line number after parsing completes.
46
+
publicprivate(set)varfinalLineNumber:Int=1
47
+
48
+
/// The final column number after parsing completes.
49
+
publicprivate(set)varfinalColumnNumber:Int=1
50
+
51
+
/// Index of the start of the current line in the byte array.
52
+
privatevarcurrentLineStartIdx:Int=0
53
+
45
54
46
55
/// Initializes the macro expression parser with the given string and delegate. How the string is parsed depends on the particular parse method that’s invoked, such as `parseAsString()` or `parseAsStringList()`, and not on the configuration of the parser.
@@ -55,6 +64,9 @@ public final class MacroConfigFileParser {
55
64
/// Returns the current line number of the parser. This is commonly used from the custom implementations of the parser delegate function callbacks. Line numbers are one-based, and refer only to the source text of the parser itself (not taking into account any source text included using #include directives).
56
65
publicvarlineNumber:Int{return currLine }
57
66
67
+
/// Returns the current column number of the parser. Column numbers are one-based.
/// We use a custom delegate to test that we’re getting the expected results, which for the sake of convenience are just kept in (name, conds:[(cond-param, cond-value)], value) tuples, i.e. conditions is an array of two-element tuples.
// Check the final line and column numbers if expected values are provided.
917
+
iflet expectedEndLine {
918
+
#expect(parser.finalLineNumber == expectedEndLine,"expected final line number \(expectedEndLine), but instead got \(parser.finalLineNumber)", sourceLocation: sourceLocation)
919
+
}
920
+
iflet expectedEndColumn {
921
+
#expect(parser.finalColumnNumber == expectedEndColumn,"expected final column number \(expectedEndColumn), but instead got \(parser.finalColumnNumber)", sourceLocation: sourceLocation)
922
+
}
876
923
877
924
// Check the assignments that the delegate saw against the expected ones.
0 commit comments