API Reference
Command Line Interface
flow run <script.flow>Arguments:
<script.flow>: Path to the FlowLang script file
Examples:
flow run examples/basic.flow
flow run workflow.flowProgrammatic Usage
FlowLang can be embedded in Python applications:
from flowlang.lexer import Lexer
from flowlang.parser import Parser
from flowlang.interpreter import Interpreter
# Your FlowLang-Script code
code = """
let x = 10
let y = 20
print x + y
"""
# Execute
tokens = Lexer(code).tokens
ast = Parser(tokens).parse()
Interpreter().eval(ast)Custom Built-in Functions
Extend FlowLang with custom built-in functions:
from flowlang.interpreter import Interpreter
interp = Interpreter()
# Add custom function
interp.builtins['custom_func'] = lambda args: args[0] * 2
# Execute code that uses it
code = "print custom_func(21)"
tokens = Lexer(code).tokens
ast = Parser(tokens).parse()
interp.eval(ast)Error Handling
FlowLang provides error messages for common issues:
- Syntax errors during parsing
- Undefined variables or functions
- Type errors in operations
- HTTP request failures
- File I/O errors
Module Structure
FlowLang consists of three main components:
- Lexer: Tokenizes the source code
- Parser: Builds an abstract syntax tree (AST)
- Interpreter: Evaluates the AST and executes the code
Return Values
When used programmatically, the interpreter returns the result of the last evaluated expression. This can be captured and used in your Python code.
Environment Variables
FlowLang scripts run in an isolated environment with access to:
- Local file system (via
read_fileandwrite_file) - Network access (via HTTP functions)
- Standard input/output (via
inputandprint)