 .  26. GrammaLang:  
 


  #26
      GrammaLang  0.2,   ,     .     ,    ,  -  LLM      .

              .      ,      . Grammar Change   .

   -.    ,   .   .   .  .





 

 .  26. GrammaLang:  





.


         .

 2025      .     -   ,    .    split, hold, transition, grammar_change.    Substance, Modus, Boundary, TensionNode.  ,     ,  MCP-  .     .  GrammaLang,      .

       .      Python-,      .      .

  . GrammaLang  0.2    .    Python-     . Rust-   . NLP-   stanza,    ,  ,    ,    . MIDI-,     . ,     .  .     .

  .   :

text

https://pawelkaev.github.io/grammalang/interface.html

 - GrammaLang.    (),      ,       :   ,  ,  ,        .        (    4),  -    .

  .     . GrammaLang   ,     .           .    :    ,   .

      .     .

 ,   ,      ,     .     I (  )   VII ().  ,   hold     ,   hold_contradiction  Rust- OntologicalContext,       .

   ,       .     II (   ),  IV (  ),  V (  LLM-).        MIDI-          .

 ,    :   , , MCP-     .     VIII (  )    EBNF-   .

       .    GrammaLang    .     .       .     : NLP-, , .        ,   .

     .  ,  hold_contradiction  TensionNode          grammalang-core/src/ontology.rs,       .  ,            pytest -v    .

   . GrammaLang       .        ,  ,  VM,   IDE.        ,   .

    .




  0.2.


.    GrammaLang  0.2.   ,   . ,        0.3,    .  :

 grammalang run script.gl   .    GrammaLang  ,     VM    0.3.

 MCP-       .

 VM     split   .

WebSocket-      .

      .   .     ,   ,          .

    GrammaLang   -   .   ,      .       ( 4).




.


       .       .        .     Python-  Rust-,  CLI  ,     NLP-     Claude (Anthropic)   -  -.

     Rust, Python, stanza, PyO3, mido  D3.js,     GrammaLang.




.


    .

          PS>:

text

PS> grammalang analyze "  " -o output.mid

     PS>,     (   PowerShell,   ).

      .  src/grammalang/analyzers/grammar_analyzer.py :   grammalang   src,  grammalang,  analyzers,   grammar_analyzer.py.

   (, , )     : OntologicalContext, hold_contradiction, TensionStatus::Held.  ,    ,  : , , .

    ,   .

 I.   .




 1.    .





1.1. :   .


    :          .      ,   ,        .

    :       ,       .        :     ,  .     .        ,      .

GrammaLang        .      .      ,     ,    .




1.2.  .


Split ().            .       .    ,    .

Hold ().  ,   .  TensionNode  ,       .       .

Transition ().         .   ,   ,    .

Grammar_change ( ).    VM.        .      .

      .




1.3.  .


Substance ().  .  ,       0  1,     .

Modus ().     .    .      -.

Boundary ().   . ,      .

TensionNode ( ).   GrammaLang.     : held (), resolved (), escalated ().

           6.




1.4.   .


 .  .  .    .

 .    .     ,   .   .

     grammar_change.       GrammaLang:     .




1.5. :    .


  :   :   .    :    0.8     0.4.  hold  TensionNode   antinomy   held.

 VM   ,        .         .

 MIDI-   :    (  ,   ),   ,    .           .




 2.  GrammaLang.





2.1.  .


GrammaLang     .    : CLI, -, .    Python-: , , .    Rust-:  , ,  .

   .     Python  Rust     .   :  MIDI,  JSON-.             ,   .




2.2. Python-.


        . MaterialSource   . OntologicalAnalyzer   . OutputGenerator   . GrammaPipeline   .

 :       .     OntologicalContext.      .




2.3. Rust-.


    . ontology.rs     . error.rs   . trace.rs     .

    BTreeMap,   HashMap.          .

Rust   .       GrammaLang: split   , hold    , grammar_change   .       .




2.4.  Rust ? Python.


  PyO3.  analyze_text  Rust   .pyd,  Python    . RustAnalyzer  ,  Rust-   JSON  Pydantic-.     RustAnalyzer    KantianAnalyzer.




2.5.   


HTTP-   8080,  POST-,  JSON   .      .     https://pawelkaev.github.io/grammalang/interface.html.




2.6.    .


Test Oracle        MD5-   .       .    -  ,      .




2.7. CLI  .


    : analyze, prompt-validate, prompt-run.      LLM.   JSON-   prompts/.     -.

 II.    .

 3. .




3.0.    .


    ,   GrammaLang,   Python, Rust  NLP-,   :

text

https://pawelkaev.github.io/grammalang/interface.html

   (),  .   ,    ,            .  :   NLP-    ( ).

      MIDI-, NLP-      .




3.1.   .


Python  3.10  . : python --version.      python.org,  Add Python to PATH.

Rust  1.70  . : winget install Rustlang.Rustup. : rustc --version.

Visual Studio Build Tools 2022. : winget install Microsoft.VisualStudio.2022.BuildTools.     .

Git  ,    .




3.2.  .


 ZIP-:

text

https://github.com/PawelKaev/grammalang/archive/refs/heads/main.zip

    . : https://github.com/PawelKaev/grammalang.

    .   grammalang-main  grammalang.     pyproject.toml, Makefile, interface.html, visualizer.html,  src, grammalang-core, tests, prompts.




3.3.  .


 VS Code. File ? Open Folder ?   grammalang.  : Terminal ? New Terminal.




3.4.   Python


text

PS> python -m venv .venv

PS> .venv\Scripts\Activate.ps1

   :

text

PS> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

3.5. 



Rust-

.

text

PS> cd grammalang-core

PS> $env:PYO3_USE_ABI3_FORWARD_COMPATIBILITY = "1"

PS> cargo build --release

PS> Copy-Item -Path target\release\grammalang_core.dll -Destination ..\src\grammalang\rust_bridge\grammalang_core.pyd -Force

PS> cd ..




3.6.  Python-


text

PS> pip install -e ".[dev]"

PS> python -c "import stanza; stanza.download('ru')"




3.7.  .


text

PS> pytest -v

PS> grammalang --help

     .

 4.  .




4.1.  analyze.


text

PS> grammalang analyze "  :   " -o my_first.mid

CLI  ,   ,     MIDI.




4.2.   


 :  (,  0.8),  (, 0.4).    TensionNode   held.       .




4.3. -.


 https://pawelkaev.github.io/grammalang/interface.html.     :

text

PS> python -c "from grammalang.server import run_server; run_server()"

   (),  .  ,  ,     .




4.4.    .


:      ,     ,   .        .




4.5. NLP-  -


            .   GrammarAnalyzer,      stanza.




4.6.   .


MIDI       .       JSON,   ,       LLM  .

 III.  GrammaLang.

 5.  GrammaLang.

5.1.  GrammaLang  

 GrammaLang   .    : Python-  Rust-,    .    ,       ,  .

 GrammaLang .           ,      .              .    ,    .

   (0.2)      Rust-    .    GrammaLang    0.3.                 Python-.

5.2.  

          :

text

//  

    , ,    .     (   ),    .  .   : , Freedom, __, tension_01.

        . :  0.0  1.0. : 0.8, 0.0, 1.0, 0.35.

          : "antinomy", " ".

5.3.  

   .    substance,        :

text

substance  {

energy: 0.8

}

       .     0  1,        .

        .      .       ,    .

:

text

substance  {

energy: 0.9

}

substance  {

energy: 0.3

}

substance  {

energy: 0.6

}

substance  {

energy: 0.7

}

5.4. 

      .    modus,      :

text

modus  

modus  

modus  

   modus   ,    .     ( ).     ;        .

         .  ,   ,     .

5.5.  

  .    boundary,         inside  outside:

text

boundary _ {

inside: [, , ]

outside: [___, ]

}

inside  outside      .  ,     ,   .             .

      ,     .

5.6.  

  (TensionNode)    tension,        :

text

tension  vs  reason ""

  vs  , reason     .      .

    hold (     held),  tension       .     held.

5.7. 

        .

Hold   :

text

hold tension_01

  hold    TensionNode.      held (     )  .

Split   :

text

split {

//  A

substance  { energy: 0.9 }

} {

//  B

substance  { energy: 0.3 }

}

       .     :        .

Resolve   :

text

resolve tension_01 with 

  with ,      .      ,   TensionNode.

Grammar_change   :

text

grammar_change polyphonic

grammar_change reactor

 : reactor ( )  polyphonic ( ).

5.8.   

   GrammaLang,     :

text

//    

substance  {

energy: 0.8

}

substance  {

energy: 0.4

}

tension  vs  vs  reason "  "

modus  

modus  

//     

grammar_change polyphonic

hold 

//      

grammar_change reactor

resolve  with 

    ,  ,  ,  ,  ,      .      ,      JSON, MIDI  .

5.9.   (EBNF)

      -    .        :

text

program        = { statement } ;

statement      = substance_decl | modus_decl | boundary_decl

| tension_decl | operation ;

substance_decl = "substance" ID "{" "energy" ":" NUMBER "}" ;

modus_decl     = "modus" ID ID ;

boundary_decl  = "boundary" ID "{" "inside" ":" "[" { ID "," } "]"

"outside" ":" "[" { ID "," } "]" "}" ;

tension_decl   = "tension" ID "vs" ID "reason" STRING ;

operation      = hold_op | split_op | resolve_op | grammar_change_op ;

hold_op        = "hold" ID ;

split_op       = "split" "{" { statement } "}" "{" { statement } "}" ;

resolve_op     = "resolve" ID "with" ID ;

grammar_change_op = "grammar_change" ("reactor" | "polyphonic") ;

5.10.  

  0.3     Rust,     GrammaLang   :

text

PS> grammalang run script.gl

      (  ),         ,      .




 5.11. -:   .


      ,     .   , ,   ,    .       ,      .         ,      .

       ,    ,    .     ,      .




5.11.1.  Split:  .


.   .        ,         .   ,    . TensionNode     ,   ,   .

.  split    .     ,    .       :     ,     .

. ,       .          :    ,   .       :   ,    .

       .  ,     ,      (  ,  )      (  ,    ).

.    collect  merge  split.         :  ,         .        (,    ),   throttle       .




5.11.2.  Hold:  .


. TensionNode ,       .     ,      .       ,     .

.  hold      .   ,    :          .      :    ,    ,     ,    .

. ,     TensionNode:

timeout    ;

escalate  ,      ;

review_interval    .

         TensionNode  .  ,     ,      (  )      ( ,    ).

.   TensionNode  :

resolve_when    (,   );

escalate_after    ,       ;

periodic_review   ,    .

   ,   TensionNode      .      ,   .     ,   , ,       reason.




5.11.3.  Transition:    .


.           .     ,     . , ,     ,        ( ).

.   (via)     .       ,        .   ,     .

.      .     Substance   origin         ,     .   Substance  origin   .  origin ,         .

 ,     :      .     Lexical   Ontological,  Syntactic, Semantic  Pragmatic,               .

.      :

text

transition Lexical to Syntactic via group_into_structures

then to Semantic via interpret_as_values

then to Pragmatic via contextualize_as_actions

then to Ontological via reformulate_as_entities;

   origin  Modus  .       :     .

    (,    ,       ),   summarize    ,       .




5.11.4.  Grammar Change:  .


.         .     TensionNode   .   :  TensionNode  held,   resolved,    held,   .

.   (grammar_change when)   . ??     .   ,       ,     .

.   .   MCP  GrammarChangeRecord   .    ,    N  ( N    ),  .

 ,     : Reactor ? Polyphonic ? Reactor ? Polyphonic      .    ,       .

.  :       ,      K  (, 3).     .   .

    : grammar_change when (plasma_duration > 3_cycles) and (not switching_back_immediately).  ,      ,   ,    .




5.11.5.  :    .


     .   (Split)     ,     (Hold).     (Transition)     ,     Grammar Change.   .

  .   :

  :   Substance  TensionNode  ,        .

 TensionNode:    TensionNode (   )       .

 :   ,       .

    ,     .

.  .       .   :     (      )     .        ,   .




5.11.6. :   .


        .   ,    4.6,   .       .

 1:   TensionNode.  ( N )   TensionNode.     :     ?    ,    ?     ?     hold  :   ,   .

 2:  .   transition ,    .        .       ,     ,   .     transition  :   ,    .

 3:   .   .   ,  ,    ,   .     grammar_change  :   ,    .




  .


   .

   ,     (https://www.litres.ru/book/valeriy-antonov-3298/grammaticheskaya-mashina-tom-26-grammalang-praktiches-74094204/)  .

      Visa, MasterCard, Maestro,    ,   ,     ,  PayPal, WebMoney, ., QIWI ,       .


