feat(protocol): grammatica S-expression (15 verbi) + parser
Aggiunge il modulo `multi_swarm.protocol` con la grammatica del DSL di strategia (15 verbi: 4 azioni, 3 logici, 3 comparatori, 4 dati, `when` e `strategy`) e un parser che produce un AST tipizzato (Strategy/Rule/ Node). Lessing delegato a sexpdata, validazione del set di verbi e forma `(when <cond> <action>)` gestita dal parser. Sollevata ParseError su top-level malformato, strategia vuota, verbi sconosciuti o azioni non terminali. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
from __future__ import annotations
|
||||
|
||||
VERBS: frozenset[str] = frozenset(
|
||||
{
|
||||
"entry-long",
|
||||
"entry-short",
|
||||
"exit",
|
||||
"flat",
|
||||
"when",
|
||||
"and",
|
||||
"or",
|
||||
"not",
|
||||
"gt",
|
||||
"lt",
|
||||
"eq",
|
||||
"feature",
|
||||
"indicator",
|
||||
"crossover",
|
||||
"crossunder",
|
||||
}
|
||||
)
|
||||
|
||||
ACTION_VERBS: frozenset[str] = frozenset({"entry-long", "entry-short", "exit", "flat"})
|
||||
LOGICAL_VERBS: frozenset[str] = frozenset({"and", "or", "not"})
|
||||
COMPARATOR_VERBS: frozenset[str] = frozenset({"gt", "lt", "eq"})
|
||||
DATA_VERBS: frozenset[str] = frozenset({"feature", "indicator", "crossover", "crossunder"})
|
||||
Reference in New Issue
Block a user