glicol icon indicating copy to clipboard operation
glicol copied to clipboard

Possibility of integrating Tidal PEG for pattern syntax?

Open jarmitage opened this issue 4 years ago • 2 comments

What are the author's thoughts on introducing a pattern syntax such as tidal.pegjs? https://github.com/gibber-cc/tidal.pegjs

Would this require porting the above to Pest.rs?

jarmitage avatar Jan 28 '21 16:01 jarmitage

This would be an interesting feature to add. I can see several usages in Glicol immediately: aa: seq '[0 [1 2]*4 <5 6 7> 8]' >> sp \bd or aa: sound 'bd [bd ~] ~ bd*4' But since Glicol has its own philosophy on syntax, of which one prominent feature is to have no pair symbols, it is better to only have a minimal modification to the glicol.pest file when adding new features. For instance, we can only add an one-line rule of Tidal:

tidalpattern = { "\'" ~ ANY* ~ "\'" } // pseudo pest code

Similar to how Gibber mixes in mini-Tidal, the best solution is to create an individual Rust crate for doing the same job as the example you mentioned in Rust:

use tidalcycles::pattern_to_event;
let event = pattern_to_event("bd ~".to_string());

Then in nodes like seq or sp, these patterns can be parsed in the node constructing process. This Tidal crate can be created with pest.rs or other tools, and can be reused in other projects.

chaosprint avatar Jan 29 '21 11:01 chaosprint

Another possibility here would be to build an OSC bridge with Tidal or Strudel or Vortex.

All of the above also show more ideas for how to implement pattern parsers for inspiration to make a Rust-based parser.

On the Rust side, these look interesting:

  • https://github.com/pest-parser/pest / https://pest.rs/
  • https://github.com/jleahred/dynparser
    • Dynamic parser. You can define parsing rules with a peg format
    • A small and simple Dynamic Parser. It's not a compile time parser.
    • You can create and modify the grammar on runtime.
  • https://github.com/siberianbluerobin/bulk-examples-generator generate examples based on Pest above

Edit: closed by accident 😅

jarmitage avatar Apr 09 '22 19:04 jarmitage