chaosprint / glicol

Graph-oriented live coding language and music/audio DSP library written in Rust
https://glicol.org
MIT License
2.25k stars 74 forks source link

Towards no-panic: the error handling system #58

Open chaosprint opened 2 years ago

chaosprint commented 2 years ago

Currently, the pest parser generates an AST, which is actually a HashMap of NodeIndex chains.

The NodeIndex is calculated in the process of parsing.

let node_index = graph.add_node(MyNode::new(paras));

The error handling mechanism is to backup the previously successful code. Once there is an error during the parsing or node creation, backup code will be used.

This brings an issue that if there is an error in the halfway, half of the graph will be modified. And we need to create a new graph (using the old backup code) to replace this half-processed graph. This is really redundant.

Therefore, skipping some middleware like Enum of Glicol nodes is actually missing the big picture.

Such a mechanism should be changed, and perhaps switching to nom parser as the error handling of nom can be more promising.

Update:

chaosprint commented 2 years ago

So far it looks quite stable. But there is some error handling details. For example, when there is an error in the second half of the code, code in the first half will still take effect in some ways, e.g. send an update msg to the sequencer.