Nextflow grammar for tree-sitter.
Target: Nextflow Strict Syntax (v2 Parser) -
NXF_SYNTAX_PARSER=v2This grammar is designed to support Nextflow's strict syntax mode, focusing on the cleaner, more consistent v2 parser syntax patterns.
- Core Nextflow Syntax: Process definitions, workflows, variable declarations
- Language Injection: Bash/shell syntax highlighting in script blocks
- Expressions: Binary operators, lists, maps, function calls
- Control Flow: If/else statements, blocks
- Channel Operations:
Channel.from(),Channel.value(),Channel.of()with pipe operations
Current Test Coverage: 28/80 tests passing (35%)
- ✅ Core Features: Variable declarations, process definitions, script injection
- ✅ Expressions: Binary operations, lists, maps, channel operations
- ✅ Control Flow: If/else statements, function calls
- 🚧 In Progress: String interpolation, advanced workflows, closures
- ⏳ Future: Configuration files, error handling, advanced channel operators
This grammar is designed to support ast-grep for advanced Nextflow code analysis and transformation.
Setup Steps:
-
Build Dynamic Library:
# Compile grammar as shared library for ast-grep tree-sitter build --output nextflow.so -
Configure AST-grep (
sgconfig.yml):customLanguages: nextflow: libraryPath: ./nextflow.so extensions: [nf, nextflow] expandoChar: "$" # For Nextflow string interpolation
-
Usage Examples:
# Search for process definitions ast-grep --lang nextflow 'process $NAME { $$$ }' # Find channel operations ast-grep --lang nextflow 'Channel.from($$$)' # Refactor variable declarations ast-grep --lang nextflow 'def $VAR = $VALUE' --replace 'val $VAR = $VALUE'
Benefits:
- Code Analysis: Search patterns across large Nextflow codebases
- Refactoring: Automated code transformations and migrations
- Quality Tools: Custom linting rules for Nextflow best practices
- IDE Features: Enhanced editor support and IntelliSense