Contributing
Contributions to VHP are welcome! Here’s how you can help.
Ways to Contribute
- Report bugs - Open an issue describing the problem
- Request features - Suggest new functionality
- Submit pull requests - Fix bugs or implement features
- Improve documentation - Help make the docs clearer
- Add tests - Increase test coverage
Development Setup
- Fork and clone the repository:
git clone https://github.com/YOUR_USERNAME/vhp.git cd vhp - Build the project:
cargo build - Run tests:
cargo build --release && ./target/release/vhp test -v
Adding New Features
1. Update Token Types (src/token.rs)
Add new token variants:
pub enum TokenKind {
// Add new tokens here
NewKeyword,
}
2. Update Lexer (src/lexer.rs)
Add recognition logic:
match ident.to_lowercase().as_str() {
"newkeyword" => TokenKind::NewKeyword,
// ...
}
3. Update AST (src/ast.rs)
Add new expression or statement types:
pub enum Stmt {
NewStatement { /* fields */ },
// ...
}
4. Update Parser (src/parser.rs)
Add parsing methods:
fn parse_new_statement(&mut self) -> Result<Stmt, String> {
// Parse the new statement
}
5. Update Interpreter (src/interpreter.rs)
Add execution logic:
match stmt {
Stmt::NewStatement { /* fields */ } => {
// Execute the new statement
}
// ...
}
6. Add Tests
Create .vhpt test files in the appropriate tests/ subdirectory.
Code Style
- No external dependencies unless absolutely necessary
- Comprehensive tests for every feature
- Clear error messages with line/column information
- PHP compatibility - existing PHP 8.x code should work
Pull Request Guidelines
- Create a feature branch from
main - Make your changes with clear commit messages
- Add tests for new functionality
- Ensure all tests pass
- Update documentation if needed
- Submit a pull request with a clear description
License
By contributing, you agree that your contributions will be licensed under the BSD 3-Clause License.
VHP