Closed Gbury closed 1 year ago
Okay so, I replaced the Plain
statement with an Other
statement which is a bit more general and should make it easier to access the original name of the statement.
Note that originally/before this PR, the only producer of Plain
statements was the TPTP parser. With this PR, smtlib extensions can also produce such statements (well now it's called Other
).
This PR adds a new concept to the smtlib2 parser: extensions. Basically, extensions are sets of new statements that are allowed. For instance the
maxsmt
extension allows statements such asminimize
andmaximize
. By default, no extension is active/allowed, and thedolmen
binary will (at least for now) discourage the use of extensions, however, users of the library will be able to accept any new statement they might want to try.Statements accepted as part of an extension basically take a list of s-expr as payload, and it is up to the users to decide what to do with them. There are two points of control of extensions for users:
Dolmen_std.Extensions.Smtlib2.create
. Once active, such an extension will make the parser accept the corresponding statements, and these statements will appear asplain
statements, annotated with a term that stores the name of the original statement, and with a single s-expr as payload (that single s-exprs wraps the list of s-exprs into a single term)Ext
module when instantiating the parser. This basically means writing a functionf : string -> (term list -> statement) option
. That functionf
is first called when the parser sees a statement(foo ...)
wherefoo
is not one of the official smtlib2 statement. Iff
returnsNone
, then everything proceeds as "normal", i.e. the statement is rejected with a syntax error. Iff
returnsSome g
then g is then called with the list of parsed s-exprs as arguments. This makes it so that the parser can still generate parsing errors as early as possible on non-allowed statements.Note: the payloads of
Plain
statements for extensions are s-expr, and not smtlib2 terms of sorts. The functionssexpr_as_term
andsexpr_as_sort
from theDolmen_type.Core.Smtlib2
module may be used to easily recover parsed expressions that can then easily be typechecked.cc @bclement-ocp