-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[main] - Fix issue where quotes basically didn't parse anything insid…
…e of them - TT
- Loading branch information
1 parent
b78e072
commit 9549a98
Showing
15 changed files
with
119 additions
and
54 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
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
43 changes: 43 additions & 0 deletions
43
Sources/CucumberSwift/StubGeneration/StubGeneratorLexer.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,43 @@ | ||
// | ||
// StubGeneratorLexer.swift | ||
// CucumberSwift | ||
// | ||
// Created by Tyler Thompson on 3/12/23. | ||
// Copyright © 2023 Tyler Thompson. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
extension StubGenerator { | ||
public class Lexer: StringReader { | ||
override internal init(_ str: String) { | ||
super.init(str) | ||
} | ||
|
||
@discardableResult private func advance<T>(_ t: @autoclosure () -> T) -> T { | ||
advanceIndex() | ||
return t() | ||
} | ||
|
||
internal func advanceToNextToken() -> Token? { | ||
guard let char = currentChar else { return nil } | ||
|
||
switch char { | ||
case .quote: | ||
let str = advance(readUntil { $0.isQuote }) | ||
return advance(.string(value: str)) | ||
case _ where char.isNumeric: | ||
let allIntegerValues = readUntil { !$0.isNumeric } | ||
return .int(value: allIntegerValues) | ||
default: return .match(value: readUntil { $0.isQuote || $0.isNumeric }) | ||
} | ||
} | ||
|
||
internal func lex() -> [Token] { | ||
var toks = [Token]() | ||
while let tok = advanceToNextToken() { | ||
toks.append(tok) | ||
} | ||
return toks | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Sources/CucumberSwift/StubGeneration/StubGeneratorToken.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,31 @@ | ||
// | ||
// StubGeneratorToken.swift | ||
// CucumberSwift | ||
// | ||
// Created by Tyler Thompson on 3/12/23. | ||
// Copyright © 2023 Tyler Thompson. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension StubGenerator { | ||
enum Token { | ||
case match(value: String) | ||
case string(value: String) | ||
case int(value: String) | ||
|
||
func isString() -> Bool { | ||
if case .string = self { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
func isInteger() -> Bool { | ||
if case .int = self { | ||
return true | ||
} | ||
return false | ||
} | ||
} | ||
} |
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