tags
This directory contains the universal core system for programming language syntax within the Talon community repository. It defines a set of Talon tags, lists, captures, and abstract actions that represent fundamental coding components.
By defining these standard command templates here, developers can map their language-specific implementations (such as Python, C++, Java, or Go) to a single unified set of voice commands. For example, saying "state if" triggers the standard ifStatement snippet across any language that implements the imperative tag.
Language Operators Framework
This sub-system provides a clean, abstract interface for inserting operators. Instead of defining hardcoded strings for addition, bitwise shifts, or pointer manipulation in every language context, the system uses a centralized routing structure:
- Core Dispatcher: operators.py declares the top-level tags and lists for various categories of operators. It defines a structured
Operatorsdictionary type and a unifieduser.code_operator(identifier: str)action. This action queries the active language context'scode_get_operators()implementation to retrieve the correct character/callable. If a language context has not implemented the modern dictionary-based lookup, it falls back gracefully to legacy actions viaoperators_fallback(). - Voice Trigger Mapping: operators.talon parses voice commands like
op {operator}oris {comparison}and passes the corresponding key to the core dispatcher.
Operator Categories & Lists
The operators are organized into modular files by purpose, which allows a programming language's context file to selectively activate only the relevant tags (e.g., C++ would activate pointer and bitwise operators, while Python might only activate math, array, and assignment operators):
- Mathematical & Comparison: operators_math.py defines the abstract math action stubs. Concrete vocalizations are defined in operators_math.talon-list (for algebraic operations like
plus,minus,mod) and operators_math_comparison.talon-list (for comparisons likeequal,less or equal,not in). - Assignments: operators_assignment.py acts as the bridge for variable assignments, while operators_assignment.talon-list specifies assignment variations like standard
equals,or equals, and combined computation assignments (e.g.,plus equals,times equals). - Bitwise: operators_bitwise.py and operators_bitwise.talon-list handle operations working on binary numbers, such as logical gates (
and,or,exclusive or) and bit-shifts. - Pointers & Dereferencing: operators_pointer.py and operators_pointer.talon-list abstract pointer concepts like
address of(&) orarrow(->) dereferencing. - Arrays & Lambdas: operators_array.py alongside operators_array.talon-list implement subscripts (
[]), while operators_lambda.py and operators_lambda.talon-list implement anonymous functions.
Command Deprecations
To maintain consistency and transition the community to standard phrasing, several files act as deprecation managers. They intercept older, legacy commands and call user.deprecate_command to log/notify users of the modern alternative:
- operators_math_deprecations.talon (e.g., warning on "op add", directing to "op plus")
- operators_assignment_deprecations.talon (e.g., warning on "op assign", directing to "op equals")
- operators_bitwise_deprecations.talon (e.g., warning on "bitwise and", directing to "op bitwise and")
Code Comments
The system separates single-line comments, block comments, and documentation comments into clean abstract interfaces:
- Line Comments: comment_line.py defines the
user.code_comment_line_prefix()action. comment_line.talon handles voice command structures, allowing line placement (e.g.,comment line <text> over) or end-of-line append commands. - Block Comments: comment_block.py handles multi-line blocks. It includes built-in fallback rules for common C-style (
/* ... */) languages. The syntax rules are mapped to commands likeblock comment linein comment_block.talon. - Documentation Comments: comment_documentation.py and comment_documentation.talon register the voice trigger
dock commentto invoke automated documentation templates.
Functions & Modular GUI Picker
These files define how users declare, invoke, or mutate functions:
- Declarations and Types: functions.py and functions.talon implement function definitions, return types, and parameter formatting. It coordinates access modifiers (like
public,private,protected, andstatic) dynamically into the proper function-naming syntax (e.g., camelCase, snake_case) using Talon configuration settings. - Common Functions Picker: To save programmers from spelling out frequently used built-in functions, functions_common.py lists standard operations in an on-screen graphical user interface (IMGUI). Saying
toggle funkopens or closes this interface. Users can then say commands likefunk cell 3to instantly write or wrap selected code around the third function in the list. - Common Functions Configuration: functions_common.talon defines the generic voice commands, and functions_common_gui_active.talon enforces contextual hotkeys when the GUI panel is active.
Object-Oriented Syntax & Imperative Flow
These files streamline structured code blocks and object operations:
- Control Flow (Imperative): imperative.py and imperative.talon map commands like
state if,state while,state for, andstate returnto standardized snippets (e.g.,ifStatement,whileLoopStatement). Many of the explicit python actions in this file are flagged for deprecation in favor of standard snippet insertions. - Object-Oriented Operations: object_oriented.py and object_oriented.talon manage self-referential keywords and classes. Trigger words like
self dotgenerate the active language's instance reference joined with its member accessor (e.g.,this.in Java orself.in Python).
Primitive Types, Generics, and Libraries
These files assist in handling types, values, and namespaces:
- Boolean and Null States: data_bool.py / data_bool.talon handle language-equivalent bool insertions. data_null.py / data_null.talon map phrases like
state niloris not nullto the target language's null identifier. - Complex Generic Type Synthesizer: generic_types.py contains logic for parsing nested types (e.g.,
Map<String, List<Integer>>). It compiles type strings on the fly by processing connectors likeof,and, anddone(acting as bracket/delimiter cues). - Keywords: keywords.py and keywords.talon let users chain multiple syntax keywords consecutively, ensuring correct whitespace separation between tokens.
- Libraries & Imports: libraries.py and libraries.talon provide abstract hooks to write import statements (
state import) and insert library dependencies.