Language Bindings
Use Tauq in your favorite programming language with native bindings.
🐍 Python
Installation
pip install tauq Usage
import tauq
# 1. Parse Tauq to Python dict/list
data = tauq.loads("""
!def User id name email
1 Alice "alice@example.com"
2 Bob "bob@example.com"
""")
print(data)
# Output: [{'id': 1, 'name': 'Alice', 'email': 'alice@example.com'}, ...]
# 2. Format Python objects to Tauq
obj = [{"id": 1, "name": "Alice", "email": "alice@example.com"}]
tqn = tauq.dumps(obj)
print(tqn)
# Output:
# !def User id name email
# ---
# [
# !use User
# 1 Alice "alice@example.com"
# ]
# 3. Execute TauqQ (with shell access)
result = tauq.exec_tauqq("!emit echo 'status ok'")
# 4. Minify
minified = tauq.minify("!def A x; 1; 2; 3")
print(minified) # Single-line output Common Operations
import tauq
# Parse from file
with open('data.tqn') as f:
data = tauq.load(f)
# Format to file
with open('output.tqn', 'w') as f:
tauq.dump(data, f)
# Safe mode (disable shell execution)
result = tauq.exec_tauqq(tqq_content, safe_mode=True) 📜 JavaScript / TypeScript
Powered by WebAssembly for blazing-fast performance in Node.js and the browser.
Installation
npm install tauq Usage (ES Modules)
import * as tauq from 'tauq';
// 1. Parse Tauq to JavaScript object
const data = tauq.parse(`
!def User id name email
1 Alice "alice@example.com"
2 Bob "bob@example.com"
`);
console.log(data);
// Output: [{id: 1, name: "Alice", email: "alice@example.com"}, ...]
// 2. Stringify (Format) JavaScript to Tauq
const tqn = tauq.stringify(data);
console.log(tqn);
// 3. Execute TauqQ
// Note: Shell execution (!run, !emit) is sandboxed in browser
const result = tauq.exec("!set A 1\nfoo A", true); // safe_mode=true
// 4. Minify
const min = tauq.minify("!def T x; 1; 2");
console.log(min); TypeScript Support
import * as tauq from 'tauq';
interface User {
id: number;
name: string;
email: string;
}
const input = `
!def User id name email
1 Alice "alice@example.com"
`;
const users: User[] = tauq.parse(input);
console.log(users[0].email); // Type-safe! Browser Usage
<!-- Load from CDN -->
<script type="module">
import init, * as tauq from 'https://cdn.jsdelivr.net/npm/tauq/pkg/tauq_wasm.js';
await init(); // Initialize WASM
const data = tauq.parse('!def User id name; 1 Alice');
console.log(data);
</script> 🐹 Go
Idiomatic Marshal/Unmarshal interface similar to encoding/json.
Installation
go get github.com/epistates/tauq Usage
package main
import (
"fmt"
"github.com/epistates/tauq"
)
type User struct {
ID int `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
}
func main() {
// 1. Unmarshal (Parse)
input := `
!def User id name email
1 Alice "alice@example.com"
2 Bob "bob@example.com"
`
var users []User
err := tauq.Unmarshal([]byte(input), &users)
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", users)
// 2. Marshal (Format)
bytes, _ := tauq.Marshal(users)
fmt.Println(string(bytes))
// 3. Exec Query
tauq.Exec([]byte("!emit echo '1 Alice'"), true, &users) // safeMode=true
// 4. Minify
min, _ := tauq.Minify("!def T x; 1; 2")
fmt.Println(min)
} 🦀 Rust
This is the native library powering all other bindings.
Installation
Add to Cargo.toml:
[dependencies]
tauq = "0.1.0" Usage
use tauq;
fn main() {
let input = r#"
!def User id name email
1 Alice "alice@example.com"
2 Bob "bob@example.com"
"#;
// 1. Parse (Returns serde_json::Value)
let json_val = tauq::compile_tauq(input).unwrap();
println!("{:?}", json_val);
// 2. Format (JSON -> Tauq)
let tqn = tauq::format_to_tauq(&json_val);
println!("{}", tqn);
// 3. Exec Query (with safe_mode=true to disable shell execution)
let res = tauq::compile_tauqq("!def T x\n1\n2", true).unwrap();
println!("{:?}", res);
// 4. Minify
let min = tauq::minify_tauq_str(&json_val);
println!("{}", min);
} Streaming Parser
use tauq::StreamingParser;
use std::fs::File;
fn main() {
let file = File::open("large_data.tqn").unwrap();
let mut parser = StreamingParser::new(file);
// Process records one at a time (constant memory usage)
while let Some(record) = parser.next_record() {
match record {
Ok(value) => println!("{:?}", value),
Err(e) => eprintln!("Parse error: {}", e),
}
}
} Perfect for processing datasets larger than available RAM.
☕ Java / Kotlin
Installation
Maven:
<dependency>
<groupId>com.epistates</groupId>
<artifactId>tauq</artifactId>
<version>0.1.0</version>
</dependency> Gradle:
implementation 'com.epistates:tauq:0.1.0' Usage (Java)
import com.epistates.tauq.Tauq;
public class Main {
public static void main(String[] args) {
String input = """
!def User id name email
1 Alice "alice@example.com"
2 Bob "bob@example.com"
""";
// Parse
String json = Tauq.parse(input);
System.out.println(json);
// Format
String tqn = Tauq.format(json);
System.out.println(tqn);
// Minify
String min = Tauq.minify(input);
System.out.println(min);
}
} #️⃣ C# / .NET
Installation
dotnet add package Tauq Usage
using Tauq;
class Program
{
static void Main()
{
string input = @"
!def User id name email
1 Alice ""alice@example.com""
2 Bob ""bob@example.com""
";
// Parse
string json = TauqParser.Parse(input);
Console.WriteLine(json);
// Format
string tqn = TauqFormatter.Format(json);
Console.WriteLine(tqn);
// Minify
string min = TauqMinifier.Minify(input);
Console.WriteLine(min);
}
} 🕊️ Swift
Installation
Add to Package.swift:
.package(url: "https://github.com/epistates/tauq.git", from: "0.1.0") Usage
import Tauq
let input = """
!def User id name email
1 Alice "alice@example.com"
2 Bob "bob@example.com"
"""
// Parse
let json = try Tauq.parse(input)
print(json)
// Format
let tqn = try Tauq.format(json)
print(tqn)
// Minify
let min = try Tauq.minify(input)
print(min) API Comparison
| Operation | Python | JavaScript | Go | Rust |
|---|---|---|---|---|
| Parse | loads() | parse() | Unmarshal() | compile_tauq() |
| Format | dumps() | stringify() | Marshal() | format_to_tauq() |
| Execute | exec_tauqq() | exec() | Exec() | compile_tauqq() |
| Minify | minify() | minify() | Minify() | minify_tauq_str() |