Commit 9f47c906 authored by Roman Alifanov's avatar Roman Alifanov

Update documentation for AWK sync and dict.field fix

- CLAUDE.md: expanded @awk section with new features - README.md: updated @awk supported features list - LANGUAGE_SPEC.md: added AWK extras, dict.field syntax
parent a8f275f6
......@@ -169,8 +169,16 @@ items = ["a", "b", "c"]
# Ассоциативный массив (dict/map)
config = {"host": "localhost", "port": 8080}
# Dict-style объекты с точечной нотацией
obj = {}
obj.name = "Alice"
obj.age = 30
print (obj.name) # Alice
```
Dict-переменные поддерживают присваивание полей через точку: `obj.field = value` генерирует `obj["field"]="value"`.
### Функции
```
......@@ -444,16 +452,24 @@ func sumNumbers (text) {
- `break`, `continue`, `return`
**Доступные методы в @awk:**
- Строки: `text.len ()`, `text.upper ()`, `text.lower ()`, `text.trim ()`, `text.substr ()`, `text.index ()`, `text.contains ()`, `text.split ()`, `text.replace ()`, `text.starts ()`, `text.ends ()`, `text.charAt ()`
- Строки: `text.len ()`, `text.upper ()`, `text.lower ()`, `text.trim ()`, `text.substr ()`, `text.index ()`, `text.contains ()`, `text.split ()`, `text.replace ()`, `text.starts ()`, `text.ends ()`, `text.charAt ()`, `text.chr ()`
- Массивы: `arr.len ()`, `arr.get ()`, `arr.set ()`, `arr.push ()`, `arr.pop ()`, `arr.shift ()`, `arr.has ()`, `arr.del ()`, `arr.map ()`, `arr.filter ()`
- Словари: `dict.get ()`, `dict.set ()`, `dict.has ()`, `dict.del ()`, `dict.keys ()`
- Математика: `math.sin ()`, `math.cos ()`, `math.sqrt ()`, `math.log ()`, `math.exp ()`, `math.int ()`, `math.rand ()`, `math.atan2 ()`
- Время: `time.now ()``systime ()`
- Вывод: `print ()`, `printf ()`, `sprintf ()`
- Декораторы: `@validate` работает с `@awk` функциями
- Assertions: `assert ()`, `assert_eq ()`
**Дополнительные возможности @awk:**
- Строковая интерполяция: `"Hello, {name}!"``("Hello, " name "!")`
- Переменные окружения: `env.HOME``ENVIRON["HOME"]`
- Method statements: `arr.push (x)`, `d.set (k, v)` — без присваивания результата
- Dict-style объекты: `obj.field = value``obj["field"] = value`
**Ограничения AWK:**
- Массивы в AWK ассоциативные — `pop ()`, `shift ()`, `join ()`, `slice ()` имеют ограниченную поддержку
- `ord ()` / `chr ()` недоступны (только в gawk)
- `ord ()` недоступен (только в gawk), `chr ()` работает через `sprintf`
- Нет доступа к `this` в методах классов
**Обработка файлов с __input__:**
......
......@@ -359,9 +359,17 @@ class Calculator {
- Loops: `for i in range()`, `foreach`, `while`
- Conditions: `if/else if/else`, `when`
- Operators: `+`, `-`, `*`, `/`, `%`, `^`, `==`, `!=`, `<`, `>`, `<=`, `>=`, `&&`, `||`
- String methods: `.len()`, `.upper()`, `.lower()`, `.trim()`, `.split()`, `.substr()`, `.contains()`, `.replace()`
- Array methods: `.len()`, `.get()`, `.set()`, `.push()`, `.pop()`, `.map()`, `.filter()`
- Math: `math.sin()`, `math.cos()`, `math.sqrt()`, `math.log()`, `math.exp()`
- String methods: `.len ()`, `.upper ()`, `.lower ()`, `.trim ()`, `.split ()`, `.substr ()`, `.contains ()`, `.replace ()`, `.chr ()`
- Array methods: `.len ()`, `.get ()`, `.set ()`, `.push ()`, `.pop ()`, `.map ()`, `.filter ()`
- Dict methods: `.get ()`, `.set ()`, `.has ()`, `.del ()`
- Math: `math.sin ()`, `math.cos ()`, `math.sqrt ()`, `math.log ()`, `math.exp ()`
- String interpolation: `"Hello, {name}!"` works in @awk
- Environment variables: `env.HOME``ENVIRON["HOME"]`
- Time: `time.now ()``systime ()`
- Assertions: `assert ()`, `assert_eq ()`
- Print: `print ()` as statement
- Method statements: `arr.push (x)`, `d.set (k, v)` without assignment
- Dict-style objects: `obj.field = value``obj["field"] = value`
- Decorators: `@validate` works with `@awk` functions
- `break`, `continue`, `return`
......@@ -369,7 +377,7 @@ class Calculator {
- No access to `this` in class methods — pass data via parameters
- Arrays are associative (AWK limitation)
- No `ord()`/`chr()` (gawk-only)
- No `ord()` (gawk-only), `chr()` works via `sprintf`
Uses `mawk` (preferred) or `gawk` for maximum speed.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment