Skip to content
This repository was archived by the owner on Dec 1, 2022. It is now read-only.

WIP: Support parsing theories#40

Open
djrenren wants to merge 1 commit intofacebookarchive:mainfrom
djrenren:smt_theories
Open

WIP: Support parsing theories#40
djrenren wants to merge 1 commit intofacebookarchive:mainfrom
djrenren:smt_theories

Conversation

@djrenren
Copy link

Hi, I wanted to take a crack at getting theory parsing working to fix #15.

Before I went to the trouble of implementing all the parser rules and concrete syntax types, I wanted to validate the approach I'm taking.

Basically it amounts to:

  • Parser returns an enum ParseResult which could be either a Command or a Theory. (currently, no modesetting is done, we rely on upstream consumers like CommandStream, to provide errors if the parser returns an unexpected result)
  • Extend SmtVisitor with TheoryVisitor. I'm not sure I like this because I imagine there are a lot of tools that will only operate on Commands and not on Theorys but it seemed the least invasive choice. I would welcome some guidance on this point.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 21, 2021
Copy link

@ma2bd ma2bd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @djrenren. I just saw your PR. Sorry for the delay. This looks like a great start! I left a few comments.

%type sort_decs Vec<(T::Symbol, crate::Numeral)>;

%start_symbol command;
%start_symbol mode;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps input or start instead of mode ?

mode ::= theory(td) { ParseResult::Theory(td) }
}

pub enum ParseResult<C, T> {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable. (Need inline doc comment for public API though :))
In full generality, we could pass an artificial input token to signal what we expect but this is not even needed here since there is no ambiguity.

fn parsing_error(&mut self, position: crate::Position, s: String) -> Self::Error;
}

/// A visitor for the entire SMT2 syntax.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix comment

return match parser.end_of_input() {
Ok((command, _)) => Some(Ok(command)),
Ok((ParseResult::Command(command), _)) => Some(Ok(command)),
Ok((ParseResult::Theory(res), _)) => unimplemented!(),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this will return an error value here, obviously.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[smt2parser] add parsing rules for SMT2 theories and logics

3 participants