Pygmalion, yet another Solidity lexer written in Rust! This project leverages the power of the Rust programming language and the logos
library to provide a robust and efficient lexical analyzer for Solidity source code.
- Lexical Analysis: Pygmalion can tokenize Solidity source code, recognizing a wide variety of keywords, literals, operators, and more.
- Mode Switching: The lexer intelligently switches modes for different contexts like
pragma
,assembly
, andyul
. - Asynchronous Operations: Utilizes asynchronous file I/O for reading from and writing to files.
- CLI Support: Includes a command-line interface (CLI) for easy integration into your workflow.
Pygmalion can be used through its CLI. You can either provide a Solidity file or a short snippet of Solidity code for analysis. The lexer will output the tokenized version of the input.
You can add Pygmalion to your project using Cargo. Run the following command:
cargo install pygmalion
Here are the available CLI options:
-p, --path <PATH>
: Path of the Solidity file to analyze.-c, --code <CODE>
: Short Solidity code snippet to analyze.-o, --out <OUT>
: Output file for the lexical analysis results.
Analyze a Solidity file:
pygmalion -p path/to/your/file.sol
Analyze a short snippet of Solidity code:
pygmalion -c "pragma solidity ^0.8.0; contract HelloWorld { }"
Save the analysis result to a file:
pygmalion -p path/to/your/file.sol -o output.txt
To contribute to Pygmalion, follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Make your changes.
- Test thoroughly.
- Submit a pull request.
- main.rs: Entry point of the application.
- cli.rs: Command-line interface definition and argument parsing.
- file_io.rs: Asynchronous file input/output functions.
- lexer.rs: Lexer implementation, including token definitions and mode handling.
Pygmalion is licensed under the MIT License. See the LICENSE file for more details.
This project uses the following crates:
logos
for lexical analysis.tokio
for asynchronous I/O operations.clap
for command-line argument parsing.
Thank you for using Pygmalion! If you have any questions or feedback, feel free to open an issue on GitHub. Peace!