A Fortran frontend that transforms Lazy Fortran to standard-conforming Fortran.
- End-to-end pipeline: lexing, parsing, semantic checks, and Fortran emission
- Lazy Fortran to standard Fortran conversion with automatic type inference
- CLI and library APIs for scripting, pipelines, and embedding in larger tools
Lazy Fortran omits boilerplate that fortfront infers automatically:
- Type declarations:
x = 5becomesinteger :: x - Function return types: inferred from usage
- Array bounds: automatic shape inference for allocatables
- Program structure: wraps bare statements in
program main ... end program
Example transformation:
! input.lf
function add(a, b)
result = a + b
end function
x = add(5, 3)
! output.f90
program main
implicit none
integer :: x
contains
function add(a, b)
implicit none
integer, intent(in) :: a, b
integer :: add
add = a + b
end function
x = add(5, 3)
end programfpm build
makefortfront input.lf > output.f90
echo "x = 5" | fortfront > output.f90-h, --helpShow help-v, --versionShow version--trace[=on|off]Enable/disable tracing--trace-file <path>Trace output path--End of options (for filenames starting with-)
FortFront provides a modular API for integration into downstream tools such as linters, compilers, and formatters.
fortfront_lexer- Tokenization and lexical analysisfortfront_parser- Token parsing and AST constructionfortfront_ast- AST node types and traversal utilitiesfortfront_semantic- Type inference and semantic validationfortfront_codegen- Standard Fortran code generationfortfront_error- Error handling and reportingfortfront_transform- High-level transformation pipelinefortfront_tooling- Convenience functions for tool developers
use fortfront_transform, only: transform_lazy_fortran_string
character(len=:), allocatable :: input, output, error_msg
input = "x = 5"
call transform_lazy_fortran_string(input, output, error_msg)
if (len(error_msg) == 0) then
print '(a)', output
else
print '(a)', 'Transformation failed: ' // error_msg
end ifSee issue #1642 for the full API specification and docs/LIBRARY_USAGE.md for worked examples.
- Fortrun integration: https://github.com/lazy-fortran/fortrun
- Examples:
examples/ - Architecture docs:
docs/