Dana Language Syntax Reference¶
Dana is a domain-specific language designed for AI-driven automation and reasoning. This document provides a comprehensive reference for Dana's syntax and language features, as supported by the current grammar and runtime.
Dana vs. Python: Quick Comparison¶
- Dana's syntax is intentionally similar to Python: indentation, assignments, conditionals, loops, and function calls all look familiar.
- Dana requires explicit scope prefixes for variables (e.g.,
private:x
,public:y
), unlike Python. - Dana only supports single-line comments with
#
(no docstrings). - Dana supports f-strings with embedded expressions (e.g.,
f"Value: {x+1}"
). - Some advanced Python features (like comprehensions, decorators, or dynamic typing) are not present in Dana.
Basic Syntax¶
Comments¶
Variables and Scoping¶
Dana has a structured scoping system with four standard scopes:
- private
: Private to the agent, resource, or tool itself
- public
: Openly accessible world state (time, weather, etc.)
- system
: System-related mechanical state with controlled access
- local
: Local scope for the current execution (implicit in most cases)
Variables must be prefixed with their scope:
For convenience in the REPL environment, variables without a scope prefix are automatically placed in the local
scope:
Basic Data Types¶
- Strings: "double quoted" or 'single quoted'
- Numbers: 42 or 3.14
- Booleans: true or false
- Null: null
Statements¶
Assignment¶
Conditional Statements¶
While Loops¶
Function Calls¶
Bare Identifiers¶
A bare identifier (just a variable or function name) is allowed as a statement, typically for REPL inspection:
Expressions¶
Binary Operators¶
- Comparison:
==
,!=
,<
,>
,<=
,>=
- Logical:
and
,or
- Arithmetic:
+
,-
,*
,/
,%
Operator Precedence¶
- Parentheses
()
- Multiplication/Division/Modulo
*
,/
,%
- Addition/Subtraction
+
,-
- Comparison
<
,>
,<=
,>=
,==
,!=
- Logical
and
,or
Function Calls in Expressions¶
Best Practices¶
- Always use explicit scope prefixes for clarity
- Use meaningful variable names
- Add comments for complex logic
- Structure code with clear indentation for blocks
Examples¶
Basic Program with Scoping¶
# Define variables with explicit scopes
private:name = "World"
public:count = 5
system:status = "active"
# Print
print("Hello, " + private:name)
print(public:count)
# Conditional logic
if public:count > 3:
print("Count is high")
else:
print("Count is normal")
While Loop Example¶
Copyright © 2025 Aitomatic, Inc. Licensed under the MIT License.
https://aitomatic.com