Skip to content
This repository has been archived by the owner on Apr 10, 2023. It is now read-only.

Use Instaparse #45

Open
ghalestrilo opened this issue Jan 18, 2021 · 3 comments
Open

Use Instaparse #45

ghalestrilo opened this issue Jan 18, 2021 · 3 comments
Labels
core Stuff seg can't go without

Comments

@ghalestrilo
Copy link
Owner

Instaparse is a parsing lib that seems perfect for this project. Among other benefits, it may allow plugins to be completely declarative and decoupled from the engine, which is pretty much the point of seg.

Investigate using it

@ghalestrilo
Copy link
Owner Author

The feature/instaparse branch is now an effort on this. I'm considering using tupelo forest for manipulating syntax trees more easily.

After spending a day sketching ebnfs, this is the solution I'm considering:

  1. Each plugin has:
  • A .yaml file, containing info like the "boot" command, pre- and post- command tokens, post-section tokens (useful for foxdot), etc.
  • An .ebnf file, containing its syntax for Instaparse.
  1. Once loading the file, seg loads the appropriate plugin.
  2. Once the plugin is loaded, seg parses the track on hiccup format, using the :unhidden true flag. This is necesary
  • If it's too hard to use this tree for displaying data, load an additional :unhidden false copy of the track for display, and duplicate all changes across both.
  • Using tupelo.tree, seg finds the core elements of the track (section, channel, variables, effects, pattern and parameters)
  1. seg queries the tree, to find the channels.
  2. seg queries the tree for :pattern nodes to build the pattern bank

For small editions (like changing variable values etc):

  1. Change editor shortcut to S-e and let e for small edition.
  2. Create a function that concatenates tree leaf content onto a string. We'll use this to output commands to the repl and to save the file (!!!)
  3. Small-editing a section/pattern/part does the following
  • "unparse" the node - could be a :section, :variable, :string, etc. depending on what you're editing. Store the node type.
  • open the small editor popup
  • on pressing enter or "S-enter", parse the output string using the :start-rule flag with the current node type
  • replace node with new content.

@ghalestrilo ghalestrilo added the core Stuff seg can't go without label Jan 19, 2021
@ghalestrilo
Copy link
Owner Author

@ghalestrilo
Copy link
Owner Author

Just thought of a different (maybe more efficient) approach for better language parsing - using actual js-based parsers.

The problem would then be to make self-contained little parsing modules that return similarly-shaped data

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
core Stuff seg can't go without
Projects
None yet
Development

No branches or pull requests

1 participant