Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree felling for SPPF #97

Open
stevefan1999-personal opened this issue Oct 15, 2023 · 1 comment
Open

Tree felling for SPPF #97

stevefan1999-personal opened this issue Oct 15, 2023 · 1 comment

Comments

@stevefan1999-personal
Copy link
Contributor

For #96, we need to delete invalid tree in case if current node is illegal for now and obviously in the future (hence felling a tree -- We generate a bunch of spanning trees from SPPF and then we fell the ones that are illegal)

@stevefan1999-personal
Copy link
Contributor Author

API design draft:

pub fn visit_sppf_version_node(node: SppfNodeVersion, visitor: &Box<dyn SppfVisitor>) -> Result<(), Error>

pub fn visit_sppf_node(node: SppfNode, visitor: &Box<dyn SppfVisitor>, mut universes: Vec<Result<Box<dyn SppfVisitor>, Error>>)

pub fn visit_sppf(result: &ParseResult<SppfImpl>, visitor: &Box<dyn SppfVisitor>) -> Vec<Result<Box<dyn SppfVisitor>, Error>>

/// SPPF Visitor interface
#[allow(unused_variables)]
pub trait SppfVisitor: DynClone {
    // Same for variables and virtualls
    fn on_terminal_identifier(&self, node: &SppfNodeVersion) -> Result<(), Error> {}

visit_sppf_version_node verifies if the action is valid or not

visit_sppf_node will fork visitor on each node version, calls visit_sppf_version_node and push back the visitor to universes if the result is not error (otherwise drop the visitor and push error instead)

visit_sppf initialize universes and return all possible results. 

Technically speaking, if there are more than 2 results in visit_sppf, then the whole program must be ambiguously defined as well (both syntactically and semantically).

TODO:

  1. Take care about any potential edge case for visit_sppf_node (1 version case is not defined?)
  2. Ergonomics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant