Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stevapple/package-syntax-parser
https://github.com/stevapple/package-syntax-parser
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/stevapple/package-syntax-parser
- Owner: stevapple
- License: apache-2.0
- Created: 2021-08-13T05:28:43.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-22T09:54:35.000Z (about 3 years ago)
- Last Synced: 2024-07-05T13:46:08.009Z (4 months ago)
- Language: Swift
- Size: 24.4 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# `package-syntax-parser`
`package-syntax-parser` is a temporary substitute for the proposed frontend parser for the new `@package` syntax in Swift, based on [`SwiftSyntax`](https://github.com/apple/swift-syntax). _This package is a part of [Google Summer of Code](https://summerofcode.withgoogle.com) 2021 project [SwiftPM support for Swift scripts](https://summerofcode.withgoogle.com/projects/#5240743418920960)._
**NOTE: This tool is supposed to be deprecated once the corresponding frontend implementation is available.**
## Usage
```
USAGE: package-syntax-parserARGUMENTS:
OPTIONS:
-h, --help Show help information.
```## Output
For `test.swift`:
```swift
@package(url: "https://github.com/apple/swift-log.git", from: "1.0.0")
import Logging@package(path: "swift-argument-parser")
import ArgumentParserstruct Count: ParsableCommand {
@Argument var inputFile: String
@Argument var outputFile: Stringfunc run() throws {
let logger = Logger(label: "com.example.Script.main")
logger.info("""
Counting words in '\(inputFile)' \
and writing the result into '\(outputFile)'.
""")// Read 'inputFile', count the words, and save to 'outputFile'.
}
}
Count.main()
```The output is:
```json
{
"dependencies" : [
{
"package" : {
"raw" : "url:\"https:\/\/github.com\/apple\/swift-log.git\",from:\"1.0.0\"",
"url" : "https:\/\/github.com\/apple\/swift-log.git"
},
"modules" : [
"Logging"
]
},
{
"package" : {
"raw" : "path:\"\/Users\/stavapple\/Developer\/swift-argument-parser\"",
"path" : "\/Users\/stavapple\/Developer\/swift-argument-parser"
},
"modules" : [
"ArgumentParser"
]
}
],
"sourceFile" : "\/Users\/stavapple\/Developer\/test.swift"
}
```