diff --git a/NEWS b/NEWS index a521ca07..9ece5e14 100755 --- a/NEWS +++ b/NEWS @@ -1,4 +1,21 @@ -Overview of Changes in alpha153 +Overview of Changes in alpha154 +============================================ +* conventions for printing spaces around unparsed tokens made +uniform +* fixed bug where set print const with sorts on . did not work +for built-in constants in terms +* new with-sorts PrintOption constant +* added metaPrintToString() descent function +* added printToString() message +* metaPrettyPrint() descent function supports concealed +argument lists via an extra argument +* printTerm() message supports concealed argument lists via an +extra argument +* concealed argument lists support for printing terms in modules +* fixed bug where color for terms in modules produces bad LaTeX +* fixed bug in LaTeX for disambiguation of iter operators + +Overview of Changes in alpha153 (2023-11-07) ============================================ * smarter sort disambiguation for printing statements and operator identities diff --git a/configure b/configure index 4c099520..fac2835d 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for Maude alpha153. +# Generated by GNU Autoconf 2.69 for Maude alpha154. # # Report bugs to . # @@ -580,8 +580,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='Maude' PACKAGE_TARNAME='maude' -PACKAGE_VERSION='alpha153' -PACKAGE_STRING='Maude alpha153' +PACKAGE_VERSION='alpha154' +PACKAGE_STRING='Maude alpha154' PACKAGE_BUGREPORT='maude-bugs@lists.cs.illinois.edu' PACKAGE_URL='' @@ -1312,7 +1312,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Maude alpha153 to adapt to many kinds of systems. +\`configure' configures Maude alpha154 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1383,7 +1383,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Maude alpha153:";; + short | recursive ) echo "Configuration of Maude alpha154:";; esac cat <<\_ACEOF @@ -1490,7 +1490,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -Maude configure alpha153 +Maude configure alpha154 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2013,7 +2013,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Maude $as_me alpha153, which was +It was created by Maude $as_me alpha154, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2962,7 +2962,7 @@ fi # Define the identity of the package. PACKAGE='maude' - VERSION='alpha153' + VERSION='alpha154' cat >>confdefs.h <<_ACEOF @@ -6623,7 +6623,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by Maude $as_me alpha153, which was +This file was extended by Maude $as_me alpha154, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6689,7 +6689,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -Maude config.status alpha153 +Maude config.status alpha154 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index d540c81c..252e6c88 100755 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ # # Initialize autoconf stuff. # -AC_INIT(Maude, alpha153, [maude-bugs@lists.cs.illinois.edu]) +AC_INIT(Maude, alpha154, [maude-bugs@lists.cs.illinois.edu]) # # Allow directory names that look like macros. # diff --git a/doc/Makefile.am b/doc/Makefile.am index 99996674..cda6cab1 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -21,4 +21,5 @@ EXTRA_DIST = \ alpha150.txt \ alpha151.txt \ alpha152.txt \ - alpha153.txt + alpha153.txt \ + alpha154.txt diff --git a/doc/Makefile.in b/doc/Makefile.in index babab2a8..893fb7ec 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -253,7 +253,8 @@ EXTRA_DIST = \ alpha150.txt \ alpha151.txt \ alpha152.txt \ - alpha153.txt + alpha153.txt \ + alpha154.txt all: all-am diff --git a/doc/alpha153.txt b/doc/alpha153.txt index 6c96cf8e..1b77d75a 100644 --- a/doc/alpha153.txt +++ b/doc/alpha153.txt @@ -61,7 +61,7 @@ or equivalently Note that as this shows the unparsed module, hooks, identity terms, membership axioms, equations, rules, and strategy definitions are just bubbles of tokens which are printed using the \maudeRaw{} command which uses -the typewritter font. +the typewriter font. Also parameterized sorts and constants in renamings in module expressions are just printed using the naive \maudeSort{} rather than as a structured name with \maudeParameter{} and \maudeView{} since they haven't been evaluated @@ -90,13 +90,13 @@ in both text and LaTeX. Note that as this shows the view module, terms on either side of op to term mappings and strategy expressions on either side of strat to expr mappings are just bubbles of tokens which are printed using the \maudeRaw{} -command which uses the typewritter font. +command which uses the typewriter font. (7) There is a new command set print combine vars on/off . which controls whether each variable alias is printed on its own line or whether variable aliases with the same sort are combined in a -single declaration. This flag is supported for show desugares/all vars +single declaration. This flag is supported for show desugared/all vars The default is off for backward compatibility. Other changes @@ -120,7 +120,7 @@ Here, previously, each occurrence of 0 required disambiguation. Now the right hand sides of =, => and := are assumed to have a known kind based on the left hand side, while the left hand side of : is assumed to have a known kind base on the sort in the rhs so none of -the occurrences of 0 recieve sort disambiguation. +the occurrences of 0 receive sort disambiguation. (2) A similar change to the printing of operator identities since the range kind will always be defined by the operator. @@ -178,7 +178,7 @@ objects contain a portal was merely to avoid the degenerate case of a lone object waiting for a reply from an external object, which would not be received because object-message rewriting and external object interaction is special behavior that is attached to the -configuration contructor +configuration constructor op __ : Configuration Configuration -> Configuration [ctor config assoc comm id: none] . With a portal present, this operator will always appear at the top of a configuration that communicates with external objects. @@ -198,7 +198,7 @@ in different configurations that have the same Oid and as long as only one such configuration has a portal, messages from external objects will not be misdelivered. This requirement arises with nested configurations where the outer configuration manages communication -between external objects and objects in the inner configurarion and +between external objects and objects in the inner configuration and objects in both configurations share Oids. In this case only the outer configuration would have a portal and would be able to communicate directly with external objects. @@ -247,9 +247,3 @@ and before the single character tokens ) ] } in mixfix syntax. This greatly reduces the overfull \hbox issue and approximates the line breaking rules used by the line wrapper in the text case. - -(11) In LaTeX output only for show all/desugared/ops, backquotes are not shown -in op-hooks (they haven't been shown in op declarations for a while). I'm -considering making this the convention for text output in the future, for -both op-hooks and op declarations but there are some subtle cases for reparsing -output. diff --git a/doc/alpha154.txt b/doc/alpha154.txt new file mode 100644 index 00000000..ab1c1f33 --- /dev/null +++ b/doc/alpha154.txt @@ -0,0 +1,115 @@ +Alpha 154 release notes +======================== + +Bug fixes +========== + +(1) The command + set print const with sorts on . +introduced alpha 126 released 11/22/2019 was implemented for all +kinds of constants when printing dag nodes but only regular constants +and not built-in constants when printing terms. This shows up in the +following example: + +fmod FOO is inc NAT . + eq 0 = 0 . + eq 1 = 1 . +endfm + +set print const with sorts on . + +show desugared . + +Here 0 is a regular constant but 1 is a special constant that is really +s 0. This omission is now fixed. + +(2) A bug where colors generated for operators with various attributes +generated bad LaTeX when printed as in terms: + +fmod FOO is + sort Foo . + op foo : Foo Foo -> Foo [assoc comm] . + op bar : Foo Foo -> Foo [assoc] . + ops a b c : -> Foo . + eq foo(a, b) = bar(c, c) . +endfm + +set print color on . + +show desugared FOO . + +Here the terminal color sequence was being used rather than the LaTeX one. + +(3) A very obscure bug where sort disambiguation of iter symbols used +the wrong font for the sort. Triggered by this rather dubious example: + +fmod FOO is + sort Foo . + op s : Foo -> Foo [iter] . + op 0 : -> Foo . + sort Bar . + op s^2 : Foo -> Bar . + eq s(s(0)) = 0 . +endfm + +show desugared . + +New features +============= + +(1) There is a new constant + op with-sorts : -> PrintOption [ctor] . +in META-LEVEL that is the metalevel equivalent of + set print const with sorts on . +i.e. each constant in the printed term will have sort disambiguation. + +(2) There is a new descent function + op metaPrintToString : Module VariableSet Term PrintOptionSet QidSet ~> String [special (...)] . +that works like metaPrettyPrint() except that it prints to a string. +Here the final argument is a set of operator names whose arguments +should be concealed. There is no PrintOption constant for the print +concealed flag - it is implicitly assumed to be true if the QidSet is +non-empty. + +(3) The meta-interpreter has a new pair of messages + op printTermToString : Oid Oid Qid VariableSet Term PrintOptionSet QidSet -> Msg [ctor msg format (b o)] . + op printedTermToString : Oid Oid String -> Msg [ctor msg format (m o)] . +that provide similar functionality for meta-interpreter objects. + +Other changes +============== + +(1) The printTokens() function in fmod LEXICAL now prints space in front +of ( [ { unless the previous token was ( [ { + +(2) Printing of raw tokens for unparsed statements and identities with +show module now print space in front of ( unless the previous token was +( [ {. This was already done for [ {. This change is for both text and +LaTeX output. + +(3) The descent function metaPrettyPrint() now takes an extra QidSet +argument to indicate which operators should have the arguments concealed. + + op metaPrettyPrint : Module VariableSet Term PrintOptionSet Qid ~> QidList [special (...)] . + +For backward compatibility there is also: + + op metaPrettyPrint : Module VariableSet Term PrintOptionSet ~> QidList . + eq metaPrettyPrint(M:Module, VS:VariableSet, T:Term, P:PrintOptionSet) = + metaPrettyPrint(M:Module, VS:VariableSet, T:Term, P:PrintOptionSet, none) . + +(4) The meta-interpreter message printTerm() now takes an extra QidSet +argument to indicate which operators should have the arguments concealed. + + op printTerm : Oid Oid Qid VariableSet Term PrintOptionSet QidSet -> Msg [ctor msg format (b o)] . + +For backward compatibility there is also: + + op printTerm : Oid Oid Qid VariableSet Term PrintOptionSet -> Msg [ctor msg format (b o)] . + eq printTerm(T:Oid, M:Oid, Q:Qid, VS:VariableSet, T:Term, P:PrintOptionSet) = + printTerm(T:Oid, M:Oid, Q:Qid, VS:VariableSet, T:Term, P:PrintOptionSet, none) . + +(5) Printing of terms (as opposed to dags) such as in modules, now supports + set print conceal on . +for both text and LaTeX output. Previously this only worked for dags. + diff --git a/src/Main/ChangeLog b/src/Main/ChangeLog index 2e91b732..f89babed 100755 --- a/src/Main/ChangeLog +++ b/src/Main/ChangeLog @@ -1,3 +1,27 @@ +2023-11-22 Steven Eker + + * metaInterpreter.maude: added printTermToString, printedTermToString + messages + printTerm message now takes a conseal symbols argument; added backward + compatibility symbol + + * prelude.maude: metaPrettyPrint() now takes a final QidSet argument for + conceal symbols; added backward compatibility definition + +2023-11-21 Steven Eker + + * prelude.maude: added constant with-sorts of sort PrintOption + in META-LEVEL + added descent function + metaPrintToString : Module VariableSet Term PrintOptionSet Qid ~> String + +2023-11-16 Steven Eker + + * main.cc (main): Interpreter::PRINT_MIXFIX -> + PrintSettings::PRINT_MIXFIX + +===================================Maude154=========================================== + 2023-11-06 Steven Eker * maude.sty: added \maudeAllowLineBreak and use it for \maudeComma diff --git a/src/Main/main.cc b/src/Main/main.cc index d3d08cea..aacbfa5b 100755 --- a/src/Main/main.cc +++ b/src/Main/main.cc @@ -125,7 +125,7 @@ main(int argc, char* argv[]) else if (strcmp(arg, "--version") == 0) printVersion(); else if (strcmp(arg, "-no-mixfix") == 0) - interpreter.setPrintFlag(Interpreter::PRINT_MIXFIX, false); + interpreter.setPrintFlag(PrintSettings::PRINT_MIXFIX, false); else if (strcmp(arg, "-ansi-color") == 0) ansiColor = true; else if (strcmp(arg, "-no-ansi-color") == 0) diff --git a/src/Main/metaInterpreter.maude b/src/Main/metaInterpreter.maude index e2f72760..3a90c769 100644 --- a/src/Main/metaInterpreter.maude +++ b/src/Main/metaInterpreter.maude @@ -2,7 +2,7 @@ This file is part of the Maude 3 interpreter. - Copyright 2009-2020 SRI International, Menlo Park, CA 94025, USA. + Copyright 2009-2023 SRI International, Menlo Park, CA 94025, USA. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ *** *** Maude meta-interpreters. -*** Version 3.2. +*** Version alpha154 *** mod META-INTERPRETER is @@ -54,9 +54,12 @@ mod META-INTERPRETER is op showView : Oid Oid Qid -> Msg [ctor msg format (b o)] . op showingView : Oid Oid View -> Msg [ctor msg format (m o)] . - op printTerm : Oid Oid Qid VariableSet Term PrintOptionSet -> Msg [ctor msg format (b o)] . + op printTerm : Oid Oid Qid VariableSet Term PrintOptionSet QidSet -> Msg [ctor msg format (b o)] . op printedTerm : Oid Oid QidList -> Msg [ctor msg format (m o)] . + op printTermToString : Oid Oid Qid VariableSet Term PrintOptionSet QidSet -> Msg [ctor msg format (b o)] . + op printedTermToString : Oid Oid String -> Msg [ctor msg format (m o)] . + op parseTerm : Oid Oid Qid VariableSet QidList Type? -> Msg [ctor msg format (b o)] . op parsedTerm : Oid Oid ResultPair? -> Msg [ctor msg format (m o)] . @@ -185,8 +188,10 @@ mod META-INTERPRETER is op-hook showViewMsg (showView : Oid Oid Qid ~> Msg) op-hook showingViewMsg (showingView : Oid Oid View ~> Msg) - op-hook printTermMsg (printTerm : Oid Oid Qid VariableSet Term PrintOptionSet ~> Msg) + op-hook printTermMsg (printTerm : Oid Oid Qid VariableSet Term PrintOptionSet QidSet ~> Msg) op-hook printedTermMsg (printedTerm : Oid Oid QidList ~> Msg) + op-hook printTermToStringMsg (printTermToString : Oid Oid Qid VariableSet Term PrintOptionSet QidSet ~> Msg) + op-hook printedTermToStringMsg (printedTermToString : Oid Oid String ~> Msg) op-hook parseTermMsg (parseTerm : Oid Oid Qid VariableSet QidList Type? ~> Msg) op-hook parsedTermMsg (parsedTerm : Oid Oid ResultPair? ~> Msg) @@ -278,8 +283,11 @@ mod META-INTERPRETER is *** For backward compatibility only. *** These operators are deprecated - do not use in new code. *** - op getVariantUnifier : Oid Oid Qid UnificationProblem TermList Qid - Nat -> Msg [ctor msg format (b o)] . + op printTerm : Oid Oid Qid VariableSet Term PrintOptionSet -> Msg [ctor msg format (b o)] . + eq printTerm(T:Oid, M:Oid, Q:Qid, VS:VariableSet, T:Term, P:PrintOptionSet) = + printTerm(T:Oid, M:Oid, Q:Qid, VS:VariableSet, T:Term, P:PrintOptionSet, none) . + + op getVariantUnifier : Oid Oid Qid UnificationProblem TermList Qid Nat -> Msg [ctor msg format (b o)] . eq getVariantUnifier(T:Oid, M:Oid, Q:Qid, U:UnificationProblem, TL:TermList, F:Qid, N:Nat) = getVariantUnifier(T:Oid, M:Oid, Q:Qid, U:UnificationProblem, TL:TermList, F:Qid, none, N:Nat) . diff --git a/src/Main/prelude.maude b/src/Main/prelude.maude index 8d962aba..c054eff7 100644 --- a/src/Main/prelude.maude +++ b/src/Main/prelude.maude @@ -22,7 +22,7 @@ *** *** Maude interpreter standard prelude. -*** Version alpha153. +*** Version alpha154. *** *** Some of the overall structure is taken from the OBJ3 *** interpreter standard prelude. @@ -2166,7 +2166,7 @@ fmod META-LEVEL is *** options for metaPrettyPrint() sorts PrintOption PrintOptionSet . subsort PrintOption < PrintOptionSet . - ops mixfix with-parens flat format number rat : -> PrintOption [ctor] . + ops mixfix with-parens with-sorts flat format number rat : -> PrintOption [ctor] . op none : -> PrintOptionSet [ctor] . op __ : PrintOptionSet PrintOptionSet -> PrintOptionSet [ctor assoc comm id: none] . @@ -2684,6 +2684,7 @@ fmod META-LEVEL is op-hook mixfixSymbol (mixfix : ~> PrintOption) op-hook withParensSymbol (with-parens : ~> PrintOption) + op-hook withSortsSymbol (with-sorts : ~> PrintOption) op-hook flatSymbol (flat : ~> PrintOption) op-hook formatPrintOptionSymbol (format : ~> PrintOption) op-hook numberSymbol (number : ~> PrintOption) @@ -2874,11 +2875,16 @@ fmod META-LEVEL is id-hook MetaLevelOpSymbol (metaParse) op-hook shareWith (metaReduce : Module Term ~> ResultPair))] . - op metaPrettyPrint : Module VariableSet Term PrintOptionSet ~> QidList + op metaPrettyPrint : Module VariableSet Term PrintOptionSet Qid ~> QidList [special ( id-hook MetaLevelOpSymbol (metaPrettyPrint) op-hook shareWith (metaReduce : Module Term ~> ResultPair))] . + op metaPrintToString : Module VariableSet Term PrintOptionSet Qid ~> String + [special ( + id-hook MetaLevelOpSymbol (metaPrintToString) + op-hook shareWith (metaReduce : Module Term ~> ResultPair))] . + op metaCheck : Module Term ~> Bool [special ( id-hook MetaLevelOpSymbol (metaCheck) @@ -3009,13 +3015,17 @@ fmod META-LEVEL is eq metaParse(M:Module, Q:QidList, T:Type?) = metaParse(M:Module, none, Q:QidList, T:Type?) . + op metaPrettyPrint : Module VariableSet Term PrintOptionSet ~> QidList . + eq metaPrettyPrint(M:Module, VS:VariableSet, T:Term, P:PrintOptionSet) = + metaPrettyPrint(M:Module, VS:VariableSet, T:Term, P:PrintOptionSet, none) . + op metaPrettyPrint : Module Term PrintOptionSet ~> QidList . eq metaPrettyPrint(M:Module, T:Term, P:PrintOptionSet) = - metaPrettyPrint(M:Module, none, T:Term, P:PrintOptionSet) . + metaPrettyPrint(M:Module, none, T:Term, P:PrintOptionSet, none) . op metaPrettyPrint : Module Term ~> QidList . eq metaPrettyPrint(M:Module, T:Term) = - metaPrettyPrint(M:Module, none, T:Term, mixfix flat format number rat) . + metaPrettyPrint(M:Module, none, T:Term, mixfix flat format number rat, none) . op metaVariantUnify : Module UnificationProblem TermList Qid Nat ~> UnificationPair? . eq metaVariantUnify(M:Module, U:UnificationProblem, TL:TermList, Q:Qid, N:Nat) = diff --git a/src/Meta/ChangeLog b/src/Meta/ChangeLog index 584ee554..c6ca500d 100644 --- a/src/Meta/ChangeLog +++ b/src/Meta/ChangeLog @@ -1,3 +1,88 @@ +2023-11-29 Steven Eker + + * descentFunctions.cc (MetaLevelOpSymbol::metaPrintToString): + set PrintSettings::PRINT_WITH_ALIASES if we have a non-empty + aliasMap + +2023-11-22 Steven Eker + + * interpreterSignature.cc: printTermMsg now takes 7 + arguments + + * miSyntax.cc (InterpreterManagerSymbol::printTerm): handle + conceal symbols + + * interpreterManagerSymbol.hh + (class InterpreterManagerSymbol): added decl for + printTermToString() + + * remoteInterpreter2.cc + (InterpreterManagerSymbol::handleMessage): added + printTermToStringMsg + + * miSyntax.cc (InterpreterManagerSymbol::printTermToString): + added + + * interpreterSignature.cc: added printTermToStringMsg, + printedTermToStringMsg + + * descentSignature.cc: metaPrettyPrint operator now takes + 5 arguments + + * descentFunctions.cc (MetaLevelOpSymbol::metaPrettyPrint): + support conceal symbols + + * metaLevel.hh (class MetaLevel): added decl for + downConcealedSet() + + * metaDown.cc (MetaLevel::downConcealedSet): added + + * descentFunctions.cc (MetaLevelOpSymbol::metaPrintToString): + handle concealSymbols + +2023-11-21 Steven Eker + + * metaLevel.hh (MetaLevel::upString): use new Rope ctor + + * descentSignature.cc: added metaPrintToString + + * descentFunctions.cc (MetaLevelOpSymbol::metaPrintToString): + added + + * metaLevel.hh (MetaLevel::upString): added + + * metaLevelSignature.cc: added withSortsSymbol + + * metaDown.cc (MetaLevel::downPrintOption): handle + withSortsSymbol + +2023-11-20 Steven Eker + + * metaLevel.hh (class MetaLevel): update decl for + downPrintOption() + + * metaDown.cc (MetaLevel::downPrintOptionSet): take and pass + PrintSettings + + * miSyntax.cc (InterpreterManagerSymbol::printTerm): use + PrintSettings + + * descentFunctions.cc (MetaLevelOpSymbol::metaPrettyPrintStrategy): + use PrintSettings + (MetaLevelOpSymbol::metaPrettyPrint): use PrintSettings + + * metaLevel.hh (class MetaLevel): updated decl for + downPrintOptionSet() + + * metaDown.cc (MetaLevel::downPrintOption): use PrintSettings + +2023-11-16 Steven Eker + + * metaDown.cc (MetaLevel::downPrintOption): Interpreter:: -> + PrintSettings:: + +===================================Maude154=========================================== + 2023-11-02 Steven Eker * metaDownOps.cc (MetaLevel::downAttr): down portal attributes diff --git a/src/Meta/descentFunctions.cc b/src/Meta/descentFunctions.cc index ec9802b6..f3782606 100644 --- a/src/Meta/descentFunctions.cc +++ b/src/Meta/descentFunctions.cc @@ -524,33 +524,36 @@ MetaLevelOpSymbol::metaParse(FreeDagNode* subject, RewritingContext& context) bool MetaLevelOpSymbol::metaPrettyPrint(FreeDagNode* subject, RewritingContext& context) { - int printFlags; - if (metaLevel->downPrintOptionSet(subject->getArgument(3), printFlags)) + PrintSettings printSettings; + if (metaLevel->downPrintOptionSet(subject->getArgument(3), printSettings)) { - if (MetaModule* m = metaLevel->downModule(subject->getArgument(0))) + if (metaLevel->downConcealedSet(subject->getArgument(4), printSettings)) { - MixfixModule::AliasMap aliasMap; - if (metaLevel->downVariableDeclSet(subject->getArgument(1), aliasMap, m)) + if (MetaModule* m = metaLevel->downModule(subject->getArgument(0))) { - if (Term* t = metaLevel->downTerm(subject->getArgument(2), m)) + MixfixModule::AliasMap aliasMap; + if (metaLevel->downVariableDeclSet(subject->getArgument(1), aliasMap, m)) { - // - // Swap in our alias map and a null parser. - // - MixfixParser* parser = 0; - m->swapVariableAliasMap(aliasMap, parser); - // - // Do the pretty print. - // - Vector buffer; - m->bufferPrint(buffer, t, printFlags); - // - // Restore original alias map and parser. - // - m->swapVariableAliasMap(aliasMap, parser); - - t->deepSelfDestruct(); - return context.builtInReplace(subject, metaLevel->upQidList(buffer)); + if (Term* t = metaLevel->downTerm(subject->getArgument(2), m)) + { + // + // Swap in our alias map and a null parser. + // + MixfixParser* parser = 0; + m->swapVariableAliasMap(aliasMap, parser); + // + // Do the pretty print. + // + Vector buffer; + m->bufferPrint(buffer, t, printSettings); + // + // Restore original alias map and parser. + // + m->swapVariableAliasMap(aliasMap, parser); + + t->deepSelfDestruct(); + return context.builtInReplace(subject, metaLevel->upQidList(buffer)); + } } } } @@ -558,6 +561,48 @@ MetaLevelOpSymbol::metaPrettyPrint(FreeDagNode* subject, RewritingContext& conte return false; } +bool +MetaLevelOpSymbol::metaPrintToString(FreeDagNode* subject, RewritingContext& context) +{ + PrintSettings printSettings; + if (metaLevel->downPrintOptionSet(subject->getArgument(3), printSettings)) + { + if (metaLevel->downConcealedSet(subject->getArgument(4), printSettings)) + { + if (MetaModule* m = metaLevel->downModule(subject->getArgument(0))) + { + MixfixModule::AliasMap aliasMap; + if (metaLevel->downVariableDeclSet(subject->getArgument(1), aliasMap, m)) + { + if (Term* t = metaLevel->downTerm(subject->getArgument(2), m)) + { + // + // Swap in our alias map and a null parser. + // + MixfixParser* parser = 0; + m->swapVariableAliasMap(aliasMap, parser); + if (!aliasMap.empty()) + printSettings.setPrintFlag(PrintSettings::PRINT_WITH_ALIASES); + // + // Do the pretty print. + // + stringstream buffer; + m->prettyPrint(buffer, printSettings, t, UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); + // + // Restore original alias map and parser. + // + m->swapVariableAliasMap(aliasMap, parser); + + t->deepSelfDestruct(); + return context.builtInReplace(subject, metaLevel->upString(buffer.str())); + } + } + } + } + } + return false; +} + bool MetaLevelOpSymbol::metaUpTerm(FreeDagNode* subject, RewritingContext& context) { @@ -687,8 +732,8 @@ MetaLevelOpSymbol::metaParseStrategy(FreeDagNode* subject, RewritingContext& con bool MetaLevelOpSymbol::metaPrettyPrintStrategy(FreeDagNode* subject, RewritingContext& context) { - int printFlags; - if (metaLevel->downPrintOptionSet(subject->getArgument(3), printFlags)) + PrintSettings printSettings; + if (metaLevel->downPrintOptionSet(subject->getArgument(3), printSettings)) { if (MixfixModule* m = metaLevel->downModule(subject->getArgument(0))) { @@ -706,7 +751,7 @@ MetaLevelOpSymbol::metaPrettyPrintStrategy(FreeDagNode* subject, RewritingContex // Do the pretty print. // Vector buffer; - m->bufferPrint(buffer, e, printFlags); + m->bufferPrint(buffer, e, printSettings); // // Restore original alias map and parser. // diff --git a/src/Meta/descentSignature.cc b/src/Meta/descentSignature.cc index 6cb52dc9..bf868646 100644 --- a/src/Meta/descentSignature.cc +++ b/src/Meta/descentSignature.cc @@ -56,7 +56,7 @@ MACRO(metaLeastSort, 2) MACRO(metaCompleteName, 2) MACRO(metaParse, 4) - MACRO(metaPrettyPrint, 4) + MACRO(metaPrettyPrint, 5) MACRO(metaWellFormedModule, 1) MACRO(metaWellFormedTerm, 2) MACRO(metaGetKind, 2) @@ -86,6 +86,7 @@ MACRO(metaSrewrite, 5) MACRO(metaParseStrategy, 3) MACRO(metaPrettyPrintStrategy, 4) + MACRO(metaPrintToString, 5) // // Legacy descent functions. // diff --git a/src/Meta/interpreterManagerSymbol.cc b/src/Meta/interpreterManagerSymbol.cc index 83979905..cd636363 100644 --- a/src/Meta/interpreterManagerSymbol.cc +++ b/src/Meta/interpreterManagerSymbol.cc @@ -25,6 +25,7 @@ // #include #include +#include // utility stuff #include "macros.hh" diff --git a/src/Meta/interpreterManagerSymbol.hh b/src/Meta/interpreterManagerSymbol.hh index bb99c8f8..b1ec109b 100644 --- a/src/Meta/interpreterManagerSymbol.hh +++ b/src/Meta/interpreterManagerSymbol.hh @@ -239,6 +239,9 @@ private: DagNode* printTerm(FreeDagNode* message, ObjectSystemRewritingContext& context, Interpreter* interpreter); + DagNode* printTermToString(FreeDagNode* message, + ObjectSystemRewritingContext& context, + Interpreter* interpreter); DagNode* parseTerm(FreeDagNode* message, ObjectSystemRewritingContext& context, Interpreter* interpreter); diff --git a/src/Meta/interpreterSignature.cc b/src/Meta/interpreterSignature.cc index 10485034..92adc128 100644 --- a/src/Meta/interpreterSignature.cc +++ b/src/Meta/interpreterSignature.cc @@ -2,7 +2,7 @@ This file is part of the Maude 3 interpreter. - Copyright 1997-2020 SRI International, Menlo Park, CA 94025, USA. + Copyright 1997-2023 SRI International, Menlo Park, CA 94025, USA. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -42,8 +42,10 @@ MACRO(insertedViewMsg, FreeSymbol, 2) MACRO(showViewMsg, FreeSymbol, 3) MACRO(showingViewMsg, FreeSymbol, 3) - MACRO(printTermMsg, FreeSymbol, 6) + MACRO(printTermMsg, FreeSymbol, 7) MACRO(printedTermMsg, FreeSymbol, 3) + MACRO(printTermToStringMsg, FreeSymbol, 7) + MACRO(printedTermToStringMsg, FreeSymbol, 3) MACRO(parseTermMsg, FreeSymbol, 6) MACRO(parsedTermMsg, FreeSymbol, 3) MACRO(getLesserSortsMsg, FreeSymbol, 4) diff --git a/src/Meta/metaDown.cc b/src/Meta/metaDown.cc index 35c17422..58d8fb23 100644 --- a/src/Meta/metaDown.cc +++ b/src/Meta/metaDown.cc @@ -476,6 +476,33 @@ MetaLevel::downQidSet(DagNode* metaQidSet, Vector& ids) return true; } +bool +MetaLevel::downConcealedSet(DagNode* metaQidSet, PrintSettings& printSettings) +{ + // + // Also sets PRINT_CONCEAL flag if set is non-emty. + // + Symbol* mq = metaQidSet->symbol(); + int id; + if (mq == qidSetSymbol) + { + for (DagArgumentIterator i(metaQidSet); i.valid(); i.next()) + { + if (!downQid(i.argument(), id)) + return false; + printSettings.insertConcealed(id); + } + } + else if (mq == emptyQidSetSymbol) + return true; + else if (downQid(metaQidSet, id)) + printSettings.insertConcealed(id); + else + return false; + printSettings.setPrintFlag(PrintSettings::PRINT_CONCEAL); + return true; +} + bool MetaLevel::downTypeList(DagNode* metaTypeList, MixfixModule* m, Vector& typeList) { @@ -1490,39 +1517,40 @@ MetaLevel::downAssignment(DagNode* metaAssignment, } bool -MetaLevel::downPrintOptionSet(DagNode* metaPrintOptionSet, int& printFlags) const +MetaLevel::downPrintOptionSet(DagNode* metaPrintOptionSet, PrintSettings& printSettings) const { - printFlags = 0; Symbol* mp = metaPrintOptionSet->symbol(); if (mp == printOptionSetSymbol) { for (DagArgumentIterator i(metaPrintOptionSet); i.valid(); i.next()) { - if (!downPrintOption(i.argument(), printFlags)) + if (!downPrintOption(i.argument(), printSettings)) return false; } } else if (mp != emptyPrintOptionSetSymbol) - return downPrintOption(metaPrintOptionSet, printFlags); + return downPrintOption(metaPrintOptionSet, printSettings); return true; } bool -MetaLevel::downPrintOption(DagNode* metaPrintOption, int& printFlags) const +MetaLevel::downPrintOption(DagNode* metaPrintOption, PrintSettings& printSettings) const { Symbol* mp = metaPrintOption->symbol(); if (mp == mixfixSymbol) - printFlags |= Interpreter::PRINT_MIXFIX; + printSettings.setPrintFlag(PrintSettings::PRINT_MIXFIX); else if (mp == withParensSymbol) - printFlags |= Interpreter::PRINT_WITH_PARENS; + printSettings.setPrintFlag(PrintSettings::PRINT_WITH_PARENS); + else if (mp == withSortsSymbol) + printSettings.setPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST); else if (mp == flatSymbol) - printFlags |= Interpreter::PRINT_FLAT; + printSettings.setPrintFlag(PrintSettings::PRINT_FLAT); else if (mp == formatPrintOptionSymbol) - printFlags |= Interpreter::PRINT_FORMAT; + printSettings.setPrintFlag(PrintSettings::PRINT_FORMAT); else if (mp == numberSymbol) - printFlags |= Interpreter::PRINT_NUMBER; + printSettings.setPrintFlag(PrintSettings::PRINT_NUMBER); else if (mp == ratSymbol) - printFlags |= Interpreter::PRINT_RAT; + printSettings.setPrintFlag(PrintSettings::PRINT_RAT); else return false; return true; diff --git a/src/Meta/metaLevel.hh b/src/Meta/metaLevel.hh index b3ee141f..062362d2 100644 --- a/src/Meta/metaLevel.hh +++ b/src/Meta/metaLevel.hh @@ -25,12 +25,14 @@ // #ifndef _metaLevel_hh_ #define _metaLevel_hh_ +#include "rope.hh" #include "cachedDag.hh" #include "metaModuleCache.hh" #include "succSymbol.hh" #include "sequenceSearch.hh" #include "variantSearch.hh" #include "variantUnificationProblem.hh" +#include "stringDagNode.hh" class MetaLevel { @@ -73,6 +75,7 @@ public: RewritingContext& context); DagNode* upNat(const mpz_class& nat); + DagNode* upString(const string& str); DagNode* upNoParent() const; DagNode* upResultPair(DagNode* dagNode, MixfixModule* m); DagNode* upResultPair(Term* term, MixfixModule* m); @@ -271,7 +274,7 @@ public: bool downSaturate(DagNode* metaBound, int& bound) const; bool downBound64(DagNode* metaBound, Int64& bound) const; bool downSaturate64(DagNode* metaBound, Int64& bound) const; - bool downPrintOptionSet(DagNode* metaPrintOptionSet, int& printFlags) const; + bool downPrintOptionSet(DagNode* metaPrintOptionSet, PrintSettings& printSettings) const; bool downVariantOptionSet(DagNode* metaVariantOptionSet, int& variantFlags) const; bool downSrewriteOption(DagNode* metaSrewriteOption, bool& depthFirst) const; bool downBool(DagNode* metaBool, bool& value); @@ -328,6 +331,7 @@ public: bool downType2(int id, MixfixModule* m, Sort*& type) const; bool downQidList(DagNode* metaQidList, Vector& ids); bool downQidSet(DagNode* metaQidSet, Vector& ids); + bool downConcealedSet(DagNode* metaQidSet, PrintSettings& printSettings); bool downTypeList(DagNode* metaTypeList, MixfixModule* m, Vector& typeList); bool downTypeSet(DagNode* metaTypeSet, MixfixModule* m, Vector& typeSet); bool downComponent(DagNode* metaComponent, @@ -577,7 +581,7 @@ private: Symbol* topSymbol, int& bubbleSpecIndex); - bool downPrintOption(DagNode* metaPrintOption, int& printFlags) const; + bool downPrintOption(DagNode* metaPrintOption, PrintSettings& printSettings) const; bool downVariantOption(DagNode* metaVariantOption, int& variantFlags) const; bool downVariableDecl(DagNode* metaVariableDecl, MixfixModule::AliasMap& aliasMap, MixfixModule* m) const; @@ -780,4 +784,10 @@ MetaLevel::downFoldType(DagNode* arg, bool& foldType) return false; } +inline DagNode* +MetaLevel::upString(const string& str) +{ + return new StringDagNode(stringSymbol, Rope(str)); +} + #endif diff --git a/src/Meta/metaLevelOpSymbol.cc b/src/Meta/metaLevelOpSymbol.cc index 56d8d1a6..fcc17496 100644 --- a/src/Meta/metaLevelOpSymbol.cc +++ b/src/Meta/metaLevelOpSymbol.cc @@ -23,6 +23,7 @@ // // Implementation for class MetaLevelOpSymbol. // +#include // utility stuff #include "macros.hh" diff --git a/src/Meta/metaLevelSignature.cc b/src/Meta/metaLevelSignature.cc index 85829dcc..f0b8fed2 100644 --- a/src/Meta/metaLevelSignature.cc +++ b/src/Meta/metaLevelSignature.cc @@ -342,6 +342,7 @@ // MACRO(mixfixSymbol, Symbol, 0, 0) MACRO(withParensSymbol, Symbol, 0, 0) + MACRO(withSortsSymbol, Symbol, 0, 0) MACRO(flatSymbol, Symbol, 0, 0) MACRO(formatPrintOptionSymbol, Symbol, 0, 0) MACRO(numberSymbol, Symbol, 0, 0) diff --git a/src/Meta/miSyntax.cc b/src/Meta/miSyntax.cc index 10f47690..6961ea9a 100644 --- a/src/Meta/miSyntax.cc +++ b/src/Meta/miSyntax.cc @@ -2,7 +2,7 @@ This file is part of the Maude 3 interpreter. - Copyright 2020 SRI International, Menlo Park, CA 94025, USA. + Copyright 2023 SRI International, Menlo Park, CA 94025, USA. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ */ // -// MetaInterpreters: printTerm() and parseTerm() messages. +// MetaInterpreters: printTerm(), printTermToString and parseTerm() messages. // DagNode* @@ -30,47 +30,108 @@ InterpreterManagerSymbol::printTerm(FreeDagNode* message, Interpreter* interpreter) { // - // op printTerm : Oid Oid Qid VariableSet Term PrintOptionSet -> Msg . - // 0 1 2 3 4 5 + // op printTerm : Oid Oid Qid VariableSet Term PrintOptionSet QidSet -> Msg . + // 0 1 2 3 4 5 6 // DagNode* errorMessage; if (MetaModule* mm = getMetaModule(message, 2, interpreter, errorMessage)) { - int printFlags; - if (metaLevel->downPrintOptionSet(message->getArgument(5), printFlags)) + PrintSettings printSettings; + if (metaLevel->downPrintOptionSet(message->getArgument(5), printSettings)) { - MixfixModule::AliasMap aliasMap; - if (metaLevel->downVariableDeclSet(message->getArgument(3), aliasMap, mm)) + if (metaLevel->downConcealedSet(message->getArgument(6), printSettings)) { - if (Term* t = metaLevel->downTerm(message->getArgument(4), mm)) + MixfixModule::AliasMap aliasMap; + if (metaLevel->downVariableDeclSet(message->getArgument(3), aliasMap, mm)) { - // - // Swap in our alias map and a null parser. - // - MixfixParser* parser = 0; - mm->swapVariableAliasMap(aliasMap, parser); - // - // Do the pretty print. - // - Vector buffer; - mm->bufferPrint(buffer, t, printFlags); - t->deepSelfDestruct(); - // - // Restore original alias map and parser. - // - mm->swapVariableAliasMap(aliasMap, parser); - // - // Assemble the reply. - // - Vector reply(3); - reply[0] = message->getArgument(1); - reply[1] = message->getArgument(0); - reply[2] = metaLevel->upQidList(buffer); - return printedTermMsg->makeDagNode(reply); + if (Term* t = metaLevel->downTerm(message->getArgument(4), mm)) + { + // + // Swap in our alias map and a null parser. + // + MixfixParser* parser = 0; + mm->swapVariableAliasMap(aliasMap, parser); + // + // Do the pretty print. + // + Vector buffer; + mm->bufferPrint(buffer, t, printSettings); + t->deepSelfDestruct(); + // + // Restore original alias map and parser. + // + mm->swapVariableAliasMap(aliasMap, parser); + // + // Assemble the reply. + // + Vector reply(3); + reply[0] = message->getArgument(1); + reply[1] = message->getArgument(0); + reply[2] = metaLevel->upQidList(buffer); + return printedTermMsg->makeDagNode(reply); + } + return makeErrorReply("Bad term.", message); + } + return makeErrorReply("Bad variable declarations.", message); + } + return makeErrorReply("Bad concealed set.", message); + } + return makeErrorReply("Bad option.", message); + } + return errorMessage; +} + +DagNode* +InterpreterManagerSymbol::printTermToString(FreeDagNode* message, + ObjectSystemRewritingContext& context, + Interpreter* interpreter) +{ + // + // op printTerm : Oid Oid Qid VariableSet Term PrintOptionSet QidSet -> Msg . + // 0 1 2 3 4 5 6 + // + DagNode* errorMessage; + if (MetaModule* mm = getMetaModule(message, 2, interpreter, errorMessage)) + { + PrintSettings printSettings; + if (metaLevel->downPrintOptionSet(message->getArgument(5), printSettings)) + { + if (metaLevel->downConcealedSet(message->getArgument(6), printSettings)) + { + MixfixModule::AliasMap aliasMap; + if (metaLevel->downVariableDeclSet(message->getArgument(3), aliasMap, mm)) + { + if (Term* t = metaLevel->downTerm(message->getArgument(4), mm)) + { + // + // Swap in our alias map and a null parser. + // + MixfixParser* parser = 0; + mm->swapVariableAliasMap(aliasMap, parser); + // + // Do the pretty print. + // + stringstream buffer; + mm->prettyPrint(buffer, printSettings, t, UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); + t->deepSelfDestruct(); + // + // Restore original alias map and parser. + // + mm->swapVariableAliasMap(aliasMap, parser); + // + // Assemble the reply. + // + Vector reply(3); + reply[0] = message->getArgument(1); + reply[1] = message->getArgument(0); + reply[2] = metaLevel->upString(buffer.str()); + return printedTermToStringMsg->makeDagNode(reply); + } + return makeErrorReply("Bad term.", message); } - return makeErrorReply("Bad term.", message); + return makeErrorReply("Bad variable declarations.", message); } - return makeErrorReply("Bad variable declarations.", message); + return makeErrorReply("Bad concealed set.", message); } return makeErrorReply("Bad option.", message); } diff --git a/src/Meta/remoteInterpreter2.cc b/src/Meta/remoteInterpreter2.cc index b9464081..dae3ab30 100644 --- a/src/Meta/remoteInterpreter2.cc +++ b/src/Meta/remoteInterpreter2.cc @@ -229,6 +229,8 @@ InterpreterManagerSymbol::handleMessage(FreeDagNode* message, // else if (s == printTermMsg) return printTerm(message, context, interpreter); + else if (s == printTermToStringMsg) + return printTermToString(message, context, interpreter); else if (s == parseTermMsg) return parseTerm(message, context, interpreter); // diff --git a/src/Mixfix/ChangeLog b/src/Mixfix/ChangeLog index 500b3952..c88ea294 100644 --- a/src/Mixfix/ChangeLog +++ b/src/Mixfix/ChangeLog @@ -1,3 +1,487 @@ +2023-11-29 Steven Eker + + * mixfixModule.hh (class MixfixModule): updated decl for + graphPrint() + + * prettyPrint.cc (MixfixModule::prettyPrint): pass printSettings + to graphPrint() + + * graphPrint.cc (MixfixModule::graphPrint): take and pass + printSettings + + * mixfixModule.hh (class MixfixModule): updated decls for + printVariable(), Term* and DagNode* to ostream& versions + of handleVariable() + + * dagNodePrint.cc (MixfixModule::handleVariable): take + printSettings and pass to printVariable() + (MixfixModule::prettyPrint): pass printSettings to + handleVariable() + + * termPrint.cc (MixfixModule::handleVariable): take printSettings + and pass to printVariable() + (MixfixModule::prettyPrint): pass printSettings to + handleVariable() + + * prettyPrint.cc (MixfixModule::printPrefixName): use + printSettings rather than interpreter + (MixfixModule::printVariable): take and use printSettings + + * mixfixModule.hh (class MixfixModule): updated decls for + handleIter(), handleMinus(), handleDivision(), handleFloat(), + handleString(),handleQuotedIdentifier(), handleVariable(), + handleSMT_Number() + + * termPrint.cc (MixfixModule::prettyPrint): use prefix() + + * latexTermPrint.cc (MixfixModule::latexPrettyPrint): fix bug + where we left (...) in code when in inserted latex version + + * termPrint.cc (MixfixModule::handleIter): don't take, use or pass + color + (MixfixModule::handleMinus): don't take or pass color + (MixfixModule::handleDivision): ditto + (MixfixModule::handleFloat): ditto + (MixfixModule::handleString): ditto + (MixfixModule::handleQuotedIdentifier): ditto + (MixfixModule::handleVariable): ditto + (MixfixModule::handleSMT_Number): ditto + (MixfixModule::prettyPrint): don't pass color to handleIter(), + handleMinus(), handleDivision(), handleFloat(), handleString(), + handleQuotedIdentifier(), handleVariable(), handleSMT_Number() + + * mixfixModule.hh (class MixfixModule): updated decl for Term* to + ostream& suffix() + (class MixfixModule): color = nullptr default argument for ostream& + prefix() + + * termPrint.cc (MixfixModule::suffix): get rid of color argument + +2023-11-28 Steven Eker + + * sharedPrint.cc (MixfixModule::disambiguatorSort): moved here + + * termPrint.cc (MixfixModule::computeColor): code cleaning + + * latexTermPrint.cc (MixfixModule::latexPrettyPrint): use + latexPrefix() + + * mixfixModule.hh (class MixfixModule): updated decls for the + Term* versions of latexSuffix(), latexHandleIter(), + latexHandleMinus(), latexHandleDivision(), latexHandleFloat(), + latexHandleString(), latexHandleQuotedIdentifier(), + latexHandleVariable(),latexHandleSMT_Number() + + * latexTermPrint.cc (MixfixModule::latexSuffix): don't take color + argument + (MixfixModule::latexHandleIter): don't take, use or pass color + argument + (MixfixModule::latexHandleIter): use latexPrefix; fix bug where + we were using suffix rather than latexSuffix + (MixfixModule::latexHandleMinus): don't take or pass color + (MixfixModule::latexHandleDivision): ditto + (MixfixModule::latexHandleFloat): ditto + (MixfixModule::latexHandleString): ditto + (MixfixModule::latexHandleQuotedIdentifier): ditto + (MixfixModule::latexHandleVariable): ditto + (MixfixModule::latexHandleSMT_Number): ditto + (MixfixModule::latexPrettyPrint): don't pass color + + * mixfixModule.hh (class MixfixModule): latexPrefix() now has + default color argument + + * latexDagNodePrint.cc (MixfixModule::latexPrettyPrint): get + rid of unneccessary Mixfix:: qualification + (MixfixModule::latexPrintDagNode): ditto + + * mixfixModule.hh (class MixfixModule): updated decls for + latexPrintPrefixName(), latexPrintTokens(), latexPrintTails(), + latexFancySpace() + + * latexTermPrint.cc (MixfixModule::latexHandleIter): + pass printSettings to latexPrintPrefixName() + (MixfixModule::latexPrettyPrint): pass printSettings to + latexPrintPrefixName(), latexPrintTokens(), latexPrintTails() + + * latexDagNodePrint.cc (MixfixModule::latexHandleIter): + pass printSettings to latexPrintPrefixName() + (MixfixModule::latexPrettyPrint): pass printSettings to + latexPrintPrefixName(), latexPrintTokens(), latexPrintTails() + + * latexCommon.cc (MixfixModule::latexFancySpace): take + and use printSettings + (MixfixModule::latexPrintPrefixName): take, use and pass + printSettings + (MixfixModule::latexPrintTokens): ditto + (MixfixModule::latexPrintTails): ditto + Intepreter:: -> PrintSettings:: + + * mixfixModule.hh (class MixfixModule): updated decl for + Terms* version of latexHandleVariable() + + * latexTermPrint.cc (MixfixModule::latexHandleVariable): + take and use printSettings + (MixfixModule::latexPrettyPrint): pass printSettings to + latexHandleVariable() + + * mixfixModule.hh (class MixfixModule): updated decl for + DagNode* version of latexHandleVariable() + + * latexDagNodePrint.cc (MixfixModule::latexHandleVariable): + take and use printSettings + (MixfixModule::latexPrettyPrint): pass printSettings to + latexHandleVariable() + + * mixfixModule.hh (class MixfixModule): updated decls for + DagNode* versions of latexComputeColor(), latexHandleIter(), + latexHandleMinus(), latexHandleDivision(), latexHandleFloat(), + latexHandleString(), latexHandleQuotedIdentifier(), + latexHandleSMT_Number(), latexPrettyPrint() + + * latexDagNodePrint.cc: Intepreter:: -> PrintSettings:: + (MixfixModule::latexComputeColor): take and use printSettings + (MixfixModule::latexHandleIter): take, use and pass + printSettings + (MixfixModule::latexHandleMinus): take and use printSettings + (MixfixModule::latexHandleDivision): ditto + (MixfixModule::latexHandleFloat): ditto + (MixfixModule::latexHandleString): ditto + (MixfixModule::latexHandleQuotedIdentifier): ditto + (MixfixModule::latexHandleSMT_Number): ditto + (MixfixModule::latexPrettyPrint): take, use and + pass printSettings + (MixfixModule::latexPrettyPrint) + (MixfixModule::latexPrintDagNode): use clearIndent() + (MixfixModule::latexPrettyPrint) + (MixfixModule::latexPrintDagNode): pass printSettings + + * latexTermPrint.cc (MixfixModule::latexPrettyPrint): pass + printSettings to main latexPrettyPrint() call + + * mixfixModule.hh (class MixfixModule): updated decl for + Term* versions of latexHandleIter(), latexHandleMinus(), + latexHandleDivision(), latexHandleFloat(), latexHandleString(), + latexHandleQuotedIdentifier(), latexHandleSMT_Number(), + latexPrettyPrint() + + * latexTermPrint.cc (MixfixModule::latexHandleIter): take and + use printSettings; pass printSettings to latexPrettyPrint() + (MixfixModule::latexHandleMinus): take and use printSettings + (MixfixModule::latexHandleFloat): ditto + (MixfixModule::latexHandleString): ditto + (MixfixModule::latexHandleQuotedIdentifier): ditto + (MixfixModule::latexHandleSMT_Number): ditto + (MixfixModule::latexPrettyPrint): take and pass printSettings + + * mixfixModule.hh (class MixfixModule): updated decl for stream + version of printPrefixName() + (class MixfixModule): updated decl for fancySpace() + + * termPrint.cc (MixfixModule::prettyPrint): pass printSettings + to printPrefixName() + (MixfixModule::handleIter): ditto + + * dagNodePrint.cc (MixfixModule::handleIter): pass printSettings + to printPrefixName() + (MixfixModule::prettyPrint): ditto + + * prettyPrint.cc (MixfixModule::printPrefixName): take and pass + printSettings + + * mixfixModule.hh (class MixfixModule): updated decls for + stream versions of printTokens() and printTails() + + * dagNodePrint.cc (MixfixModule::prettyPrint): pass printSettings + to printTails() and printTokens() + + * termPrint.cc (MixfixModule::prettyPrint): pass printSettings + to printTails() and printTokens() + + * prettyPrint.cc (MixfixModule::fancySpace): take and use + printSettings + (MixfixModule::printTails): take, use and pass printSettings + (MixfixModule::printTokens): ditto + +2023-11-27 Steven Eker + + * mixfixModule.hh (class MixfixModule): updated decl for + latexComputeColor() + + * latexTermPrint.cc (MixfixModule::latexComputeColor): take + printSettings arg + (MixfixModule::latexPrettyPrint): use latexComputeColor rather + than computeColor() + + * latexDagNodePrint.cc (MixfixModule::latexPrettyPrint): + use \maudeEllipsis + + * latexTermPrint.cc: Interpreter:: -> PrintSettings:: + (MixfixModule::latexPrettyPrint): handle print conceal + + * termPrint.cc (MixfixModule::suffix): formatting + + * latexTermPrint.cc (MixfixModule::latexPrettyPrint): use + clearIndent() + + * mixfixModule.hh (class MixfixModule): unfriend DagNode* + operator<< + (class MixfixModule): made StrategyExpression* prettyPrint() + public + (class MixfixModule): unfriend StrategyExpression* operator<< + + * prettyPrint.cc: (operator<<): (DagNode* version), use + new MixfixModule::prettyPrint() + + * mixfixModule.hh (class MixfixModule): added decl for + 3 argument DagNode* prettyPrint() + + * prettyPrint.cc (MixfixModule::prettyPrint): use + clearIndent(), clearColor() + (operator<<): (DagNode* version), use clearIndent(), + clearColor() + (MixfixModule::prettyPrint): added 3 argument DagNode* + version + + * mixfixModule.hh (MixfixModule::clearIndent): added + (MixfixModule::clearColor): added + +2023-11-22 Steven Eker + + * bufferPrint.cc (MixfixModule::prettyPrint): support print + conceal + + * specialTokens.cc: added ellipsis + + * termPrint.cc (MixfixModule::prettyPrint): support print conceal + +2023-11-21 Steven Eker + + * mixfixModule.hh (class MixfixModule): make main Term* prettyPrint + public + +2023-11-20 Steven Eker + + * printSettings.hh (class PrintSettings): pass polarity = true + by default for setPrintFlag() + + * mixfixModule.hh (class MixfixModule): updated decls + for both versions of bufferPrint() + + * bufferPrint.cc (MixfixModule::bufferPrint): (StrategyExpression* + version): pass printSettings + (MixfixModule::bufferPrint): take printSettings (both versions) + + * mixfixModule.hh (class MixfixModule): updated decls + for all 3 functions used to print strategies to buffer + + * bufferPrint.cc (MixfixModule::prettyPrint): (StrategyExpression* + version): take and pass printSettings + (MixfixModule::prettyPrint): (Vector version): + take and pass printSettings + (MixfixModule::prettyPrint): (ConditionFragment* version): + take and pass printSettings + + * mixfixModule.hh (class MixfixModule): updated decls for + buffer versions of printTokens(), printTails(), printPrefixName() + + * bufferPrint.cc (MixfixModule::bufferPrint): pass printSettings + to prettyPrint() + + * mixfixModule.hh (class MixfixModule): updated decls for + buffer versions of suffix(), prettyPrint(), handleVariable(), + handleIter(), handleMinus(), handleDivision(), handleFloat(), + handleString(), handleQuotedIdentifier(), handleSMT_NumberSymbol(), + printKind(), printSort(), printDotSort(), printVarSort(), + printTokens(), printTails(), printPrefixName() + + * bufferPrint.cc (MixfixModule::handleIter): take + printSettings rather than printFlags + (MixfixModule::suffix): ditto + (MixfixModule::handleIter): ditto + (MixfixModule::handleMinus): ditto + (MixfixModule::handleDivision): ditto + (MixfixModule::handleFloat): ditto + (MixfixModule::handleString): ditto + (MixfixModule::handleQuotedIdentifier): ditto + (MixfixModule::handleVariable): ditto + (MixfixModule::handleSMT_NumberSymbol): ditto + (MixfixModule::prettyPrint): take, use and pass printSettings + (MixfixModule::printKind): take and pass printSettings + (MixfixModule::printSort): take printSettings + (MixfixModule::printDotSort): ditto + (MixfixModule::printVarSort): ditto + (MixfixModule::printTokens): ditto + (MixfixModule::printTails): ditto + (MixfixModule::printPrefixName): ditto + + * termPrint.cc (MixfixModule::handleIter): pass + printSettings to prettyPrint() + + * prettyPrint.cc (MixfixModule::prettyPrint): pass + printSettings to Term* -> ostream prettyPrint() + + * termPrint.cc (MixfixModule::prettyPrint): take + printSettings argument and pass it in recursive calls + + * mixfixModule.hh (class MixfixModule): updated decl + for Term* -> ostream prettyPrint() + + * latexTermPrint.cc (MixfixModule::latexPrettyPrint): pass + printSettings argument to computeColor() + + * termPrint.cc (MixfixModule::prettyPrint): pass printSettings + argument to computeColor(), handleIter(), handleMinus(), + handleDivision(), handleFloat(), handleString(), + handleQuotedIdentifier(), handleSMT_Number() + + * mixfixModule.hh (class MixfixModule): updated decls for Term* + versions of computeColor(), handleIter(), handleMinus(), + handleDivision(), handleFloat(), handleString(), + handleQuotedIdentifier(), handleSMT_Number() + + * termPrint.cc (MixfixModule::computeColor): take and + use printSettings argument + Interpreter:: -> PrintSettings:: everywhere + (MixfixModule::handleIter): take and use printSettings + argument + (MixfixModule::handleMinus): ditto + (MixfixModule::handleDivision): ditto + (MixfixModule::handleFloat): ditto + (MixfixModule::handleString): ditto + (MixfixModule::handleQuotedIdentifier): ditto + (MixfixModule::handleSMT_Number): ditto + +2023-11-17 Steven Eker + + * bufferPrint.cc: Interpreter:: -> PrintSettings:: + (MixfixModule::handleIter): handle + PrintSettings::PRINT_DISAMBIG_CONST + (MixfixModule::handleMinus): ditto + (MixfixModule::handleDivision): ditto + (MixfixModule::handleFloat): ditto + (MixfixModule::handleString): ditto + (MixfixModule::handleQuotedIdentifier): ditto + (MixfixModule::handleSMT_NumberSymbol): ditto + (MixfixModule::prettyPrint): made needDisambig, argRangeKnown + calculations symmetric with ostream& case + +2023-11-16 Steven Eker + + * latexTermPrint.cc (MixfixModule::latexHandleIter): + handle PrintSettings::PRINT_DISAMBIG_CONST + (MixfixModule::latexHandleMinus): ditto + (MixfixModule::latexHandleDivision): ditto + (MixfixModule::latexHandleFloat): ditto + (MixfixModule::latexHandleString): ditto + (MixfixModule::latexHandleQuotedIdentifier): ditto + (MixfixModule::latexHandleSMT_Number): ditto + + * termPrint.cc (MixfixModule::handleIter): handle + PrintSettings::PRINT_DISAMBIG_CONST + (MixfixModule::handleMinus): handle + PrintSettings::PRINT_DISAMBIG_CONST + (MixfixModule::handleDivision): handle + PrintSettings::PRINT_DISAMBIG_CONST + (MixfixModule::handleFloat): ditto + (MixfixModule::handleString): ditto + (MixfixModule::handleQuotedIdentifier): ditto + (MixfixModule::handleSMT_Number): ditto + +2023-11-15 Steven Eker + + * dagNodePrint.cc (MixfixModule::prettyPrint): use + printSettings.concealSymbol() + + * latexDagNodePrint.cc (MixfixModule::latexPrettyPrint): use + new printConceal() convention + + * interpreter.hh (class Interpreter): deleted decl for + concealedSymbol() + + * dagNodePrint.cc (MixfixModule::prettyPrint): use new + printConceal() convention + + * printSettings.hh (class PrintSettings): added data member + concealedSymbols + + * interpreter.hh (class Interpreter): deleted data member + concealedSymbols + + * interpreter.cc (Interpreter::concealedSymbol): deleted + (Interpreter::printConceal): moved here and use insertConcealed(), + eraseConcealed() + + * printSettings.hh (PrintSettings::insertConcealed) + (PrintSettings::eraseConcealed, PrintSettings::concealedSymbol): + added + + * prettyPrint.cc: Interpreter:: -> PrintSettings:: + (operator<<): pass printSettings to prettyPrint (DagNode* + version); use safeCastNonNull() + + * mixfixModule.hh (class MixfixModule): updated decl for + prettyPrint() (DagNode* version) + + * dagNodePrint.cc (MixfixModule::handleIter): pass + printSettings to prettyPrint() + (MixfixModule::prettyPrint): take printSettings argument + + * mixfixModule.hh (class MixfixModule): update decls for + handleFloat(), handleString(), handleQuotedIdentifier(), + handleIter(), handleMinus(), handleDivision(), + handleSMT_Number() + + * dagNodePrint.cc (MixfixModule::handleIter): take + printSettings argument + (MixfixModule::handleMinus): take printSettings argument + (MixfixModule::handleDivision): take printSettings argument + (MixfixModule::handleFloat): take printSettings argument + (MixfixModule::handleQuotedIdentifier): take printSettings + argument + (MixfixModule::handleString): take printSettings argument + (MixfixModule::handleSMT_Number): take printSettings argument + (MixfixModule::prettyPrint): pass printSettings to + computeColor(), handleIter(), handleMinus(), handleDivision(), + handleFloat(), handleString(), handleQuotedIdentifier(), + handleSMT_Number(); use printSettings + + * mixfixModule.hh (class MixfixModule): updated decl for + computeColor() (DagNode* version) + + * dagNodePrint.cc: Interpreter:: -> PrintSettings:: + (MixfixModule::handleVariable): remove hack + (MixfixModule::computeColor): take printSettings argument + + * commands.yy (kw_module): Interpreter:: -> PrintSettings:: + + * interpreter.cc (Interpreter::Interpreter): initialize + PrintSettings base rather than printFlags member + (Interpreter::setPrintFlag): deleted + + * mixfix.hh: added class PrintSettings + + * interpreter.hh (class Interpreter): derive from + PrintSettings; delete enum PrintFlags + (Interpreter::getPrintFlag): deleted + + * printSettings.hh (class PrintSettings): created + + * interpreter.hh (Interpreter::getPrintFlags): deleted + +2023-11-14 Steven Eker + + * latexPreModulePrint.cc + (SyntacticPreModule::latexTokenVector): symmetric change + + * token.cc (Token::printTokenVector): treat ( like [ { and + put space in front of it if needSpace + + * quotedIdentifierOpSymbol.cc + (QuotedIdentifierOpSymbol::printQid): put space before ( [ { + if needSpace true + +===================================Maude154=========================================== + 2023-11-07 Steven Eker * latexCommon.cc (MixfixModule::latexPrintTokens): use diff --git a/src/Mixfix/Makefile.am b/src/Mixfix/Makefile.am index af024f80..cf4e0825 100644 --- a/src/Mixfix/Makefile.am +++ b/src/Mixfix/Makefile.am @@ -246,4 +246,5 @@ noinst_HEADERS = \ parameterDatabase.hh \ objectConstructorSymbol.hh \ statementTransformer.hh \ - maudeLatexBuffer.hh + maudeLatexBuffer.hh \ + printSettings.hh diff --git a/src/Mixfix/Makefile.in b/src/Mixfix/Makefile.in index e59f1015..18920bed 100644 --- a/src/Mixfix/Makefile.in +++ b/src/Mixfix/Makefile.in @@ -605,7 +605,8 @@ noinst_HEADERS = \ parameterDatabase.hh \ objectConstructorSymbol.hh \ statementTransformer.hh \ - maudeLatexBuffer.hh + maudeLatexBuffer.hh \ + printSettings.hh all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am diff --git a/src/Mixfix/bufferPrint.cc b/src/Mixfix/bufferPrint.cc index eabe638e..aa2a7ea8 100644 --- a/src/Mixfix/bufferPrint.cc +++ b/src/Mixfix/bufferPrint.cc @@ -25,17 +25,17 @@ // void -MixfixModule::bufferPrint(Vector& buffer, Term* term, int printFlags) +MixfixModule::bufferPrint(Vector& buffer, Term* term, const PrintSettings& printSettings) { globalIndent = 0; // HACK - prettyPrint(buffer, term, UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false, printFlags); + prettyPrint(buffer, printSettings, term, UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); } void -MixfixModule::bufferPrint(Vector& buffer, StrategyExpression* expr, int printFlags) +MixfixModule::bufferPrint(Vector& buffer, StrategyExpression* expr, const PrintSettings& printSettings) { globalIndent = 0; // HACK - prettyPrint(buffer, expr, UNBOUNDED, printFlags); + prettyPrint(buffer, printSettings, expr, UNBOUNDED); } void @@ -46,7 +46,7 @@ MixfixModule::prefix(Vector& buffer, bool needDisambig) } void -MixfixModule::suffix(Vector& buffer, Term* term, bool needDisambig, int printFlags) +MixfixModule::suffix(Vector& buffer, Term* term, bool needDisambig, const PrintSettings& printSettings) { if (needDisambig) { @@ -58,58 +58,29 @@ MixfixModule::suffix(Vector& buffer, Term* term, bool needDisambig, int pri // // sortIndex will never be the index of a kind. // - printDotSort(buffer, symbol->rangeComponent()->sort(sortIndex), printFlags); + printDotSort(buffer, symbol->rangeComponent()->sort(sortIndex), printSettings); } } -void -MixfixModule::handleVariable(Vector& buffer, Term* term, int printFlags) -{ - VariableTerm* v = safeCast(VariableTerm*, term); - int id = v->id(); - Sort* sort = v->getSort(); - - AliasMap::const_iterator i = variableAliases.find(id); - if (i != variableAliases.end() && (*i).second == sort) - { - // - // Use just the base name alone. - // - buffer.append(id); - return; - } - // - // Construct the full name. - // - string fullName(Token::name(id)); - fullName += ':'; - if (sort->index() == Sort::KIND) - { - buffer.append(Token::encode(fullName.c_str())); - printKind(buffer, sort, printFlags); - } - else - printVarSort(buffer, fullName, sort, printFlags); -} - bool -MixfixModule::handleIter(Vector& buffer, Term* term, SymbolInfo& si, bool rangeKnown, int printFlags) +MixfixModule::handleIter(Vector& buffer, Term* term, SymbolInfo& si, bool rangeKnown, const PrintSettings& printSettings) { if (!(si.symbolType.hasFlag(SymbolType::ITER))) return false; if (si.symbolType.getBasicType() == SymbolType::SUCC_SYMBOL && - (printFlags & Interpreter::PRINT_NUMBER)) + printSettings.getPrintFlag(PrintSettings::PRINT_NUMBER)) { SuccSymbol* succSymbol = safeCast(SuccSymbol*, term->symbol()); if (succSymbol->isNat(term)) { const mpz_class& nat = succSymbol->getNat(term); - bool needDisambig = !rangeKnown && (kindsWithSucc.size() > 1 || overloadedIntegers.count(nat)); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (kindsWithSucc.size() > 1 || overloadedIntegers.count(nat))); prefix(buffer, needDisambig); char* name = mpz_get_str(0, 10, nat.get_mpz_t()); buffer.append(Token::encode(name)); free(name); - suffix(buffer, term, needDisambig, printFlags); + suffix(buffer, term, needDisambig, printSettings); return true; } } @@ -125,49 +96,51 @@ MixfixModule::handleIter(Vector& buffer, Term* term, SymbolInfo& si, bool r string prefixName; makeIterName(prefixName, term->symbol()->id(), number); - printPrefixName(buffer, Token::encode(prefixName.c_str()), si, printFlags); + printPrefixName(buffer, Token::encode(prefixName.c_str()), si, printSettings); buffer.append(leftParen); - prettyPrint(buffer, st->getArgument(), PREFIX_GATHER, UNBOUNDED, 0, UNBOUNDED, 0, argumentRangeKnown, printFlags); + prettyPrint(buffer, printSettings, st->getArgument(), PREFIX_GATHER, UNBOUNDED, 0, UNBOUNDED, 0, argumentRangeKnown); buffer.append(rightParen); - suffix(buffer, term, needToDisambiguate, printFlags); + suffix(buffer, term, needToDisambiguate, printSettings); return true; } bool -MixfixModule::handleMinus(Vector& buffer, Term* term, bool rangeKnown, int printFlags) +MixfixModule::handleMinus(Vector& buffer, Term* term, bool rangeKnown, const PrintSettings& printSettings) { - if (printFlags & Interpreter::PRINT_NUMBER) + if (printSettings.getPrintFlag(PrintSettings::PRINT_NUMBER)) { const MinusSymbol* minusSymbol = safeCast(MinusSymbol*, term->symbol()); if (minusSymbol->isNeg(term)) { mpz_class neg; (void) minusSymbol->getNeg(term, neg); - bool needDisambig = !rangeKnown && (kindsWithMinus.size() > 1 || overloadedIntegers.count(neg)); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (kindsWithMinus.size() > 1 || overloadedIntegers.count(neg))); prefix(buffer, needDisambig); char* name = mpz_get_str(0, 10, neg.get_mpz_t()); buffer.append(Token::encode(name)); free(name); - suffix(buffer, term, needDisambig, printFlags); + suffix(buffer, term, needDisambig, printSettings); return true; } } return false; } - + bool -MixfixModule::handleDivision(Vector& buffer, Term* term, bool rangeKnown, int printFlags) +MixfixModule::handleDivision(Vector& buffer, Term* term, bool rangeKnown, const PrintSettings& printSettings) { - if (printFlags & Interpreter::PRINT_RAT) + if (printSettings.getPrintFlag(PrintSettings::PRINT_RAT)) { const DivisionSymbol* divisionSymbol = safeCast(DivisionSymbol*, term->symbol()); if (divisionSymbol->isRat(term)) { pair rat; rat.second = divisionSymbol->getRat(term, rat.first); - bool needDisambig = !rangeKnown && (kindsWithDivision.size() > 1 || overloadedRationals.count(rat)); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (kindsWithDivision.size() > 1 || overloadedRationals.count(rat))); prefix(buffer, needDisambig); char* nn = mpz_get_str(0, 10, rat.first.get_mpz_t()); @@ -179,7 +152,7 @@ MixfixModule::handleDivision(Vector& buffer, Term* term, bool rangeKnown, i free(dn); buffer.append(Token::encode(prefixName.c_str())); - suffix(buffer, term, needDisambig, printFlags); + suffix(buffer, term, needDisambig, printSettings); return true; } } @@ -187,38 +160,71 @@ MixfixModule::handleDivision(Vector& buffer, Term* term, bool rangeKnown, i } void -MixfixModule::handleFloat(Vector& buffer, Term* term, bool rangeKnown, int printFlags) +MixfixModule::handleFloat(Vector& buffer, Term* term, bool rangeKnown, const PrintSettings& printSettings) { double mfValue = safeCast(FloatTerm*, term)->getValue(); - bool needDisambig = !rangeKnown && (floatSymbols.size() > 1 || overloadedFloats.count(mfValue)); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (floatSymbols.size() > 1 || overloadedFloats.count(mfValue))); prefix(buffer, needDisambig); buffer.append(Token::doubleToCode(mfValue)); - suffix(buffer, term, needDisambig, printFlags); + suffix(buffer, term, needDisambig, printSettings); } void -MixfixModule::handleString(Vector& buffer, Term* term, bool rangeKnown, int printFlags) +MixfixModule::handleString(Vector& buffer, Term* term, bool rangeKnown, const PrintSettings& printSettings) { string strValue; Token::ropeToString(safeCast(StringTerm*, term)->getValue(), strValue); - bool needDisambig = !rangeKnown && (stringSymbols.size() > 1 || overloadedStrings.count(strValue)); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (stringSymbols.size() > 1 || overloadedStrings.count(strValue))); prefix(buffer, needDisambig); buffer.append(Token::encode(strValue.c_str())); - suffix(buffer, term, needDisambig, printFlags); + suffix(buffer, term, needDisambig, printSettings); } void -MixfixModule::handleQuotedIdentifier(Vector& buffer, Term* term, bool rangeKnown, int printFlags) +MixfixModule::handleQuotedIdentifier(Vector& buffer, Term* term, bool rangeKnown, const PrintSettings& printSettings) { int qidCode = safeCast(QuotedIdentifierTerm*, term)->getIdIndex(); - bool needDisambig = !rangeKnown && (quotedIdentifierSymbols.size() > 1 || overloadedQuotedIdentifiers.count(qidCode)); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (quotedIdentifierSymbols.size() > 1 || overloadedQuotedIdentifiers.count(qidCode))); prefix(buffer, needDisambig); buffer.append(Token::quoteNameCode(qidCode)); - suffix(buffer, term, needDisambig, printFlags); + suffix(buffer, term, needDisambig, printSettings); } void -MixfixModule::handleSMT_NumberSymbol(Vector& buffer, Term* term, bool rangeKnown, int printFlags) +MixfixModule::handleVariable(Vector& buffer, Term* term, const PrintSettings& printSettings) +{ + VariableTerm* v = safeCast(VariableTerm*, term); + int id = v->id(); + Sort* sort = v->getSort(); + + AliasMap::const_iterator i = variableAliases.find(id); + if (i != variableAliases.end() && (*i).second == sort) + { + // + // Use just the base name alone. + // + buffer.append(id); + return; + } + // + // Construct the full name. + // + string fullName(Token::name(id)); + fullName += ':'; + if (sort->index() == Sort::KIND) + { + buffer.append(Token::encode(fullName.c_str())); + printKind(buffer, sort, printSettings); + } + else + printVarSort(buffer, fullName, sort, printSettings); +} + +void +MixfixModule::handleSMT_NumberSymbol(Vector& buffer, Term* term, bool rangeKnown, const PrintSettings& printSettings) { // // Get value. @@ -239,30 +245,31 @@ MixfixModule::handleSMT_NumberSymbol(Vector& buffer, Term* term, bool range if (t == SMT_Info::INTEGER) { const mpz_class& integer = value.get_num(); - needDisambig = !rangeKnown && (kindsWithSucc.size() > 1 || overloadedIntegers.count(integer)); + needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (kindsWithSucc.size() > 1 || overloadedIntegers.count(integer))); } else { Assert(t == SMT_Info::REAL, "SMT number sort expected"); pair rat(value.get_num(), value.get_den()); - needDisambig = !rangeKnown && (kindsWithDivision.size() > 1 || overloadedRationals.count(rat)); + needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (kindsWithDivision.size() > 1 || overloadedRationals.count(rat))); } - prefix(buffer, needDisambig); buffer.append(getSMT_NumberToken(value, sort)); - suffix(buffer, term, needDisambig, printFlags); + suffix(buffer, term, needDisambig, printSettings); } void MixfixModule::prettyPrint(Vector& buffer, + const PrintSettings& printSettings, Term* term, int requiredPrec, int leftCapture, const ConnectedComponent* leftCaptureComponent, int rightCapture, const ConnectedComponent* rightCaptureComponent, - bool rangeKnown, - int printFlags) + bool rangeKnown) { Symbol* symbol = term->symbol(); int index = symbol->getIndexWithinModule(); @@ -270,46 +277,46 @@ MixfixModule::prettyPrint(Vector& buffer, // // Check for special i/o representation. // - if (handleIter(buffer, term, si, rangeKnown, printFlags)) + if (handleIter(buffer, term, si, rangeKnown, printSettings)) return; int basicType = si.symbolType.getBasicType(); switch (basicType) { case SymbolType::MINUS_SYMBOL: { - if (handleMinus(buffer, term, rangeKnown, printFlags)) + if (handleMinus(buffer, term, rangeKnown, printSettings)) return; break; } case SymbolType::DIVISION_SYMBOL: { - if (handleDivision(buffer, term, rangeKnown, printFlags)) + if (handleDivision(buffer, term, rangeKnown, printSettings)) return; break; } case SymbolType::FLOAT: { - handleFloat(buffer, term, rangeKnown, printFlags); + handleFloat(buffer, term, rangeKnown, printSettings); return; } case SymbolType::STRING: { - handleString(buffer, term, rangeKnown, printFlags); + handleString(buffer, term, rangeKnown, printSettings); return; } case SymbolType::QUOTED_IDENTIFIER: { - handleQuotedIdentifier(buffer, term, rangeKnown, printFlags); + handleQuotedIdentifier(buffer, term, rangeKnown, printSettings); return; } case SymbolType::VARIABLE: { - handleVariable(buffer, term, printFlags); + handleVariable(buffer, term, printSettings); return; } case SymbolType::SMT_NUMBER_SYMBOL: { - handleSMT_NumberSymbol(buffer, term, rangeKnown, printFlags); + handleSMT_NumberSymbol(buffer, term, rangeKnown, printSettings); return; } default: @@ -318,16 +325,24 @@ MixfixModule::prettyPrint(Vector& buffer, int iflags = si.iflags; bool needDisambig = !rangeKnown && ambiguous(iflags); - bool argRangeKnown = rangeOfArgumentsKnown(iflags, rangeKnown, needDisambig); + bool argRangeKnown = false; int nrArgs = symbol->arity(); + if (nrArgs == 0) + { + if (printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST)) + needDisambig = true; + } + else + argRangeKnown = rangeOfArgumentsKnown(iflags, rangeKnown, needDisambig); prefix(buffer, needDisambig); - if (((printFlags & Interpreter::PRINT_MIXFIX) && !si.mixfixSyntax.empty()) || (basicType == SymbolType::SORT_TEST)) + bool printConceal = printSettings.concealedSymbol(symbol->id()); + if ((printSettings.getPrintFlag(PrintSettings::PRINT_MIXFIX) && !si.mixfixSyntax.empty() && !printConceal) || (basicType == SymbolType::SORT_TEST)) { // // Mixfix case. // - bool printWithParens = printFlags & Interpreter::PRINT_WITH_PARENS; + bool printWithParens = printSettings.getPrintFlag(PrintSettings::PRINT_WITH_PARENS); bool needParen = !needDisambig && (printWithParens || requiredPrec < si.prec || ((iflags & LEFT_BARE) && leftCapture <= si.gather[0] && @@ -349,14 +364,14 @@ MixfixModule::prettyPrint(Vector& buffer, Term* t = a.argument(); a.next(); moreArgs = a.valid(); - pos = printTokens(buffer, si, pos, printFlags); + pos = printTokens(buffer, si, pos, printSettings); if (arg == nrArgs - 1 && moreArgs) { ++nrTails; arg = 0; if (needAssocParen) buffer.append(leftParen); - pos = printTokens(buffer, si, 0, printFlags); + pos = printTokens(buffer, si, 0, printSettings); } int lc = UNBOUNDED; const ConnectedComponent* lcc = 0; @@ -382,9 +397,9 @@ MixfixModule::prettyPrint(Vector& buffer, rcc = rightCaptureComponent; } } - prettyPrint(buffer, t, si.gather[arg], lc, lcc, rc, rcc, argRangeKnown, printFlags); + prettyPrint(buffer, printSettings, t, si.gather[arg], lc, lcc, rc, rcc, argRangeKnown); } - printTails(buffer, si, pos, nrTails, needAssocParen, printFlags); + printTails(buffer, si, pos, nrTails, needAssocParen, printSettings); if (needParen) buffer.append(rightParen); } @@ -394,61 +409,67 @@ MixfixModule::prettyPrint(Vector& buffer, // Prefix case. // int id = symbol->id(); - printPrefixName(buffer, id, si, printFlags); + printPrefixName(buffer, id, si, printSettings); ArgumentIterator a(*term); if (a.valid()) { - int nrTails = 1; - buffer.append(leftParen); - for (int arg = 0;; arg++) + if (printConceal) { - Term* t = a.argument(); - a.next(); - int moreArgs = a.valid(); - if (arg >= nrArgs - 1 && - !(printFlags & Interpreter::PRINT_FLAT) && - moreArgs) + buffer.append(leftParen); + buffer.append(ellipsis); + buffer.append(rightParen); + } + else + { + int nrTails = 1; + buffer.append(leftParen); + for (int arg = 0;; arg++) { - ++nrTails; - printPrefixName(buffer, id, si, printFlags); - buffer.append(leftParen); + Term* t = a.argument(); + a.next(); + int moreArgs = a.valid(); + if (arg >= nrArgs - 1 && !printSettings.getPrintFlag(PrintSettings::PRINT_FLAT) && moreArgs) + { + ++nrTails; + printPrefixName(buffer, id, si, printSettings); + buffer.append(leftParen); + } + prettyPrint(buffer, printSettings, t, PREFIX_GATHER, UNBOUNDED, 0, UNBOUNDED, 0, argRangeKnown); + if (!moreArgs) + break; + buffer.append(comma); } - prettyPrint(buffer, t, PREFIX_GATHER, UNBOUNDED, 0, UNBOUNDED, 0, argRangeKnown, printFlags); - if (!moreArgs) - break; - buffer.append(comma); + while (nrTails-- > 0) + buffer.append(rightParen); } - while (nrTails-- > 0) - buffer.append(rightParen); } } - suffix(buffer, term, needDisambig, printFlags); + suffix(buffer, term, needDisambig, printSettings); } void -MixfixModule::printKind(Vector& buffer, const Sort* kind, int printFlags) +MixfixModule::printKind(Vector& buffer, const Sort* kind, const PrintSettings& printSettings) { Assert(kind != 0, "null kind"); ConnectedComponent* c = kind->component(); Assert(c != 0, "null conponent"); buffer.append(leftBracket); - printSort(buffer, c->sort(1), printFlags); + printSort(buffer, c->sort(1), printSettings); int nrMax = c->nrMaximalSorts(); for (int i = 2; i <= nrMax; i++) { buffer.append(comma); - printSort(buffer, c->sort(i), printFlags); + printSort(buffer, c->sort(i), printSettings); } buffer.append(rightBracket); } void -MixfixModule::printSort(Vector& buffer, const Sort* sort, int printFlags) +MixfixModule::printSort(Vector& buffer, const Sort* sort, const PrintSettings& printSettings) { int name = sort->id(); - if (Token::auxProperty(name) == Token::AUX_STRUCTURED_SORT && - interpreter.getPrintFlag(Interpreter::PRINT_MIXFIX)) + if (Token::auxProperty(name) == Token::AUX_STRUCTURED_SORT && printSettings.getPrintFlag(PrintSettings::PRINT_MIXFIX)) { Vector parts; Token::splitParameterizedSort(name, parts); @@ -460,11 +481,10 @@ MixfixModule::printSort(Vector& buffer, const Sort* sort, int printFlags) } void -MixfixModule::printDotSort(Vector& buffer, const Sort* sort, int printFlags) +MixfixModule::printDotSort(Vector& buffer, const Sort* sort, const PrintSettings& printSettings) { int name = sort->id(); - if (Token::auxProperty(name) == Token::AUX_STRUCTURED_SORT && - interpreter.getPrintFlag(Interpreter::PRINT_MIXFIX)) + if (Token::auxProperty(name) == Token::AUX_STRUCTURED_SORT && printSettings.getPrintFlag(PrintSettings::PRINT_MIXFIX)) { Vector parts; Token::splitParameterizedSort(name, parts); @@ -477,11 +497,10 @@ MixfixModule::printDotSort(Vector& buffer, const Sort* sort, int printFlags } void -MixfixModule::printVarSort(Vector& buffer, string& fullName, const Sort* sort, int printFlags) +MixfixModule::printVarSort(Vector& buffer, string& fullName, const Sort* sort, const PrintSettings& printSettings) { int name = sort->id(); - if (Token::auxProperty(name) == Token::AUX_STRUCTURED_SORT && - interpreter.getPrintFlag(Interpreter::PRINT_MIXFIX)) + if (Token::auxProperty(name) == Token::AUX_STRUCTURED_SORT && printSettings.getPrintFlag(PrintSettings::PRINT_MIXFIX)) { Vector parts; Token::splitParameterizedSort(name, parts); @@ -498,9 +517,9 @@ MixfixModule::printVarSort(Vector& buffer, string& fullName, const Sort* so } int -MixfixModule::printTokens(Vector& buffer, const SymbolInfo& si, int pos, int printFlags) +MixfixModule::printTokens(Vector& buffer, const SymbolInfo& si, int pos, const PrintSettings& printSettings) { - bool hasFormat = (printFlags & Interpreter::PRINT_FORMAT) && (si.format.length() > 0); + bool hasFormat = printSettings.getPrintFlag(PrintSettings::PRINT_FORMAT) && (si.format.length() > 0); for (;;) { int token = si.mixfixSyntax[pos++]; @@ -521,9 +540,9 @@ MixfixModule::printTails(Vector& buffer, int pos, int nrTails, bool needAssocParen, - int printFlags) + const PrintSettings& printSettings) { - bool hasFormat = (printFlags & Interpreter::PRINT_FORMAT) && (si.format.length() > 0); + bool hasFormat = printSettings.getPrintFlag(PrintSettings::PRINT_FORMAT) && (si.format.length() > 0); int mixfixLength = si.mixfixSyntax.length(); for (int i = 0;;) { @@ -543,9 +562,9 @@ MixfixModule::printTails(Vector& buffer, } void -MixfixModule::printPrefixName(Vector& buffer, int prefixName, SymbolInfo& si, int printFlags) +MixfixModule::printPrefixName(Vector& buffer, int prefixName, SymbolInfo& si, const PrintSettings& printSettings) { - if ((printFlags & Interpreter::PRINT_FORMAT) && (si.format.length() == 2)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_FORMAT) && si.format.length() == 2) { handleFormat(buffer, si.format[0]); buffer.append(prefixName); @@ -591,7 +610,7 @@ MixfixModule::handleFormat(Vector& buffer, int spaceToken) case 't': case 's': { - static char strg[3] = "\\!"; // HACK + static char strg[3] = "\\!"; // We replace the ! with *cmd strg[1] = *cmd; buffer.append(Token::encode(strg)); break; @@ -602,9 +621,9 @@ MixfixModule::handleFormat(Vector& buffer, int spaceToken) void MixfixModule::prettyPrint(Vector& buffer, + const PrintSettings& printSettings, StrategyExpression* expr, - int requiredPrec, - int printFlags) + int requiredPrec) { bool needParen = false; @@ -614,7 +633,7 @@ MixfixModule::prettyPrint(Vector& buffer, { buffer.append(one); buffer.append(leftParen); - prettyPrint(buffer, o->getStrategy(), UNBOUNDED, printFlags); + prettyPrint(buffer, printSettings, o->getStrategy(), UNBOUNDED); buffer.append(rightParen); } else if (ApplicationStrategy* a = dynamic_cast(expr)) @@ -639,9 +658,9 @@ MixfixModule::prettyPrint(Vector& buffer, int nrAssignements = variables.size(); for (int i = 0;;) { - prettyPrint(buffer, variables[i], UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false, printFlags); + prettyPrint(buffer, printSettings, variables[i], UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); buffer.append(assignment); - prettyPrint(buffer, values[i].getTerm(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false, printFlags); + prettyPrint(buffer, printSettings, values[i].getTerm(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); if (++i == nrAssignements) break; buffer.append(comma); @@ -655,7 +674,7 @@ MixfixModule::prettyPrint(Vector& buffer, int nrStrategies = strategies.size(); for (int i = 0;;) { - prettyPrint(buffer, strategies[i], UNBOUNDED, printFlags); + prettyPrint(buffer, printSettings, strategies[i], UNBOUNDED); if (++i == nrStrategies) break; buffer.append(comma); @@ -675,7 +694,7 @@ MixfixModule::prettyPrint(Vector& buffer, int nrStrategies = strategies.size(); for (int i = 0;;) { - prettyPrint(buffer, strategies[i], STRAT_SEQ_PREC, printFlags); + prettyPrint(buffer, printSettings, strategies[i], STRAT_SEQ_PREC); if (++i == nrStrategies) break; buffer.append(semicolon); @@ -690,7 +709,7 @@ MixfixModule::prettyPrint(Vector& buffer, int nrStrategies = strategies.size(); for (int i = 0;;) { - prettyPrint(buffer, strategies[i], STRAT_UNION_PREC, printFlags); + prettyPrint(buffer, printSettings, strategies[i], STRAT_UNION_PREC); if (++i == nrStrategies) break; buffer.append(pipe); @@ -698,7 +717,7 @@ MixfixModule::prettyPrint(Vector& buffer, } else if (IterationStrategy* i = dynamic_cast(expr)) { - prettyPrint(buffer, i->getStrategy(), 0, printFlags); + prettyPrint(buffer, printSettings, i->getStrategy(), 0); buffer.append(i->getZeroAllowed() ? star : plus); } else if (BranchStrategy* b = dynamic_cast(expr)) @@ -712,7 +731,7 @@ MixfixModule::prettyPrint(Vector& buffer, b->getFailureStrategy() == 0, "unknown branch strategy"); buffer.append(notToken); buffer.append(leftParen); - prettyPrint(buffer, b->getInitialStrategy(), UNBOUNDED, printFlags); + prettyPrint(buffer, printSettings, b->getInitialStrategy(), UNBOUNDED); buffer.append(rightParen); break; } @@ -723,7 +742,7 @@ MixfixModule::prettyPrint(Vector& buffer, b->getFailureStrategy() == 0, "unknown branch strategy"); buffer.append(test); buffer.append(leftParen); - prettyPrint(buffer, b->getInitialStrategy(), UNBOUNDED, printFlags); + prettyPrint(buffer, printSettings, b->getInitialStrategy(), UNBOUNDED); buffer.append(rightParen); break; } @@ -735,7 +754,7 @@ MixfixModule::prettyPrint(Vector& buffer, b->getFailureStrategy() == 0, "unknown branch strategy"); buffer.append(tryToken); buffer.append(leftParen); - prettyPrint(buffer, b->getInitialStrategy(), UNBOUNDED, printFlags); + prettyPrint(buffer, printSettings, b->getInitialStrategy(), UNBOUNDED); buffer.append(rightParen); } else @@ -745,9 +764,9 @@ MixfixModule::prettyPrint(Vector& buffer, needParen = requiredPrec < STRAT_ORELSE_PREC; if (needParen) buffer.append(leftParen); - prettyPrint(buffer, b->getInitialStrategy(), STRAT_ORELSE_PREC, printFlags); + prettyPrint(buffer, printSettings, b->getInitialStrategy(), STRAT_ORELSE_PREC); buffer.append(orelse); - prettyPrint(buffer, b->getFailureStrategy(), STRAT_ORELSE_PREC, printFlags); + prettyPrint(buffer, printSettings, b->getFailureStrategy(), STRAT_ORELSE_PREC); } break; } @@ -757,11 +776,11 @@ MixfixModule::prettyPrint(Vector& buffer, needParen = requiredPrec < STRAT_BRANCH_PREC; if (needParen) buffer.append(leftParen); - prettyPrint(buffer, b->getInitialStrategy(), STRAT_BRANCH_PREC, printFlags); + prettyPrint(buffer, printSettings, b->getInitialStrategy(), STRAT_BRANCH_PREC); buffer.append(query); - prettyPrint(buffer, b->getSuccessStrategy(), STRAT_BRANCH_PREC, printFlags); + prettyPrint(buffer, printSettings, b->getSuccessStrategy(), STRAT_BRANCH_PREC); buffer.append(colon); - prettyPrint(buffer, b->getFailureStrategy(), STRAT_BRANCH_PREC, printFlags); + prettyPrint(buffer, printSettings, b->getFailureStrategy(), STRAT_BRANCH_PREC); break; } case BranchStrategy::ITERATE: @@ -769,7 +788,7 @@ MixfixModule::prettyPrint(Vector& buffer, Assert(b->getFailureAction() == BranchStrategy::IDLE && b->getSuccessStrategy() == 0 && b->getFailureStrategy() == 0, "unknown branch strategy"); - prettyPrint(buffer, b->getInitialStrategy(), 0, printFlags); + prettyPrint(buffer, printSettings, b->getInitialStrategy(), 0); buffer.append(bang); break; } @@ -788,12 +807,12 @@ MixfixModule::prettyPrint(Vector& buffer, case 0: buffer.append(xmatch); break; default: buffer.append(amatch); } - prettyPrint(buffer, t->getPatternTerm(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false, printFlags); + prettyPrint(buffer, printSettings, t->getPatternTerm(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); const Vector& condition = t->getCondition(); if (!condition.empty()) { buffer.append(suchThat); - prettyPrint(buffer, condition, printFlags); + prettyPrint(buffer, condition, printSettings); } } else if (SubtermStrategy* s = dynamic_cast(expr)) @@ -807,12 +826,12 @@ MixfixModule::prettyPrint(Vector& buffer, case 0: buffer.append(xmatchrew); break; default: buffer.append(amatchrew); } - prettyPrint(buffer, s->getPatternTerm(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false, printFlags); + prettyPrint(buffer, printSettings, s->getPatternTerm(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); const Vector& condition = s->getCondition(); if (!condition.empty()) { buffer.append(suchThat); - prettyPrint(buffer, condition, printFlags); + prettyPrint(buffer, condition, printSettings); } const Vector& subterms = s->getSubterms(); const Vector& strategies = s->getStrategies(); @@ -822,9 +841,9 @@ MixfixModule::prettyPrint(Vector& buffer, for (size_t i = 0; i < nrSubterms; ++i) { buffer.append(i == 0 ? by : comma); - prettyPrint(buffer, subterms[i], UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false, printFlags); + prettyPrint(buffer, printSettings, subterms[i], UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); buffer.append(usingToken); - prettyPrint(buffer, strategies[i], STRAT_USING_PREC - 1, printFlags); + prettyPrint(buffer, printSettings, strategies[i], STRAT_USING_PREC - 1); } } else if (CallStrategy* c = dynamic_cast(expr)) @@ -845,7 +864,7 @@ MixfixModule::prettyPrint(Vector& buffer, first = false; else buffer.append(comma); - prettyPrint(buffer, it.argument(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false, printFlags); + prettyPrint(buffer, printSettings, it.argument(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); } buffer.append(rightParen); } @@ -857,12 +876,12 @@ MixfixModule::prettyPrint(Vector& buffer, void MixfixModule::prettyPrint(Vector& buffer, const Vector& condition, - int printFlags) + const PrintSettings& printSettings) { int nrFragments = condition.length(); for (int i = 0; i < nrFragments;) { - prettyPrint(buffer, condition[i], printFlags); + prettyPrint(buffer, condition[i], printSettings); if (++i < nrFragments) buffer.append(wedge); } @@ -871,35 +890,31 @@ MixfixModule::prettyPrint(Vector& buffer, void MixfixModule::prettyPrint(Vector& buffer, const ConditionFragment* c, - int printFlags) + const PrintSettings& printSettings) { - if (const EqualityConditionFragment* e = - dynamic_cast(c)) + if (const EqualityConditionFragment* e = dynamic_cast(c)) { - prettyPrint(buffer, e->getLhs(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false, printFlags); + prettyPrint(buffer, printSettings, e->getLhs(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); buffer.append(equals); - prettyPrint(buffer, e->getRhs(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false, printFlags); + prettyPrint(buffer, printSettings, e->getRhs(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); } - else if (const SortTestConditionFragment* t = - dynamic_cast(c)) + else if (const SortTestConditionFragment* t = dynamic_cast(c)) { - prettyPrint(buffer, t->getLhs(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false, printFlags); + prettyPrint(buffer, printSettings, t->getLhs(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); buffer.append(colon); - printSort(buffer, t->getSort(), printFlags); + printSort(buffer, t->getSort(), printSettings); } - else if (const AssignmentConditionFragment* a = - dynamic_cast(c)) + else if (const AssignmentConditionFragment* a = dynamic_cast(c)) { - prettyPrint(buffer, a->getLhs(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false, printFlags); + prettyPrint(buffer, printSettings, a->getLhs(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); buffer.append(assign); - prettyPrint(buffer, a->getRhs(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false, printFlags); + prettyPrint(buffer, printSettings, a->getRhs(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); } - else if (const RewriteConditionFragment* r = - dynamic_cast(c)) + else if (const RewriteConditionFragment* r = dynamic_cast(c)) { - prettyPrint(buffer, r->getLhs(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false, printFlags); + prettyPrint(buffer, printSettings, r->getLhs(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); buffer.append(arrow); - prettyPrint(buffer, r->getRhs(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false, printFlags); + prettyPrint(buffer, printSettings, r->getRhs(), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); } else CantHappen("bad condition fragment"); diff --git a/src/Mixfix/commands.yy b/src/Mixfix/commands.yy index a3fa04bb..2b68d195 100644 --- a/src/Mixfix/commands.yy +++ b/src/Mixfix/commands.yy @@ -601,20 +601,20 @@ kw_module : KW_MODULE /* * Options */ -printOption : KW_MIXFIX { $$ = Interpreter::PRINT_MIXFIX; } - | KW_FLAT { $$ = Interpreter::PRINT_FLAT; } - | KW_WITH KW_ALIASES { $$ = Interpreter::PRINT_WITH_ALIASES; } - | KW_WITH KW_PARENS { $$ = Interpreter::PRINT_WITH_PARENS; } - | KW_GRAPH { $$ = Interpreter::PRINT_GRAPH; } - | KW_CONCEAL { $$ = Interpreter::PRINT_CONCEAL; } - | KW_NUMBER { $$ = Interpreter::PRINT_NUMBER; } - | KW_RAT { $$ = Interpreter::PRINT_RAT; } - | KW_COLOR { $$ = Interpreter::PRINT_COLOR; } - | KW_FORMAT { $$ = Interpreter::PRINT_FORMAT; } - | KW_CONST KW_WITH KW_SORTS { $$ = Interpreter::PRINT_DISAMBIG_CONST; } - | KW_LABEL KW_ATTRIBUTE { $$ = Interpreter::PRINT_LABEL_ATTRIBUTE; } - | KW_HOOKS { $$ = Interpreter::PRINT_HOOKS; } - | KW_COMBINE KW_VARS { $$ = Interpreter::PRINT_COMBINE_VARS; } +printOption : KW_MIXFIX { $$ = PrintSettings::PRINT_MIXFIX; } + | KW_FLAT { $$ = PrintSettings::PRINT_FLAT; } + | KW_WITH KW_ALIASES { $$ = PrintSettings::PRINT_WITH_ALIASES; } + | KW_WITH KW_PARENS { $$ = PrintSettings::PRINT_WITH_PARENS; } + | KW_GRAPH { $$ = PrintSettings::PRINT_GRAPH; } + | KW_CONCEAL { $$ = PrintSettings::PRINT_CONCEAL; } + | KW_NUMBER { $$ = PrintSettings::PRINT_NUMBER; } + | KW_RAT { $$ = PrintSettings::PRINT_RAT; } + | KW_COLOR { $$ = PrintSettings::PRINT_COLOR; } + | KW_FORMAT { $$ = PrintSettings::PRINT_FORMAT; } + | KW_CONST KW_WITH KW_SORTS { $$ = PrintSettings::PRINT_DISAMBIG_CONST; } + | KW_LABEL KW_ATTRIBUTE { $$ = PrintSettings::PRINT_LABEL_ATTRIBUTE; } + | KW_HOOKS { $$ = PrintSettings::PRINT_HOOKS; } + | KW_COMBINE KW_VARS { $$ = PrintSettings::PRINT_COMBINE_VARS; } ; traceOption : { $$ = Interpreter::TRACE; } diff --git a/src/Mixfix/dagNodePrint.cc b/src/Mixfix/dagNodePrint.cc index 1936c506..be656d91 100644 --- a/src/Mixfix/dagNodePrint.cc +++ b/src/Mixfix/dagNodePrint.cc @@ -25,9 +25,9 @@ // const char* -MixfixModule::computeColor(ColoringInfo& coloringInfo, DagNode* dagNode) +MixfixModule::computeColor(ColoringInfo& coloringInfo, DagNode* dagNode, const PrintSettings& printSettings) { - if (interpreter.getPrintFlag(Interpreter::PRINT_COLOR)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_COLOR)) { if (dagNode->isReduced()) { @@ -75,7 +75,8 @@ MixfixModule::handleIter(ostream& s, DagNode* dagNode, SymbolInfo& si, bool rangeKnown, - const char* color) + const char* color, + const PrintSettings& printSettings) { // // Check if dagNode is headed by a iter symbol and if so handle @@ -89,7 +90,7 @@ MixfixModule::handleIter(ostream& s, // number printing turned on. // if (si.symbolType.getBasicType() == SymbolType::SUCC_SYMBOL && - interpreter.getPrintFlag(Interpreter::PRINT_NUMBER)) + printSettings.getPrintFlag(PrintSettings::PRINT_NUMBER)) { // // If dagNode corresponds to a number we want to @@ -99,7 +100,7 @@ MixfixModule::handleIter(ostream& s, if (succSymbol->isNat(dagNode)) { const mpz_class& nat = succSymbol->getNat(dagNode); - bool needDisambig = interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST) || + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || (!rangeKnown && (kindsWithSucc.size() > 1 || overloadedIntegers.count(nat))); prefix(s, needDisambig, color); s << nat; @@ -126,15 +127,15 @@ MixfixModule::handleIter(ostream& s, if (color != 0) s << color << prefixName << Tty(Tty::RESET); else - printPrefixName(s, prefixName.c_str(), si); + printPrefixName(s, prefixName.c_str(), si, printSettings); s << '('; - if (interpreter.getPrintFlag(Interpreter::PRINT_COLOR)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_COLOR)) { coloringInfo.reducedDirectlyAbove = dagNode->isReduced(); coloringInfo.reducedAbove = coloringInfo.reducedAbove || coloringInfo.reducedDirectlyAbove; } - prettyPrint(s, coloringInfo, sd->getArgument(), + prettyPrint(s, coloringInfo, printSettings, sd->getArgument(), PREFIX_GATHER, UNBOUNDED, 0, UNBOUNDED, 0, argumentRangeKnown); s << ')'; suffix(s, dagNode, needToDisambiguate, color); @@ -145,16 +146,17 @@ bool MixfixModule::handleMinus(ostream& s, DagNode* dagNode, bool rangeKnown, - const char* color) + const char* color, + const PrintSettings& printSettings) { - if (interpreter.getPrintFlag(Interpreter::PRINT_NUMBER)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_NUMBER)) { const MinusSymbol* minusSymbol = safeCast(MinusSymbol*, dagNode->symbol()); if (minusSymbol->isNeg(dagNode)) { mpz_class neg; (void) minusSymbol->getNeg(dagNode, neg); - bool needDisambig = interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST) || + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || (!rangeKnown && (kindsWithMinus.size() > 1 || overloadedIntegers.count(neg))); prefix(s, needDisambig, color); s << neg; @@ -169,16 +171,17 @@ bool MixfixModule::handleDivision(ostream& s, DagNode* dagNode, bool rangeKnown, - const char* color) + const char* color, + const PrintSettings& printSettings) { - if (interpreter.getPrintFlag(Interpreter::PRINT_RAT)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_RAT)) { const DivisionSymbol* divisionSymbol = safeCast(DivisionSymbol*, dagNode->symbol()); if (divisionSymbol->isRat(dagNode)) { pair rat; rat.second = divisionSymbol->getRat(dagNode, rat.first); - bool needDisambig = interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST) || + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || (!rangeKnown && (kindsWithDivision.size() > 1 || overloadedRationals.count(rat))); prefix(s, needDisambig, color); s << rat.first << '/' << rat.second; @@ -193,10 +196,11 @@ void MixfixModule::handleFloat(ostream& s, DagNode* dagNode, bool rangeKnown, - const char* color) + const char* color, + const PrintSettings& printSettings) { double mfValue = safeCast(FloatDagNode*, dagNode)->getValue(); - bool needDisambig = interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST) || + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || (!rangeKnown && (floatSymbols.size() > 1 || overloadedFloats.count(mfValue))); prefix(s, needDisambig, color); s << doubleToString(mfValue); @@ -207,11 +211,12 @@ void MixfixModule::handleString(ostream& s, DagNode* dagNode, bool rangeKnown, - const char* color) + const char* color, + const PrintSettings& printSettings) { string strValue; Token::ropeToString(safeCast(StringDagNode*, dagNode)->getValue(), strValue); - bool needDisambig = interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST) || + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || (!rangeKnown && (stringSymbols.size() > 1 || overloadedStrings.count(strValue))); prefix(s, needDisambig, color); s << strValue; @@ -222,10 +227,11 @@ void MixfixModule::handleQuotedIdentifier(ostream& s, DagNode* dagNode, bool rangeKnown, - const char* color) + const char* color, + const PrintSettings& printSettings) { int qidCode = safeCast(QuotedIdentifierDagNode*, dagNode)->getIdIndex(); - bool needDisambig = interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST) || + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || (!rangeKnown && (quotedIdentifierSymbols.size() > 1 || overloadedQuotedIdentifiers.count(qidCode))); prefix(s, needDisambig, color); s << '\'' << Token::name(qidCode); @@ -236,22 +242,15 @@ void MixfixModule::handleVariable(ostream& s, DagNode* dagNode, bool rangeKnown, - const char* color) + const char* color, + const PrintSettings& printSettings) { VariableDagNode* v = safeCast(VariableDagNode*, dagNode); Sort* sort = safeCast(VariableSymbol*, dagNode->symbol())->getSort(); pair p(v->id(), sort->id()); bool needDisambig = !rangeKnown && overloadedVariables.count(p); // kinds not handled prefix(s, needDisambig, color); - printVariable(s, p.first, sort); - // - // HACK to understand what is happening with variable indices. - // - //s << Tty(Tty::MAGENTA) << "(index=" << safeCastNonNull(dagNode)->getIndex() << - //", address=" << (void*) dagNode << ")" << Tty(Tty::RESET); - // - // - // + printVariable(s, p.first, sort, printSettings); suffix(s, dagNode, needDisambig, color); } @@ -259,7 +258,8 @@ void MixfixModule::handleSMT_Number(ostream& s, DagNode* dagNode, bool rangeKnown, - const char* color) + const char* color, + const PrintSettings& printSettings) { // // Get value. @@ -279,7 +279,7 @@ MixfixModule::handleSMT_Number(ostream& s, if (t == SMT_Info::INTEGER) { const mpz_class& integer = value.get_num(); - bool needDisambig = interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST) || + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || (!rangeKnown && (kindsWithSucc.size() > 1 || overloadedIntegers.count(integer))); prefix(s, needDisambig, color); s << integer; @@ -289,7 +289,7 @@ MixfixModule::handleSMT_Number(ostream& s, { Assert(t == SMT_Info::REAL, "SMT number sort expected"); pair rat(value.get_num(), value.get_den()); - bool needDisambig = interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST) || + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || (!rangeKnown && (kindsWithDivision.size() > 1 || overloadedRationals.count(rat))); prefix(s, needDisambig, color); s << rat.first << '/' << rat.second; @@ -300,6 +300,7 @@ MixfixModule::handleSMT_Number(ostream& s, void MixfixModule::prettyPrint(ostream& s, ColoringInfo& coloringInfo, + const PrintSettings& printSettings, DagNode* dagNode, int requiredPrec, int leftCapture, @@ -319,52 +320,52 @@ MixfixModule::prettyPrint(ostream& s, } #endif - const char* color = computeColor(coloringInfo, dagNode); + const char* color = computeColor(coloringInfo, dagNode, printSettings); Symbol* symbol = dagNode->symbol(); SymbolInfo& si = symbolInfo[symbol->getIndexWithinModule()]; // // Check for special i/o representation. // - if (handleIter(s, coloringInfo, dagNode, si, rangeKnown, color)) + if (handleIter(s, coloringInfo, dagNode, si, rangeKnown, color, printSettings)) return; int basicType = si.symbolType.getBasicType(); switch (basicType) { case SymbolType::MINUS_SYMBOL: { - if (handleMinus(s, dagNode, rangeKnown, color)) + if (handleMinus(s, dagNode, rangeKnown, color, printSettings)) return; break; } case SymbolType::DIVISION_SYMBOL: { - if (handleDivision(s, dagNode, rangeKnown, color)) + if (handleDivision(s, dagNode, rangeKnown, color, printSettings)) return; break; } case SymbolType::FLOAT: { - handleFloat(s, dagNode, rangeKnown, color); + handleFloat(s, dagNode, rangeKnown, color, printSettings); return; } case SymbolType::STRING: { - handleString(s, dagNode, rangeKnown, color); + handleString(s, dagNode, rangeKnown, color, printSettings); return; } case SymbolType::QUOTED_IDENTIFIER: { - handleQuotedIdentifier(s, dagNode, rangeKnown, color); + handleQuotedIdentifier(s, dagNode, rangeKnown, color, printSettings); return; } case SymbolType::VARIABLE: { - handleVariable(s, dagNode, rangeKnown, color); + handleVariable(s, dagNode, rangeKnown, color, printSettings); return; } case SymbolType::SMT_NUMBER_SYMBOL: { - handleSMT_Number(s, dagNode, rangeKnown, color); + handleSMT_Number(s, dagNode, rangeKnown, color, printSettings); return; } default: @@ -379,13 +380,13 @@ MixfixModule::prettyPrint(ostream& s, int nrArgs = symbol->arity(); if (nrArgs == 0) { - if (interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST)) needDisambig = true; } else argRangeKnown = rangeOfArgumentsKnown(iflags, rangeKnown, needDisambig); - if (interpreter.getPrintFlag(Interpreter::PRINT_COLOR)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_COLOR)) { coloringInfo.reducedDirectlyAbove = dagNode->isReduced(); coloringInfo.reducedAbove = coloringInfo.reducedAbove || @@ -393,14 +394,14 @@ MixfixModule::prettyPrint(ostream& s, } if (needDisambig) s << '('; - bool printConceal = interpreter.concealedSymbol(symbol); - if ((interpreter.getPrintFlag(Interpreter::PRINT_MIXFIX) && !si.mixfixSyntax.empty() && !printConceal) || + bool printConceal = printSettings.concealedSymbol(symbol->id()); + if ((printSettings.getPrintFlag(PrintSettings::PRINT_MIXFIX) && !si.mixfixSyntax.empty() && !printConceal) || (basicType == SymbolType::SORT_TEST)) { // // Mixfix case. // - bool printWithParens = interpreter.getPrintFlag(Interpreter::PRINT_WITH_PARENS); + bool printWithParens = printSettings.getPrintFlag(PrintSettings::PRINT_WITH_PARENS); bool needParen = !needDisambig && (printWithParens || requiredPrec < si.prec || ((iflags & LEFT_BARE) && leftCapture <= si.gather[0] && @@ -422,14 +423,14 @@ MixfixModule::prettyPrint(ostream& s, DagNode* d = a.argument(); a.next(); moreArgs = a.valid(); - pos = printTokens(s, si, pos, color); + pos = printTokens(s, si, pos, color, printSettings); if (arg == nrArgs - 1 && moreArgs) { ++nrTails; arg = 0; if (needAssocParen) s << '('; - pos = printTokens(s, si, 0, color); + pos = printTokens(s, si, 0, color, printSettings); } int lc = UNBOUNDED; const ConnectedComponent* lcc = 0; @@ -455,13 +456,13 @@ MixfixModule::prettyPrint(ostream& s, rcc = rightCaptureComponent; } } - prettyPrint(s, coloringInfo, d, + prettyPrint(s, coloringInfo, printSettings, d, si.gather[arg], lc, lcc, rc, rcc, argRangeKnown); if (UserLevelRewritingContext::interrupted()) return; } - printTails(s, si, pos, nrTails, needAssocParen, true, color); + printTails(s, si, pos, nrTails, needAssocParen, true, color, printSettings); if (UserLevelRewritingContext::interrupted()) return; if (needParen) @@ -476,7 +477,7 @@ MixfixModule::prettyPrint(ostream& s, if (color != 0) s << color << prefixName << Tty(Tty::RESET); else - printPrefixName(s, prefixName, si); + printPrefixName(s, prefixName, si, printSettings); DagArgumentIterator a(*dagNode); if (a.valid()) { @@ -492,17 +493,17 @@ MixfixModule::prettyPrint(ostream& s, a.next(); int moreArgs = a.valid(); if (arg >= nrArgs - 1 && - !(interpreter.getPrintFlag(Interpreter::PRINT_FLAT)) && + !(printSettings.getPrintFlag(PrintSettings::PRINT_FLAT)) && moreArgs) { ++nrTails; if (color != 0) s << color << prefixName << Tty(Tty::RESET); else - printPrefixName(s, prefixName, si); + printPrefixName(s, prefixName, si, printSettings); s << '('; } - prettyPrint(s, coloringInfo, d, + prettyPrint(s, coloringInfo, printSettings, d, PREFIX_GATHER, UNBOUNDED, 0, UNBOUNDED, 0, argRangeKnown); if (UserLevelRewritingContext::interrupted()) diff --git a/src/Mixfix/graphPrint.cc b/src/Mixfix/graphPrint.cc index 4688f06a..c25bdc35 100644 --- a/src/Mixfix/graphPrint.cc +++ b/src/Mixfix/graphPrint.cc @@ -25,7 +25,7 @@ // void -MixfixModule::graphPrint(ostream& s, DagNode* dagNode) +MixfixModule::graphPrint(ostream& s, DagNode* dagNode, const PrintSettings& printSettings) { PointerSet visited; Vector counts; @@ -48,7 +48,7 @@ MixfixModule::graphPrint(ostream& s, DagNode* dagNode) case SymbolType::VARIABLE: { VariableDagNode* v = safeCast(VariableDagNode*, dagNode); - printVariable(s, v->id(), safeCast(VariableSymbol*, symbol)->getSort()); + printVariable(s, v->id(), safeCast(VariableSymbol*, symbol)->getSort(), printSettings); break; } case SymbolType::FLOAT: diff --git a/src/Mixfix/interpreter.cc b/src/Mixfix/interpreter.cc index 2e611aab..599993b3 100644 --- a/src/Mixfix/interpreter.cc +++ b/src/Mixfix/interpreter.cc @@ -91,13 +91,13 @@ #include "srewrite.cc" Interpreter::Interpreter() +: PrintSettings(DEFAULT_PRINT_FLAGS) { xmlLog = 0; xmlBuffer = 0; latexBuffer = 0; flags = DEFAULT_FLAGS; - printFlags = DEFAULT_PRINT_FLAGS; currentModule = 0; currentView = 0; @@ -155,15 +155,6 @@ Interpreter::setFlag(Flags flag, bool polarity) RewritingContext::setTraceStatus(flags & EXCEPTION_FLAGS); } -void -Interpreter::setPrintFlag(PrintFlags flag, bool polarity) -{ - if (polarity) - printFlags |= flag; - else - printFlags &= ~flag; -} - void Interpreter::showProfile() const { @@ -342,10 +333,20 @@ Interpreter::updateSet(set& target, bool add) selected.clear(); } -bool -Interpreter::concealedSymbol(Symbol* symbol) +void +Interpreter::printConceal(bool add) { - return getPrintFlag(PRINT_CONCEAL) && concealedSymbols.find(symbol->id()) != concealedSymbols.end(); + if (add) + { + for (int i : selected) + insertConcealed(i); + } + else + { + for (int i : selected) + eraseConcealed(i); + } + selected.clear(); } void diff --git a/src/Mixfix/interpreter.hh b/src/Mixfix/interpreter.hh index d7c1c20f..01049f9b 100644 --- a/src/Mixfix/interpreter.hh +++ b/src/Mixfix/interpreter.hh @@ -34,6 +34,7 @@ #include "viewCache.hh" //#include "syntacticView.hh" #include "parameterDatabase.hh" +#include "printSettings.hh" #include "SMT.hh" class Interpreter @@ -45,7 +46,8 @@ class Interpreter #endif public ViewDatabase, public ViewCache, - public ParameterDatabase + public ParameterDatabase, + public PrintSettings { NO_COPYING(Interpreter); @@ -136,32 +138,6 @@ public: AUTO_CLEAR_PROFILE | AUTO_CLEAR_CACHES | AUTO_CLEAR_RULES | PRINT_ATTRIBUTE_NEWLINE }; - enum PrintFlags - { - // - // General prettyprinter flags. - // - PRINT_GRAPH = 0x1, // print as a set of DAG nodes - PRINT_CONCEAL = 0x2, // respect concealed argument lists - PRINT_FORMAT = 0x4, // respect format attribute - PRINT_MIXFIX = 0x8, // mixfix notation - PRINT_WITH_PARENS = 0x10, // maximal parens - PRINT_COLOR = 0x20, // dag node coloring based on ctor/reduced status - PRINT_DISAMBIG_CONST = 0x40, // (c).s for every constant c - PRINT_LABEL_ATTRIBUTE = 0x80, // use [label foo] after statement rather than [foo] : before statement - // - // Prettyprinter flags for particular symbol types. - // - PRINT_WITH_ALIASES = 0x100, // for variables - PRINT_FLAT = 0x200, // for assoc symbols - PRINT_NUMBER = 0x400, // for nats & ints - PRINT_RAT = 0x800, // for rats - PRINT_HOOKS = 0x1000, // for built-ins - PRINT_COMBINE_VARS = 0x2000, // for variables - - DEFAULT_PRINT_FLAGS = PRINT_FORMAT | PRINT_MIXFIX | PRINT_WITH_ALIASES | PRINT_FLAT | PRINT_NUMBER | PRINT_RAT | PRINT_HOOKS - }; - Interpreter(); ~Interpreter(); @@ -176,9 +152,6 @@ public: void cleanCaches(); void setFlag(Flags flag, bool polarity); bool getFlag(Flags flag) const; - void setPrintFlag(PrintFlags flag, bool polarity); - bool getPrintFlag(PrintFlags flag) const; - int getPrintFlags() const; SyntacticPreModule* getCurrentModule() const; bool setCurrentModule(const Vector& moduleExpr, int start = 0); @@ -234,7 +207,6 @@ public: bool traceId(int id); bool breakId(int id); bool excludedModule(int id); - bool concealedSymbol(Symbol* symbol); void showProfile() const; void showKinds() const; @@ -372,7 +344,7 @@ private: MaudeLatexBuffer* latexBuffer; int flags; - int printFlags; + //int printFlags; SyntacticPreModule* currentModule; SyntacticView* currentView; // @@ -388,7 +360,6 @@ private: set traceIds; // names of symbols/labels selected for tracing set breakIds; // names of symbols/labels selected as break points set excludedModules; // names of modules to be excluded from tracing - set concealedSymbols; // names of symbols to have their arguments concealed during printing }; inline void @@ -409,12 +380,6 @@ Interpreter::traceExclude(bool add) updateSet(excludedModules, add); } -inline void -Interpreter::printConceal(bool add) -{ - updateSet(concealedSymbols, add); -} - inline bool Interpreter::traceId(int id) { @@ -445,18 +410,6 @@ Interpreter::getFlag(Flags flag) const return flags & flag; } -inline bool -Interpreter::getPrintFlag(PrintFlags flag) const -{ - return printFlags & flag; -} - -inline int -Interpreter::getPrintFlags() const -{ - return printFlags; -} - inline SyntacticPreModule* Interpreter::getCurrentModule() const { diff --git a/src/Mixfix/latexCommon.cc b/src/Mixfix/latexCommon.cc index f0f9fb41..ca78a18e 100644 --- a/src/Mixfix/latexCommon.cc +++ b/src/Mixfix/latexCommon.cc @@ -160,14 +160,14 @@ MixfixModule::latexPrettyOp(int code) } bool -MixfixModule::latexFancySpace(ostream& s, int spaceToken) +MixfixModule::latexFancySpace(ostream& s, int spaceToken, const PrintSettings& printSettings) { // // Handle user specified formating between tokens. Return true if we emit // something that can be treated like a space between tokens. // bool space = false; - for (const char* cmd = Token::name(spaceToken); *cmd; cmd++) + for (const char* cmd = Token::name(spaceToken); *cmd; ++cmd) { char c = *cmd; switch (c) @@ -213,7 +213,7 @@ MixfixModule::latexFancySpace(ostream& s, int spaceToken) } default: { - if (interpreter.getPrintFlag(Interpreter::PRINT_COLOR)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_COLOR)) break; switch (c) { @@ -284,20 +284,20 @@ MixfixModule::latexPrefix(ostream& s, bool needDisambig, const char* color) } void -MixfixModule::latexPrintPrefixName(ostream& s, const char* prefixName, const SymbolInfo& si) +MixfixModule::latexPrintPrefixName(ostream& s, const char* prefixName, const SymbolInfo& si, const PrintSettings& printSettings) { - if (interpreter.getPrintFlag(Interpreter::PRINT_FORMAT) && (si.format.length() == 2)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_FORMAT) && (si.format.length() == 2)) { - latexFancySpace(s, si.format[0]); + latexFancySpace(s, si.format[0], printSettings); s << prefixName; - latexFancySpace(s, si.format[1]); + latexFancySpace(s, si.format[1], printSettings); } else s << prefixName; } int -MixfixModule::latexPrintTokens(ostream& s, const SymbolInfo& si, int pos, const char* color) +MixfixModule::latexPrintTokens(ostream& s, const SymbolInfo& si, int pos, const char* color, const PrintSettings& printSettings) { // // We start with a space if we are following an argument and don't start with a special @@ -305,7 +305,7 @@ MixfixModule::latexPrintTokens(ostream& s, const SymbolInfo& si, int pos, const // bool noSpace = (pos == 0); bool previousOpenOrComma = false; - bool hasFormat = interpreter.getPrintFlag(Interpreter::PRINT_FORMAT) && (si.format.length() > 0); + bool hasFormat = printSettings.getPrintFlag(PrintSettings::PRINT_FORMAT) && (si.format.length() > 0); for (;;) { int token = si.mixfixSyntax[pos++]; @@ -314,7 +314,7 @@ MixfixModule::latexPrintTokens(ostream& s, const SymbolInfo& si, int pos, const bool open = token == leftParen || token == leftBracket || token == leftBrace; bool close = token == rightParen || token == rightBracket || token == rightBrace; bool isComma = token == comma; - if (!(hasFormat && latexFancySpace(s, si.format[pos - 1]))) + if (!(hasFormat && latexFancySpace(s, si.format[pos - 1], printSettings))) { // // format didn't produce a space; do we need one? @@ -357,7 +357,7 @@ MixfixModule::latexPrintTokens(ostream& s, const SymbolInfo& si, int pos, const if (color != 0) s << latexResetColor; } - if (!(hasFormat && latexFancySpace(s, si.format[pos - 1]))) + if (!(hasFormat && latexFancySpace(s, si.format[pos - 1], printSettings))) { // // format didn't produce a space; do we need one? @@ -384,14 +384,15 @@ MixfixModule::latexPrintTails(ostream& s, int nrTails, bool needAssocParen, bool checkForInterrupt, - const char* color) + const char* color, + const PrintSettings& printSettings) { // // We output nrTails copies of the user syntax from pos to si.mixfixSyntax.size() - 1 // Usually nrTails will be 1 unless we are unflattening a flattened associative operator. // bool previousOpenOrComma = false; - bool hasFormat = interpreter.getPrintFlag(Interpreter::PRINT_FORMAT) && (si.format.length() > 0); + bool hasFormat = printSettings.getPrintFlag(PrintSettings::PRINT_FORMAT) && (si.format.length() > 0); Index mixfixLength = si.mixfixSyntax.size(); for (int i = 0;;) { @@ -404,7 +405,7 @@ MixfixModule::latexPrintTails(ostream& s, bool open = token == leftParen || token == leftBracket || token == leftBrace; bool close = token == rightParen || token == rightBracket || token == rightBrace; bool isComma = token == comma; - if (!(hasFormat && latexFancySpace(s, si.format[pos - 1]))) + if (!(hasFormat && latexFancySpace(s, si.format[pos - 1], printSettings))) { // // format didn't produce a space; do we need one? @@ -446,7 +447,7 @@ MixfixModule::latexPrintTails(ostream& s, // If we generate whitespace after the token, we don't want to allow a line break before // the next tail so we reset previousOpenOrComma // - if (latexFancySpace(s, si.format[mixfixLength])) + if (latexFancySpace(s, si.format[mixfixLength], printSettings)) previousOpenOrComma = false; } if (++i == nrTails) diff --git a/src/Mixfix/latexDagNodePrint.cc b/src/Mixfix/latexDagNodePrint.cc index 841819d1..4edf4d0d 100644 --- a/src/Mixfix/latexDagNodePrint.cc +++ b/src/Mixfix/latexDagNodePrint.cc @@ -32,21 +32,22 @@ MixfixModule::latexPrettyPrint(ostream& s, DagNode* dagNode) s << "\\maudeMisc{(null DagNode*)}"; return; } + const PrintSettings& printSettings = interpreter; // HACK MixfixModule* module = static_cast(dagNode->symbol()->getModule()); - if (interpreter.getPrintFlag(Interpreter::PRINT_GRAPH)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_GRAPH)) /*module->latexGraphPrint(s, dagNode)*/; else { - globalIndent = 0; + clearIndent(); s << "$"; - MixfixModule::ColoringInfo coloringInfo; - if (interpreter.getPrintFlag(Interpreter::PRINT_COLOR)) + ColoringInfo coloringInfo; + if (printSettings.getPrintFlag(PrintSettings::PRINT_COLOR)) { - MixfixModule::computeGraphStatus(dagNode, coloringInfo.visited, coloringInfo.statusVec); + computeGraphStatus(dagNode, coloringInfo.visited, coloringInfo.statusVec); coloringInfo.reducedAbove = false; coloringInfo.reducedDirectlyAbove = false; } - module->latexPrettyPrint(s, coloringInfo, dagNode, UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); + module->latexPrettyPrint(s, printSettings, coloringInfo, dagNode, UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); s << "$"; } } @@ -54,27 +55,32 @@ MixfixModule::latexPrettyPrint(ostream& s, DagNode* dagNode) void MixfixModule::latexPrintDagNode(ostream& s, DagNode* dagNode) { + const PrintSettings& printSettings = interpreter; // HACK MixfixModule* module = safeCastNonNull(dagNode->symbol()->getModule()); - if (interpreter.getPrintFlag(Interpreter::PRINT_GRAPH)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_GRAPH)) /*module->latexGraphPrint(s, dagNode)*/; else { - globalIndent = 0; - MixfixModule::ColoringInfo coloringInfo; - if (interpreter.getPrintFlag(Interpreter::PRINT_COLOR)) + clearIndent(); + ColoringInfo coloringInfo; + if (printSettings.getPrintFlag(PrintSettings::PRINT_COLOR)) { - MixfixModule::computeGraphStatus(dagNode, coloringInfo.visited, coloringInfo.statusVec); + computeGraphStatus(dagNode, coloringInfo.visited, coloringInfo.statusVec); coloringInfo.reducedAbove = false; coloringInfo.reducedDirectlyAbove = false; } - module->latexPrettyPrint(s, coloringInfo, dagNode, UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); + module->latexPrettyPrint(s, printSettings, coloringInfo, dagNode, UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); } } const char* -MixfixModule::latexComputeColor(ColoringInfo& coloringInfo, DagNode* dagNode) +MixfixModule::latexComputeColor(ColoringInfo& coloringInfo, DagNode* dagNode, const PrintSettings& printSettings) { - if (interpreter.getPrintFlag(Interpreter::PRINT_COLOR)) + // + // For dags, automatically generated color (as opposed to format generated color) is based + // on ctor-ness and reduced-ness of each dag node. + // + if (printSettings.getPrintFlag(PrintSettings::PRINT_COLOR)) { if (dagNode->isReduced()) { @@ -114,7 +120,8 @@ MixfixModule::latexHandleIter(ostream& s, DagNode* dagNode, SymbolInfo& si, bool rangeKnown, - const char* color) + const char* color, + const PrintSettings& printSettings) { // // Check if dagNode is headed by a iter symbol and if so handle @@ -128,7 +135,7 @@ MixfixModule::latexHandleIter(ostream& s, // number printing turned on. // if (si.symbolType.getBasicType() == SymbolType::SUCC_SYMBOL && - interpreter.getPrintFlag(Interpreter::PRINT_NUMBER)) + printSettings.getPrintFlag(PrintSettings::PRINT_NUMBER)) { // // If dagNode corresponds to a number we want to @@ -138,7 +145,7 @@ MixfixModule::latexHandleIter(ostream& s, if (succSymbol->isNat(dagNode)) { const mpz_class& nat = succSymbol->getNat(dagNode); - bool needDisambig = interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST) || + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || (!rangeKnown && (kindsWithSucc.size() > 1 || overloadedIntegers.count(nat))); latexPrefix(s, needDisambig, color); s << "\\maudeNumber{" << nat << "}"; @@ -164,31 +171,35 @@ MixfixModule::latexHandleIter(ostream& s, if (color != 0) s << color << prefixName << latexResetColor; else - latexPrintPrefixName(s, prefixName.c_str(), si); - if (interpreter.getPrintFlag(Interpreter::PRINT_COLOR)) + latexPrintPrefixName(s, prefixName.c_str(), si, printSettings); + if (printSettings.getPrintFlag(PrintSettings::PRINT_COLOR)) { coloringInfo.reducedDirectlyAbove = dagNode->isReduced(); coloringInfo.reducedAbove = coloringInfo.reducedAbove || coloringInfo.reducedDirectlyAbove; } s << "\\maudeLeftParen"; - latexPrettyPrint(s, coloringInfo, sd->getArgument(), PREFIX_GATHER, UNBOUNDED, 0, UNBOUNDED, 0, argumentRangeKnown); + latexPrettyPrint(s, printSettings, coloringInfo, sd->getArgument(), PREFIX_GATHER, UNBOUNDED, 0, UNBOUNDED, 0, argumentRangeKnown); s << "\\maudeRightParen"; suffix(s, dagNode, needToDisambiguate, color); return true; } bool -MixfixModule::latexHandleMinus(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color) +MixfixModule::latexHandleMinus(ostream& s, + DagNode* dagNode, + bool rangeKnown, + const char* color, + const PrintSettings& printSettings) { - if (interpreter.getPrintFlag(Interpreter::PRINT_NUMBER)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_NUMBER)) { const MinusSymbol* minusSymbol = safeCast(MinusSymbol*, dagNode->symbol()); if (minusSymbol->isNeg(dagNode)) { mpz_class neg; (void) minusSymbol->getNeg(dagNode, neg); - bool needDisambig = interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST) || + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || (!rangeKnown && (kindsWithMinus.size() > 1 || overloadedIntegers.count(neg))); latexPrefix(s, needDisambig, color); s << "\\maudeNumber{" << neg << "}"; @@ -200,16 +211,20 @@ MixfixModule::latexHandleMinus(ostream& s, DagNode* dagNode, bool rangeKnown, co } bool -MixfixModule::latexHandleDivision(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color) +MixfixModule::latexHandleDivision(ostream& s, + DagNode* dagNode, + bool rangeKnown, + const char* color, + const PrintSettings& printSettings) { - if (interpreter.getPrintFlag(Interpreter::PRINT_RAT)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_RAT)) { const DivisionSymbol* divisionSymbol = safeCast(DivisionSymbol*, dagNode->symbol()); if (divisionSymbol->isRat(dagNode)) { pair rat; rat.second = divisionSymbol->getRat(dagNode, rat.first); - bool needDisambig = interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST) || + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || (!rangeKnown && (kindsWithDivision.size() > 1 || overloadedRationals.count(rat))); latexPrefix(s, needDisambig, color); s << "\\maudeNumber{" << rat.first << "}/\\maudeNumber{" << rat.second << "}"; @@ -221,10 +236,14 @@ MixfixModule::latexHandleDivision(ostream& s, DagNode* dagNode, bool rangeKnown, } void -MixfixModule::latexHandleFloat(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color) +MixfixModule::latexHandleFloat(ostream& s, + DagNode* dagNode, + bool rangeKnown, + const char* color, + const PrintSettings& printSettings) { double mfValue = safeCast(FloatDagNode*, dagNode)->getValue(); - bool needDisambig = interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST) || + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || (!rangeKnown && (floatSymbols.size() > 1 || overloadedFloats.count(mfValue))); latexPrefix(s, needDisambig, color); s << "\\maudeNumber{" << doubleToString(mfValue) << "}"; @@ -232,11 +251,15 @@ MixfixModule::latexHandleFloat(ostream& s, DagNode* dagNode, bool rangeKnown, co } void -MixfixModule::latexHandleString(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color) +MixfixModule::latexHandleString(ostream& s, + DagNode* dagNode, + bool rangeKnown, + const char* color, + const PrintSettings& printSettings) { string strValue; Token::ropeToString(safeCast(StringDagNode*, dagNode)->getValue(), strValue); - bool needDisambig = interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST) || + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || (!rangeKnown && (stringSymbols.size() > 1 || overloadedStrings.count(strValue))); latexPrefix(s, needDisambig, color); s << "\\maudeString{" << Token::latexName(strValue) << "}"; @@ -244,10 +267,14 @@ MixfixModule::latexHandleString(ostream& s, DagNode* dagNode, bool rangeKnown, c } void -MixfixModule::latexHandleQuotedIdentifier(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color) +MixfixModule::latexHandleQuotedIdentifier(ostream& s, + DagNode* dagNode, + bool rangeKnown, + const char* color, + const PrintSettings& printSettings) { int qidCode = safeCast(QuotedIdentifierDagNode*, dagNode)->getIdIndex(); - bool needDisambig = interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST) || + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || (!rangeKnown && (quotedIdentifierSymbols.size() > 1 || overloadedQuotedIdentifiers.count(qidCode))); latexPrefix(s, needDisambig, color); s << "\\maudeQid{" << "\\maudeSingleQuote " << Token::latexName(qidCode) << "}"; @@ -255,7 +282,11 @@ MixfixModule::latexHandleQuotedIdentifier(ostream& s, DagNode* dagNode, bool ran } void -MixfixModule::latexHandleVariable(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color) +MixfixModule::latexHandleVariable(ostream& s, + DagNode* dagNode, + bool rangeKnown, + const char* color, + const PrintSettings& printSettings) { VariableDagNode* v = safeCast(VariableDagNode*, dagNode); Sort* sort = safeCast(VariableSymbol*, dagNode->symbol())->getSort(); @@ -264,7 +295,7 @@ MixfixModule::latexHandleVariable(ostream& s, DagNode* dagNode, bool rangeKnown, latexPrefix(s, needDisambig, color); s << Token::latexIdentifier(v->id()); - if (interpreter.getPrintFlag(Interpreter::PRINT_WITH_ALIASES)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_WITH_ALIASES)) { AliasMap::const_iterator i = variableAliases.find(v->id()); if (i != variableAliases.end() && (*i).second == sort) @@ -278,7 +309,11 @@ MixfixModule::latexHandleVariable(ostream& s, DagNode* dagNode, bool rangeKnown, } void -MixfixModule::latexHandleSMT_Number(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color) +MixfixModule::latexHandleSMT_Number(ostream& s, + DagNode* dagNode, + bool rangeKnown, + const char* color, + const PrintSettings& printSettings) { // // Get value. @@ -298,7 +333,7 @@ MixfixModule::latexHandleSMT_Number(ostream& s, DagNode* dagNode, bool rangeKnow if (t == SMT_Info::INTEGER) { const mpz_class& integer = value.get_num(); - bool needDisambig = interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST) || + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || (!rangeKnown && (kindsWithSucc.size() > 1 || overloadedIntegers.count(integer))); latexPrefix(s, needDisambig, color); s << "\\maudeNumber{" << integer << "}"; @@ -308,7 +343,7 @@ MixfixModule::latexHandleSMT_Number(ostream& s, DagNode* dagNode, bool rangeKnow { Assert(t == SMT_Info::REAL, "SMT number sort expected"); pair rat(value.get_num(), value.get_den()); - bool needDisambig = interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST) || + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || (!rangeKnown && (kindsWithDivision.size() > 1 || overloadedRationals.count(rat))); latexPrefix(s, needDisambig, color); s << "\\maudeNumber{" << rat.first << "}/\\maudeNumber{" << rat.second << "}"; @@ -318,6 +353,7 @@ MixfixModule::latexHandleSMT_Number(ostream& s, DagNode* dagNode, bool rangeKnow void MixfixModule::latexPrettyPrint(ostream& s, + const PrintSettings& printSettings, ColoringInfo& coloringInfo, DagNode* dagNode, int requiredPrec, @@ -327,56 +363,56 @@ MixfixModule::latexPrettyPrint(ostream& s, const ConnectedComponent* rightCaptureComponent, bool rangeKnown) { + Assert(dagNode != 0, "null pointer"); if (UserLevelRewritingContext::interrupted()) return; - Assert(dagNode != 0, "null pointer"); - const char* color = latexComputeColor(coloringInfo, dagNode); Symbol* symbol = dagNode->symbol(); SymbolInfo& si = symbolInfo[symbol->getIndexWithinModule()]; + const char* color = latexComputeColor(coloringInfo, dagNode, printSettings); // // Check for special i/o representation. // - if (latexHandleIter(s, coloringInfo, dagNode, si, rangeKnown, color)) + if (latexHandleIter(s, coloringInfo, dagNode, si, rangeKnown, color, printSettings)) return; int basicType = si.symbolType.getBasicType(); switch (basicType) { case SymbolType::MINUS_SYMBOL: { - if (latexHandleMinus(s, dagNode, rangeKnown, color)) + if (latexHandleMinus(s, dagNode, rangeKnown, color, printSettings)) return; break; } case SymbolType::DIVISION_SYMBOL: { - if (latexHandleDivision(s, dagNode, rangeKnown, color)) + if (latexHandleDivision(s, dagNode, rangeKnown, color, printSettings)) return; break; } case SymbolType::FLOAT: { - latexHandleFloat(s, dagNode, rangeKnown, color); + latexHandleFloat(s, dagNode, rangeKnown, color, printSettings); return; } case SymbolType::STRING: { - latexHandleString(s, dagNode, rangeKnown, color); + latexHandleString(s, dagNode, rangeKnown, color, printSettings); return; } case SymbolType::QUOTED_IDENTIFIER: { - latexHandleQuotedIdentifier(s, dagNode, rangeKnown, color); + latexHandleQuotedIdentifier(s, dagNode, rangeKnown, color, printSettings); return; } case SymbolType::VARIABLE: { - latexHandleVariable(s, dagNode, rangeKnown, color); + latexHandleVariable(s, dagNode, rangeKnown, color, printSettings); return; } case SymbolType::SMT_NUMBER_SYMBOL: { - latexHandleSMT_Number(s, dagNode, rangeKnown, color); + latexHandleSMT_Number(s, dagNode, rangeKnown, color, printSettings); return; } default: @@ -391,30 +427,31 @@ MixfixModule::latexPrettyPrint(ostream& s, int nrArgs = symbol->arity(); if (nrArgs == 0) { - if (interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST)) needDisambig = true; } else argRangeKnown = rangeOfArgumentsKnown(iflags, rangeKnown, needDisambig); - if (interpreter.getPrintFlag(Interpreter::PRINT_COLOR)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_COLOR)) { coloringInfo.reducedDirectlyAbove = dagNode->isReduced(); coloringInfo.reducedAbove = coloringInfo.reducedAbove || coloringInfo.reducedDirectlyAbove; } + if (needDisambig) s << "\\maudeLeftParen"; - bool printConceal = interpreter.concealedSymbol(symbol); + bool printConceal = printSettings.concealedSymbol(symbol->id()); if (nrArgs == 0 && Token::auxProperty(symbol->id()) == Token::AUX_STRUCTURED_SORT) s << latexStructuredConstant(symbol->id()); - else if ((interpreter.getPrintFlag(Interpreter::PRINT_MIXFIX) && !si.mixfixSyntax.empty() && !printConceal) || + else if ((printSettings.getPrintFlag(PrintSettings::PRINT_MIXFIX) && !si.mixfixSyntax.empty() && !printConceal) || (basicType == SymbolType::SORT_TEST)) { // // Mixfix case. // - bool printWithParens = interpreter.getPrintFlag(Interpreter::PRINT_WITH_PARENS); + bool printWithParens = printSettings.getPrintFlag(PrintSettings::PRINT_WITH_PARENS); bool needParen = !needDisambig && (printWithParens || requiredPrec < si.prec || ((iflags & LEFT_BARE) && leftCapture <= si.gather[0] && @@ -431,19 +468,19 @@ MixfixModule::latexPrettyPrint(ostream& s, int pos = 0; DagArgumentIterator a(*dagNode); int moreArgs = a.valid(); - for (int arg = 0; moreArgs; arg++) + for (int arg = 0; moreArgs; ++arg) { DagNode* d = a.argument(); a.next(); moreArgs = a.valid(); - pos = latexPrintTokens(s, si, pos, color); + pos = latexPrintTokens(s, si, pos, color, printSettings); if (arg == nrArgs - 1 && moreArgs) { ++nrTails; arg = 0; if (needAssocParen) s << "\\maudeLeftParen"; - pos = latexPrintTokens(s, si, 0, color); + pos = latexPrintTokens(s, si, 0, color, printSettings); } int lc = UNBOUNDED; const ConnectedComponent* lcc = 0; @@ -469,13 +506,11 @@ MixfixModule::latexPrettyPrint(ostream& s, rcc = rightCaptureComponent; } } - latexPrettyPrint(s, coloringInfo, d, - si.gather[arg], lc, lcc, rc, rcc, - argRangeKnown); + latexPrettyPrint(s, printSettings, coloringInfo, d, si.gather[arg], lc, lcc, rc, rcc, argRangeKnown); if (UserLevelRewritingContext::interrupted()) return; } - latexPrintTails(s, si, pos, nrTails, needAssocParen, true, color); + latexPrintTails(s, si, pos, nrTails, needAssocParen, true, color, printSettings); if (needParen) s << "\\maudeRightParen"; } @@ -488,12 +523,12 @@ MixfixModule::latexPrettyPrint(ostream& s, if (color != 0) s << color << prefixName << latexResetColor; else - latexPrintPrefixName(s, prefixName.c_str(), si); + latexPrintPrefixName(s, prefixName.c_str(), si, printSettings); DagArgumentIterator a(*dagNode); if (a.valid()) { if (printConceal) - s << "\\maudeLeftParen\\ldots\\maudeRightParen"; + s << "\\maudeLeftParen\\maudeEllipsis\\maudeRightParen"; else { int nrTails = 1; @@ -504,17 +539,17 @@ MixfixModule::latexPrettyPrint(ostream& s, a.next(); int moreArgs = a.valid(); if (arg >= nrArgs - 1 && - !(interpreter.getPrintFlag(Interpreter::PRINT_FLAT)) && + !(printSettings.getPrintFlag(PrintSettings::PRINT_FLAT)) && moreArgs) { ++nrTails; if (color != 0) s << color << prefixName << latexResetColor; else - latexPrintPrefixName(s, prefixName.c_str(), si); + latexPrintPrefixName(s, prefixName.c_str(), si, printSettings); s << "\\maudeLeftParen"; } - latexPrettyPrint(s, coloringInfo, d, + latexPrettyPrint(s, printSettings, coloringInfo, d, PREFIX_GATHER, UNBOUNDED, 0, UNBOUNDED, 0, argRangeKnown); if (!moreArgs) diff --git a/src/Mixfix/latexPreModulePrint.cc b/src/Mixfix/latexPreModulePrint.cc index 4db2cc77..de70f2d0 100644 --- a/src/Mixfix/latexPreModulePrint.cc +++ b/src/Mixfix/latexPreModulePrint.cc @@ -48,12 +48,7 @@ SyntacticPreModule::latexTokenVector(ostream& s, const Vector& tokens, In int code = tokens[i].code(); if (code == rightParen || code == rightBracket || code == rightBrace || code == comma) needSpace = false; - else if (code == leftParen) - { - needSpace = false; - nextNeedSpace = false; - } - else if (code == leftBracket || code == leftBrace) + else if (code == leftParen || code == leftBracket || code == leftBrace) nextNeedSpace = false; if (needSpace) s << "\\maudeSpace"; diff --git a/src/Mixfix/latexTermPrint.cc b/src/Mixfix/latexTermPrint.cc index 9d886ff9..857d136a 100644 --- a/src/Mixfix/latexTermPrint.cc +++ b/src/Mixfix/latexTermPrint.cc @@ -27,9 +27,10 @@ void MixfixModule::latexPrettyPrint(ostream& s, Term* term, bool rangeKnown) { - globalIndent = 0; + clearIndent(); + const PrintSettings& printSettings = interpreter; // HACK MixfixModule* module = safeCastNonNull(term->symbol()->getModule()); - module->latexPrettyPrint(s, term, UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, rangeKnown); + module->latexPrettyPrint(s, printSettings, term, UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, rangeKnown); } void @@ -51,16 +52,26 @@ MixfixModule::latexPrintStrategyTerm(ostream& s, RewriteStrategy* rs, Term* term } const char* -MixfixModule::latexComputeColor(SymbolType st) +MixfixModule::latexComputeColor(SymbolType st, const PrintSettings& printSettings) { - if (interpreter.getPrintFlag(Interpreter::PRINT_COLOR)) + // + // For terms, automatically generated color (as opposed to format generated color) is based + // on the axioms of each operator symbol. + // AC : red + // ACU : magenta + // A : green + // AU : cyan + // C/CU : blue + // U : yellow + // + if (printSettings.getPrintFlag(PrintSettings::PRINT_COLOR)) { if (st.hasFlag(SymbolType::ASSOC)) { if (st.hasFlag(SymbolType::COMM)) return st.hasFlag(SymbolType::LEFT_ID | SymbolType::RIGHT_ID) ? latexMagenta : latexRed; else - return st.hasFlag(SymbolType::LEFT_ID | SymbolType::RIGHT_ID) ? latexCyan :latexGreen; + return st.hasFlag(SymbolType::LEFT_ID | SymbolType::RIGHT_ID) ? latexCyan : latexGreen; } if (st.hasFlag(SymbolType::COMM)) return latexBlue; @@ -71,14 +82,18 @@ MixfixModule::latexComputeColor(SymbolType st) } void -MixfixModule::latexSuffix(ostream& s, Term* term, bool needDisambig, const char* /* color */) +MixfixModule::latexSuffix(ostream& s, Term* term, bool needDisambig) { if (needDisambig) s << "\\maudeRightParen\\maudeDisambigDot" << latexType(disambiguatorSort(term)); } bool -MixfixModule::latexHandleIter(ostream& s, Term* term, const SymbolInfo& si, bool rangeKnown, const char* color) +MixfixModule::latexHandleIter(ostream& s, + Term* term, + const SymbolInfo& si, + bool rangeKnown, + const PrintSettings& printSettings) { // // Check if term is headed by a iter symbol and if so handle @@ -90,8 +105,7 @@ MixfixModule::latexHandleIter(ostream& s, Term* term, const SymbolInfo& si, bool // // Check if the top symbol is also a succ symbol and we have number printing turned on. // - if (si.symbolType.getBasicType() == SymbolType::SUCC_SYMBOL && - interpreter.getPrintFlag(Interpreter::PRINT_NUMBER)) + if (si.symbolType.getBasicType() == SymbolType::SUCC_SYMBOL && printSettings.getPrintFlag(PrintSettings::PRINT_NUMBER)) { // // If term corresponds to a number we want to print it as decimal number. @@ -100,10 +114,11 @@ MixfixModule::latexHandleIter(ostream& s, Term* term, const SymbolInfo& si, bool if (succSymbol->isNat(term)) { const mpz_class& nat = succSymbol->getNat(term); - bool needDisambig = !rangeKnown && (kindsWithSucc.size() > 1 || overloadedIntegers.count(nat)); - latexPrefix(s, needDisambig, color); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (kindsWithSucc.size() > 1 || overloadedIntegers.count(nat))); + latexPrefix(s, needDisambig); s << "\\maudeNumber{" << nat << "}"; - latexSuffix(s, term, needDisambig, color); + latexSuffix(s, term, needDisambig); return true; } } @@ -118,35 +133,36 @@ MixfixModule::latexHandleIter(ostream& s, Term* term, const SymbolInfo& si, bool bool needToDisambiguate; bool argumentRangeKnown; decideIteratedAmbiguity(rangeKnown, term->symbol(), number, needToDisambiguate, argumentRangeKnown); - if (needToDisambiguate) - s << "\\maudeLeftParen"; + latexPrefix(s, needToDisambiguate); string prefixName = "\\maudeIter{" + Token::latexIdentifier(term->symbol()->id()) + "}{" + number.get_str() + "}"; - if (color != 0) - s << color << prefixName << latexResetColor; - else - latexPrintPrefixName(s, prefixName.c_str(), si); + latexPrintPrefixName(s, prefixName.c_str(), si, printSettings); s << "\\maudeLeftParen"; - latexPrettyPrint(s, st->getArgument(), PREFIX_GATHER, UNBOUNDED, 0, UNBOUNDED, 0, argumentRangeKnown); + latexPrettyPrint(s, printSettings, st->getArgument(), PREFIX_GATHER, UNBOUNDED, 0, UNBOUNDED, 0, argumentRangeKnown); s << "\\maudeRightParen"; - suffix(s, term, needToDisambiguate, color); + + latexSuffix(s, term, needToDisambiguate); return true; } bool -MixfixModule::latexHandleMinus(ostream& s, Term* term, bool rangeKnown, const char* color) const +MixfixModule::latexHandleMinus(ostream& s, + Term* term, + bool rangeKnown, + const PrintSettings& printSettings) const { - if (interpreter.getPrintFlag(Interpreter::PRINT_NUMBER)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_NUMBER)) { const MinusSymbol* minusSymbol = safeCast(MinusSymbol*, term->symbol()); if (minusSymbol->isNeg(term)) { mpz_class neg; (void) minusSymbol->getNeg(term, neg); - bool needDisambig = !rangeKnown && (kindsWithMinus.size() > 1 || overloadedIntegers.count(neg)); - latexPrefix(s, needDisambig, color); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (kindsWithMinus.size() > 1 || overloadedIntegers.count(neg))); + latexPrefix(s, needDisambig); s << "\\maudeNumber{" << neg << "}"; - latexSuffix(s, term, needDisambig, color); + latexSuffix(s, term, needDisambig); return true; } } @@ -154,19 +170,23 @@ MixfixModule::latexHandleMinus(ostream& s, Term* term, bool rangeKnown, const ch } bool -MixfixModule::latexHandleDivision(ostream& s, Term* term, bool rangeKnown, const char* color) const +MixfixModule::latexHandleDivision(ostream& s, + Term* term, + bool rangeKnown, + const PrintSettings& printSettings) const { - if (interpreter.getPrintFlag(Interpreter::PRINT_RAT)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_RAT)) { const DivisionSymbol* divisionSymbol = safeCast(DivisionSymbol*, term->symbol()); if (divisionSymbol->isRat(term)) { pair rat; rat.second = divisionSymbol->getRat(term, rat.first); - bool needDisambig = !rangeKnown && (kindsWithDivision.size() > 1 || overloadedRationals.count(rat)); - latexPrefix(s, needDisambig, color); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (kindsWithDivision.size() > 1 || overloadedRationals.count(rat))); + latexPrefix(s, needDisambig); s << "\\maudeNumber{" << rat.first << "}/\\maudeNumber{" << rat.second << "}"; - latexSuffix(s, term, needDisambig, color); + latexSuffix(s, term, needDisambig); return true; } } @@ -174,61 +194,79 @@ MixfixModule::latexHandleDivision(ostream& s, Term* term, bool rangeKnown, const } void -MixfixModule::latexHandleFloat(ostream& s, Term* term, bool rangeKnown, const char* color) const +MixfixModule::latexHandleFloat(ostream& s, + Term* term, + bool rangeKnown, + const PrintSettings& printSettings) const { double mfValue = safeCastNonNull(term)->getValue(); - bool needDisambig = !rangeKnown && (floatSymbols.size() > 1 || overloadedFloats.count(mfValue)); - latexPrefix(s, needDisambig, color); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (floatSymbols.size() > 1 || overloadedFloats.count(mfValue))); + latexPrefix(s, needDisambig); s << "\\maudeNumber{" << doubleToString(mfValue) << "}"; - latexSuffix(s, term, needDisambig, color); + latexSuffix(s, term, needDisambig); } void -MixfixModule::latexHandleString(ostream& s, Term* term, bool rangeKnown, const char* color) const +MixfixModule::latexHandleString(ostream& s, + Term* term, + bool rangeKnown, + const PrintSettings& printSettings) const { string strValue; Token::ropeToString(safeCastNonNull(term)->getValue(), strValue); - bool needDisambig = !rangeKnown && (stringSymbols.size() > 1 || overloadedStrings.count(strValue)); - latexPrefix(s, needDisambig, color); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (stringSymbols.size() > 1 || overloadedStrings.count(strValue))); + latexPrefix(s, needDisambig); s << "\\maudeString{" << Token::latexName(strValue) << "}"; - latexSuffix(s, term, needDisambig, color); + latexSuffix(s, term, needDisambig); } void -MixfixModule::latexHandleQuotedIdentifier(ostream& s, Term* term, bool rangeKnown, const char* color) const +MixfixModule::latexHandleQuotedIdentifier(ostream& s, + Term* term, + bool rangeKnown, + const PrintSettings& printSettings) const { int qidCode = safeCastNonNull(term)->getIdIndex(); - bool needDisambig = !rangeKnown && (quotedIdentifierSymbols.size() > 1 || overloadedQuotedIdentifiers.count(qidCode)); - latexPrefix(s, needDisambig, color); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (quotedIdentifierSymbols.size() > 1 || overloadedQuotedIdentifiers.count(qidCode))); + latexPrefix(s, needDisambig); s << "\\maudeQid{" << "\\maudeSingleQuote " << Token::latexName(qidCode) << "}"; - latexSuffix(s, term, needDisambig, color); + latexSuffix(s, term, needDisambig); } void -MixfixModule::latexHandleVariable(ostream& s, Term* term, bool rangeKnown, const char* color) const +MixfixModule::latexHandleVariable(ostream& s, + Term* term, + bool rangeKnown, + const PrintSettings& printSettings) const { VariableTerm* v = safeCastNonNull(term); Sort* sort = safeCastNonNull(term->symbol())->getSort(); pair p(v->id(), sort->id()); bool needDisambig = !rangeKnown && overloadedVariables.count(p); // kinds not handled - latexPrefix(s, needDisambig, color); + latexPrefix(s, needDisambig); s << Token::latexIdentifier(v->id()); - if (interpreter.getPrintFlag(Interpreter::PRINT_WITH_ALIASES)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_WITH_ALIASES)) { AliasMap::const_iterator i = variableAliases.find(v->id()); if (i != variableAliases.end() && (*i).second == sort) { - latexSuffix(s, term, needDisambig, color); + latexSuffix(s, term, needDisambig); return; } } s << "\\maudeVariableColon" << latexType(sort); - latexSuffix(s, term, needDisambig, color); + latexSuffix(s, term, needDisambig); } void -MixfixModule::latexHandleSMT_Number(ostream& s, Term* term, bool rangeKnown, const char* color) +MixfixModule::latexHandleSMT_Number(ostream& s, + Term* term, + bool rangeKnown, + const PrintSettings& printSettings) { // // Get value. @@ -248,24 +286,27 @@ MixfixModule::latexHandleSMT_Number(ostream& s, Term* term, bool rangeKnown, con if (t == SMT_Info::INTEGER) { const mpz_class& integer = value.get_num(); - bool needDisambig = !rangeKnown && (kindsWithSucc.size() > 1 || overloadedIntegers.count(integer)); - latexPrefix(s, needDisambig, color); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (kindsWithSucc.size() > 1 || overloadedIntegers.count(integer))); + latexPrefix(s, needDisambig); s << "\\maudeNumber{" << integer << "}"; - latexSuffix(s, term, needDisambig, color); + latexSuffix(s, term, needDisambig); } else { Assert(t == SMT_Info::REAL, "SMT number sort expected"); pair rat(value.get_num(), value.get_den()); - bool needDisambig = !rangeKnown && (kindsWithDivision.size() > 1 || overloadedRationals.count(rat)); - latexPrefix(s, needDisambig, color); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (kindsWithDivision.size() > 1 || overloadedRationals.count(rat))); + latexPrefix(s, needDisambig); s << "\\maudeNumber{" << rat.first << "}/\\maudeNumber{" << rat.second << "}"; - latexSuffix(s, term, needDisambig, color); + latexSuffix(s, term, needDisambig); } } void MixfixModule::latexPrettyPrint(ostream& s, + const PrintSettings& printSettings, Term* term, int requiredPrec, int leftCapture, @@ -279,50 +320,49 @@ MixfixModule::latexPrettyPrint(ostream& s, Symbol* symbol = term->symbol(); const SymbolInfo& si = symbolInfo[symbol->getIndexWithinModule()]; - const char* color = computeColor(si.symbolType); // // Check for special i/o representation. // - if (latexHandleIter(s, term, si, rangeKnown, color)) + if (latexHandleIter(s, term, si, rangeKnown, printSettings)) return; int basicType = si.symbolType.getBasicType(); switch (basicType) { case SymbolType::MINUS_SYMBOL: { - if (latexHandleMinus(s, term, rangeKnown, color)) + if (latexHandleMinus(s, term, rangeKnown, printSettings)) return; break; } case SymbolType::DIVISION_SYMBOL: { - if (latexHandleDivision(s, term, rangeKnown, color)) + if (latexHandleDivision(s, term, rangeKnown, printSettings)) return; break; } case SymbolType::FLOAT: { - latexHandleFloat(s, term, rangeKnown, color); + latexHandleFloat(s, term, rangeKnown, printSettings); return; } case SymbolType::STRING: { - latexHandleString(s, term, rangeKnown, color); + latexHandleString(s, term, rangeKnown, printSettings); return; } case SymbolType::QUOTED_IDENTIFIER: { - latexHandleQuotedIdentifier(s, term, rangeKnown, color); + latexHandleQuotedIdentifier(s, term, rangeKnown, printSettings); return; } case SymbolType::VARIABLE: { - latexHandleVariable(s, term, rangeKnown, color); + latexHandleVariable(s, term, rangeKnown, printSettings); return; } case SymbolType::SMT_NUMBER_SYMBOL: { - latexHandleSMT_Number(s, term, rangeKnown, color); + latexHandleSMT_Number(s, term, rangeKnown, printSettings); return; } default: @@ -331,29 +371,30 @@ MixfixModule::latexPrettyPrint(ostream& s, // // Default case where no special i/o representation applies. // + const char* color = latexComputeColor(si.symbolType, printSettings); int iflags = si.iflags; bool needDisambig = !rangeKnown && ambiguous(iflags); bool argRangeKnown = false; int nrArgs = symbol->arity(); if (nrArgs == 0) { - if (interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST)) needDisambig = true; } else argRangeKnown = rangeOfArgumentsKnown(iflags, rangeKnown, needDisambig); - if (needDisambig) - s << "\\maudeLeftParen"; - + latexPrefix(s, needDisambig); + bool printConceal = printSettings.concealedSymbol(symbol->id()); if (nrArgs == 0 && Token::auxProperty(symbol->id()) == Token::AUX_STRUCTURED_SORT) s << latexStructuredConstant(symbol->id()); - else if ((interpreter.getPrintFlag(Interpreter::PRINT_MIXFIX) && !si.mixfixSyntax.empty()) || basicType == SymbolType::SORT_TEST) + else if ((printSettings.getPrintFlag(PrintSettings::PRINT_MIXFIX) && !si.mixfixSyntax.empty() && !printConceal) || + basicType == SymbolType::SORT_TEST) { // // Mixfix case. // - bool printWithParens = interpreter.getPrintFlag(Interpreter::PRINT_WITH_PARENS); + bool printWithParens = printSettings.getPrintFlag(PrintSettings::PRINT_WITH_PARENS); bool needParen = !needDisambig && (printWithParens || requiredPrec < si.prec || ((iflags & LEFT_BARE) && leftCapture <= si.gather[0] && @@ -370,19 +411,19 @@ MixfixModule::latexPrettyPrint(ostream& s, int pos = 0; ArgumentIterator a(*term); int moreArgs = a.valid(); - for (int arg = 0; moreArgs; arg++) + for (int arg = 0; moreArgs; ++arg) { Term* t = a.argument(); a.next(); moreArgs = a.valid(); - pos = latexPrintTokens(s, si, pos, color); + pos = latexPrintTokens(s, si, pos, color, printSettings); if (arg == nrArgs - 1 && moreArgs) { ++nrTails; arg = 0; if (needAssocParen) s << "\\maudeLeftParen"; - pos = latexPrintTokens(s, si, 0, color); + pos = latexPrintTokens(s, si, 0, color, printSettings); } int lc = UNBOUNDED; const ConnectedComponent* lcc = 0; @@ -408,11 +449,11 @@ MixfixModule::latexPrettyPrint(ostream& s, rcc = rightCaptureComponent; } } - latexPrettyPrint(s, t, si.gather[arg], lc, lcc, rc, rcc, argRangeKnown); + latexPrettyPrint(s, printSettings, t, si.gather[arg], lc, lcc, rc, rcc, argRangeKnown); if (UserLevelRewritingContext::interrupted()) return; } - latexPrintTails(s, si, pos, nrTails, needAssocParen, true, color); + latexPrintTails(s, si, pos, nrTails, needAssocParen, true, color, printSettings); if (needParen) s << "\\maudeRightParen"; } @@ -425,40 +466,45 @@ MixfixModule::latexPrettyPrint(ostream& s, if (color != 0) s << color << prefixName << latexResetColor; else - latexPrintPrefixName(s, prefixName.c_str(), si); + latexPrintPrefixName(s, prefixName.c_str(), si, printSettings); ArgumentIterator a(*term); if (a.valid()) { - int nrTails = 1; - s << "\\maudeLeftParen"; - for (int arg = 0;; arg++) + if (printConceal) + s << "\\maudeLeftParen\\maudeEllipsis\\maudeRightParen"; + else { - Term* t = a.argument(); - a.next(); - int moreArgs = a.valid(); - if (arg >= nrArgs - 1 && - !(interpreter.getPrintFlag(Interpreter::PRINT_FLAT)) && - moreArgs) + int nrTails = 1; + s << "\\maudeLeftParen"; + for (int arg = 0;; arg++) { - ++nrTails; - if (color != 0) - s << color << prefixName << latexResetColor; - else - latexPrintPrefixName(s, prefixName.c_str(), si); - s << "\\maudeLeftParen"; + Term* t = a.argument(); + a.next(); + int moreArgs = a.valid(); + if (arg >= nrArgs - 1 && + !(printSettings.getPrintFlag(PrintSettings::PRINT_FLAT)) && + moreArgs) + { + ++nrTails; + if (color != 0) + s << color << prefixName << latexResetColor; + else + latexPrintPrefixName(s, prefixName.c_str(), si, printSettings); + s << "\\maudeLeftParen"; + } + latexPrettyPrint(s, printSettings, t, PREFIX_GATHER, UNBOUNDED, 0, UNBOUNDED, 0, argRangeKnown); + if (!moreArgs) + break; + s << "\\maudeComma"; + } + while (nrTails-- > 0) + { + if (UserLevelRewritingContext::interrupted()) + return; + s << "\\maudeRightParen"; } - latexPrettyPrint(s, t, PREFIX_GATHER, UNBOUNDED, 0, UNBOUNDED, 0, argRangeKnown); - if (!moreArgs) - break; - s << "\\maudeComma"; - } - while (nrTails-- > 0) - { - if (UserLevelRewritingContext::interrupted()) - return; - s << "\\maudeRightParen"; } } } - latexSuffix(s, term, needDisambig, color); + latexSuffix(s, term, needDisambig); } diff --git a/src/Mixfix/mixfix.hh b/src/Mixfix/mixfix.hh index 89073fe0..63bb5460 100644 --- a/src/Mixfix/mixfix.hh +++ b/src/Mixfix/mixfix.hh @@ -74,6 +74,7 @@ class ObjectConstructorSymbol; class StatementTransformer; class MaudeLatexBuffer; class CommutativeDecomposeEqualitySymbol; +class PrintSettings; // // Support for quantifying just active computations (rather than diff --git a/src/Mixfix/mixfixModule.hh b/src/Mixfix/mixfixModule.hh index fe15fe52..262c3bb1 100644 --- a/src/Mixfix/mixfixModule.hh +++ b/src/Mixfix/mixfixModule.hh @@ -276,12 +276,16 @@ public: // // Pretty print functions. // - void bufferPrint(Vector& buffer, Term* term, int printFlags); - void bufferPrint(Vector& buffer, StrategyExpression* term, int printFlags); + void bufferPrint(Vector& buffer, Term* term, const PrintSettings& printSettings); + void bufferPrint(Vector& buffer, StrategyExpression* term, const PrintSettings& printSettings); static Sort* disambiguatorSort(const Term* term); int getSMT_NumberToken(const mpq_class& value, Sort* sort); void printModifiers(ostream& s, Int64 number = NONE, Int64 number2 = NONE); static void prettyPrint(ostream& s, const Term* term, bool rangeKnown = false); + static void prettyPrint(ostream& s, DagNode* dagNode, bool rangeKnown = false); + static bool prettyPrint(ostream& s, StrategyExpression* strategy, int requiredPrec); + static void clearIndent(); + static void clearColor(ostream& s); // // LaTeX conversion functions. // @@ -598,22 +602,24 @@ private: static Term* findNonlinearVariable(Term* term, NatSet& seenIndices); - void printVariable(ostream& s, int name, Sort* sort) const; - void graphPrint(ostream& s, DagNode* dagNode); + void printVariable(ostream& s, int name, Sort* sort, const PrintSettings& printSettings) const; + void graphPrint(ostream& s, DagNode* dagNode, const PrintSettings& printSettings); - static void printPrefixName(ostream& s, const char* prefixName, SymbolInfo& si); + static void printPrefixName(ostream& s, const char* prefixName, SymbolInfo& si, const PrintSettings& printSettings); static int printTokens(ostream& s, const SymbolInfo& si, int pos, - const char* color = 0); + const char* color, + const PrintSettings& printSettings); static void printTails(ostream& s, const SymbolInfo& si, int pos, int nrTails, bool needAssocParen, - bool checkForInterrupt = false, - const char* color = 0); - static bool fancySpace(ostream& s, int spaceToken); + bool checkForInterrupt, + const char* color, + const PrintSettings& printSettings); + static bool fancySpace(ostream& s, int spaceToken, const PrintSettings& printSettings); static int chooseDisambiguator(Symbol* s); static void graphCount(DagNode* dagNode, PointerSet& visited, Vector& counts); static void makeIterName(string& name, int id, const mpz_class& number); @@ -624,54 +630,53 @@ private: // Member functions for Term* -> Vector& pretty printer. // static void prefix(Vector& buffer, bool needDisambig); - static void suffix(Vector& buffer, Term* term, bool needDisambig, int printFlags); + static void suffix(Vector& buffer, Term* term, bool needDisambig, const PrintSettings& printSettings); void prettyPrint(Vector& buffer, + const PrintSettings& printSettings, Term* term, int requiredPrec, int leftCapture, const ConnectedComponent* leftCaptureComponent, int rightCapture, const ConnectedComponent* rightCaptureComponent, - bool rangeKnown, - int printFlags); - - void handleVariable(Vector& buffer, Term* term, int printFlags); - bool handleIter(Vector& buffer, Term* term, SymbolInfo& si, bool rangeKnown, int printFlags); - bool handleMinus(Vector& buffer, Term* term, bool rangeKnown, int printFlags); - bool handleDivision(Vector& buffer, Term* term, bool rangeKnown, int printFlags); - void handleFloat(Vector& buffer, Term* term, bool rangeKnown, int printFlags); - void handleString(Vector& buffer, Term* term, bool rangeKnown, int printFlags); - void handleQuotedIdentifier(Vector& buffer, Term* term, bool rangeKnown, int printFlags); - void handleSMT_NumberSymbol(Vector& buffer, Term* term, bool rangeKnown, int printFlags); - - static void printKind(Vector& buffer, const Sort* kind, int printFlags); - static void printSort(Vector& buffer, const Sort* sort, int printFlags); - static void printDotSort(Vector& buffer, const Sort* sort, int printFlags); - static void printVarSort(Vector& buffer, string& fullName, const Sort* sort, int printFlags); - - int printTokens(Vector& buffer, const SymbolInfo& si, int pos, int printFlags); + bool rangeKnown); + void handleVariable(Vector& buffer, Term* term, const PrintSettings& printSettings); + bool handleIter(Vector& buffer, Term* term, SymbolInfo& si, bool rangeKnown, const PrintSettings& printSettings); + bool handleMinus(Vector& buffer, Term* term, bool rangeKnown, const PrintSettings& printSettings); + bool handleDivision(Vector& buffer, Term* term, bool rangeKnown, const PrintSettings& printSettings); + void handleFloat(Vector& buffer, Term* term, bool rangeKnown, const PrintSettings& printSettings); + void handleString(Vector& buffer, Term* term, bool rangeKnown, const PrintSettings& printSettings); + void handleQuotedIdentifier(Vector& buffer, Term* term, bool rangeKnown, const PrintSettings& printSettings); + void handleSMT_NumberSymbol(Vector& buffer, Term* term, bool rangeKnown, const PrintSettings& printSettings); + + static void printKind(Vector& buffer, const Sort* kind, const PrintSettings& printSettings); + static void printSort(Vector& buffer, const Sort* sort, const PrintSettings& printSettings); + static void printDotSort(Vector& buffer, const Sort* sort, const PrintSettings& printSettings); + static void printVarSort(Vector& buffer, string& fullName, const Sort* sort, const PrintSettings& printSettings); + + int printTokens(Vector& buffer, const SymbolInfo& si, int pos, const PrintSettings& printSettings); void printTails(Vector& buffer, const SymbolInfo& si, int pos, int nrTails, bool needAssocParen, - int printFlags); - void printPrefixName(Vector& buffer, int prefixName, SymbolInfo& si, int printFlags); + const PrintSettings& printSettings); + void printPrefixName(Vector& buffer, int prefixName, SymbolInfo& si, const PrintSettings& printSettings); void handleFormat(Vector& buffer, int spaceToken); // // Member functions for StrategyExpression* -> Vector& pretty printer. // void prettyPrint(Vector& buffer, - StrategyExpression* term, - int requiredPrec, - int printFlags); + const PrintSettings& printSettings, + StrategyExpression* expr, + int requiredPrec); void prettyPrint(Vector& buffer, const Vector& condition, - int printFlags); + const PrintSettings& printSettings); void prettyPrint(Vector& buffer, const ConditionFragment* fragment, - int printFlags); + const PrintSettings& printSettings); static Vector emptyGather; static Vector gatherAny; @@ -812,45 +817,54 @@ private: // // Member functions for DagNode* -> ostream& pretty printer. // - const char* computeColor(ColoringInfo& coloringInfo, DagNode* dagNode); - static void prefix(ostream& s, bool needDisambig, const char* color); + const char* computeColor(ColoringInfo& coloringInfo, DagNode* dagNode, const PrintSettings& printSettings); + static void prefix(ostream& s, bool needDisambig, const char* color = nullptr); static void suffix(ostream& s, DagNode* dagNode, bool needDisambig, const char* color); void handleFloat(ostream& s, DagNode* dagNode, bool rangeKnown, - const char* color); + const char* color, + const PrintSettings& printSettings); void handleString(ostream& s, DagNode* dagNode, bool rangeKnown, - const char* color); + const char* color, + const PrintSettings& printSettings); void handleQuotedIdentifier(ostream& s, DagNode* dagNode, bool rangeKnown, - const char* color); + const char* color, + const PrintSettings& printSettings); void handleVariable(ostream& s, DagNode* dagNode, bool rangeKnown, - const char* color); + const char* color, + const PrintSettings& printSettings); bool handleIter(ostream& s, ColoringInfo& coloringInfo, DagNode* dagNode, SymbolInfo& si, bool rangeKnown, - const char* color); + const char* color, + const PrintSettings& printSettings); bool handleMinus(ostream& s, DagNode* dagNode, bool rangeKnown, - const char* color); + const char* color, + const PrintSettings& printSettings); bool handleDivision(ostream& s, DagNode* dagNode, bool rangeKnown, - const char* color); + const char* color, + const PrintSettings& printSettings); void handleSMT_Number(ostream& s, DagNode* dagNode, bool rangeKnown, - const char* color); + const char* color, + const PrintSettings& printSettings); void prettyPrint(ostream& s, ColoringInfo& coloringInfo, + const PrintSettings& printSettings, DagNode* dagNode, int requiredPrec, int leftCapture, @@ -861,41 +875,43 @@ private: // // Member functions for Term* -> ostream& pretty printer. // - static const char* computeColor(SymbolType st); - static void suffix(ostream& s, Term* term, bool needDisambig, const char* color); + static const char* computeColor(SymbolType st, const PrintSettings& printSettings); + static void suffix(ostream& s, Term* term, bool needDisambig); bool handleIter(ostream& s, Term* term, SymbolInfo& si, bool rangeKnown, - const char* color); + const PrintSettings& printSettings); bool handleMinus(ostream& s, Term* term, bool rangeKnown, - const char* color); + const PrintSettings& printSettings); bool handleDivision(ostream& s, Term* term, bool rangeKnown, - const char* color); + const PrintSettings& printSettings); void handleFloat(ostream& s, Term* term, bool rangeKnown, - const char* color); + const PrintSettings& printSettings); void handleString(ostream& s, Term* term, bool rangeKnown, - const char* color); + const PrintSettings& printSettings); void handleQuotedIdentifier(ostream& s, Term* term, bool rangeKnown, - const char* color); + const PrintSettings& printSettings); void handleVariable(ostream& s, Term* term, bool rangeKnown, - const char* color); + const PrintSettings& printSettings); void handleSMT_Number(ostream& s, Term* term, bool rangeKnown, - const char* color); + const PrintSettings& printSettings); +public: void prettyPrint(ostream& s, + const PrintSettings& printSettings, Term* term, int requiredPrec, int leftCapture, @@ -903,37 +919,44 @@ private: int rightCapture, const ConnectedComponent* rightCaptureComponent, bool rangeKnown); +private: // // Common LaTeX functions. // - static void latexPrintPrefixName(ostream& s, const char* prefixName, const SymbolInfo& si); - static int latexPrintTokens(ostream& s, const SymbolInfo& si, int pos, const char* color); - static void latexPrefix(ostream& s, bool needDisambig, const char* color); + static void latexPrintPrefixName(ostream& s, const char* prefixName, const SymbolInfo& si, const PrintSettings& printSettings); + static int latexPrintTokens(ostream& s, const SymbolInfo& si, int pos, const char* color, const PrintSettings& printSettings); + static void latexPrefix(ostream& s, bool needDisambig, const char* color = nullptr); static void latexPrintTails(ostream& s, const SymbolInfo& si, int pos, int nrTails, bool needAssocParen, bool checkForInterrupt, - const char* color); - static bool latexFancySpace(ostream& s, int spaceToken); + const char* color, + const PrintSettings& printSettings); + static bool latexFancySpace(ostream& s, int spaceToken, const PrintSettings& printSettings); // // Member functions for Term* -> LaTeX pretty printer. // - static const char* latexComputeColor(SymbolType st); - static void latexSuffix(ostream& s, Term* term, bool needDisambig, const char* color); - bool latexHandleIter(ostream& s, Term* term, const SymbolInfo& si, bool rangeKnown, const char* color); - bool latexHandleMinus(ostream& s, Term* term, bool rangeKnown, const char* color) const; - bool latexHandleDivision(ostream& s, Term* term, bool rangeKnown, const char* color) const; - void latexHandleFloat(ostream& s, Term* term, bool rangeKnown, const char* color) const; - void latexHandleString(ostream& s, Term* term, bool rangeKnown, const char* color) const; - void latexHandleQuotedIdentifier(ostream& s, Term* term, bool rangeKnown, const char* color) const; - void latexHandleVariable(ostream& s, Term* term, bool rangeKnown, const char* color) const; - void latexHandleSMT_Number(ostream& s, Term* term, bool rangeKnown, const char* color); + static const char* latexComputeColor(SymbolType st, const PrintSettings& printSettings); + static void latexSuffix(ostream& s, Term* term, bool needDisambig); + bool latexHandleIter(ostream& s, + Term* term, + const SymbolInfo& si, + bool rangeKnown, + const PrintSettings& printSettings); + bool latexHandleMinus(ostream& s, Term* term, bool rangeKnown, const PrintSettings& printSettings) const; + bool latexHandleDivision(ostream& s, Term* term, bool rangeKnown, const PrintSettings& printSettings) const; + void latexHandleFloat(ostream& s, Term* term, bool rangeKnown, const PrintSettings& printSettings) const; + void latexHandleString(ostream& s, Term* term, bool rangeKnown, const PrintSettings& printSettings) const; + void latexHandleQuotedIdentifier(ostream& s, Term* term, bool rangeKnown, const PrintSettings& printSettings) const; + void latexHandleVariable(ostream& s, Term* term, bool rangeKnown, const PrintSettings& printSettings) const; + void latexHandleSMT_Number(ostream& s, Term* term, bool rangeKnown, const PrintSettings& printSettings); protected: void latexPrettyPrint(ostream& s, + const PrintSettings& printSettings, Term* term, int requiredPrec, int leftCapture, @@ -947,22 +970,24 @@ private: // // Member functions for DagNode* -> LaTeX pretty printer. // - static const char* latexComputeColor(ColoringInfo& coloringInfo, DagNode* dagNode); + static const char* latexComputeColor(ColoringInfo& coloringInfo, DagNode* dagNode, const PrintSettings& printSettings); static void latexSuffix(ostream& s, DagNode* dagNode, bool needDisambig, const char* color); bool latexHandleIter(ostream& s, ColoringInfo& coloringInfo, DagNode* dagNode, SymbolInfo& si, bool rangeKnown, - const char* color); - bool latexHandleMinus(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color); - bool latexHandleDivision(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color); - void latexHandleFloat(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color); - void latexHandleString(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color); - void latexHandleQuotedIdentifier(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color); - void latexHandleVariable(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color); - void latexHandleSMT_Number(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color); + const char* color, + const PrintSettings& printSettings); + bool latexHandleMinus(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color, const PrintSettings& printSettings); + bool latexHandleDivision(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color, const PrintSettings& printSettings); + void latexHandleFloat(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color, const PrintSettings& printSettings); + void latexHandleString(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color, const PrintSettings& printSettings); + void latexHandleQuotedIdentifier(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color, const PrintSettings& printSettings); + void latexHandleVariable(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color, const PrintSettings& printSettings); + void latexHandleSMT_Number(ostream& s, DagNode* dagNode, bool rangeKnown, const char* color, const PrintSettings& printSettings); void latexPrettyPrint(ostream& s, + const PrintSettings& printSettings, ColoringInfo& coloringInfo, DagNode* dagNode, int requiredPrec, @@ -972,9 +997,6 @@ private: const ConnectedComponent* rightCaptureComponent, bool rangeKnown); - static bool prettyPrint(ostream& s, - StrategyExpression* strategy, - int requiredPrec); NatSet objectSymbols; NatSet messageSymbols; NatSet portalSymbols; @@ -998,9 +1020,6 @@ private: static const char* latexMagenta; static const char* latexYellow; static const char* latexResetColor; - - friend ostream& operator<<(ostream& s, DagNode* dagNode); - friend ostream& operator<<(ostream& s, StrategyExpression* strategy); }; inline SymbolType @@ -1246,4 +1265,20 @@ MixfixModule::installStatementTransformer(StatementTransformer* st) statementTransformer = st; } +inline void +MixfixModule::clearIndent() +{ + globalIndent = 0; +} + +inline void +MixfixModule::clearColor(ostream& s) +{ + if (attributeUsed) + { + attributeUsed = false; + s << Tty(Tty::RESET); + } +} + #endif diff --git a/src/Mixfix/prettyPrint.cc b/src/Mixfix/prettyPrint.cc index f6d514ea..e54b8aeb 100644 --- a/src/Mixfix/prettyPrint.cc +++ b/src/Mixfix/prettyPrint.cc @@ -74,13 +74,11 @@ operator<<(ostream& s, const ConnectedComponent* component) void MixfixModule::prettyPrint(ostream& s, const Term* term, bool rangeKnown) { - globalIndent = 0; - safeCastNonNull(term->symbol()->getModule())->prettyPrint(s, const_cast(term), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, rangeKnown); - if (attributeUsed) - { - attributeUsed = false; - s << Tty(Tty::RESET); - } + clearIndent(); + MixfixModule* parentModule = safeCastNonNull(term->symbol()->getModule()); + const PrintSettings& printSettings = interpreter; // HACK + parentModule->prettyPrint(s, printSettings, const_cast(term), UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, rangeKnown); + clearColor(s); } ostream& @@ -90,36 +88,37 @@ operator<<(ostream& s, const Term* term) return s; } -ostream& -operator<<(ostream& s, DagNode* dagNode) +void +MixfixModule::prettyPrint(ostream& s, DagNode* dagNode, bool rangeKnown) { if (dagNode == 0) { s << "(null DagNode*)"; - return s; + return; } - MixfixModule::globalIndent = 0; - MixfixModule* module = static_cast(dagNode->symbol()->getModule()); - if (interpreter.getPrintFlag(Interpreter::PRINT_GRAPH)) - module->graphPrint(s, dagNode); + MixfixModule::clearIndent(); + MixfixModule* module = safeCastNonNull(dagNode->symbol()->getModule()); + const PrintSettings& printSettings = interpreter; // HACK + if (printSettings.getPrintFlag(PrintSettings::PRINT_GRAPH)) + module->graphPrint(s, dagNode, printSettings); else { MixfixModule::ColoringInfo coloringInfo; - if (interpreter.getPrintFlag(Interpreter::PRINT_COLOR)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_COLOR)) { - MixfixModule::computeGraphStatus(dagNode, - coloringInfo.visited, - coloringInfo.statusVec); + MixfixModule::computeGraphStatus(dagNode, coloringInfo.visited, coloringInfo.statusVec); coloringInfo.reducedAbove = false; coloringInfo.reducedDirectlyAbove = false; } - module->prettyPrint(s, coloringInfo, dagNode, UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, false); - } - if (MixfixModule::attributeUsed) - { - MixfixModule::attributeUsed = false; - s << Tty(Tty::RESET); + module->prettyPrint(s, coloringInfo, printSettings, dagNode, UNBOUNDED, UNBOUNDED, 0, UNBOUNDED, 0, rangeKnown); } + MixfixModule::clearColor(s); +} + +ostream& +operator<<(ostream& s, DagNode* dagNode) +{ + MixfixModule::prettyPrint(s, dagNode); return s; } @@ -127,7 +126,7 @@ void MixfixModule::printAttributes(ostream& s, const PreEquation* pe, ItemType itemType) { const Label& l = pe->getLabel(); - int id = interpreter.getPrintFlag(Interpreter::PRINT_LABEL_ATTRIBUTE) ? l.id() : NONE; + int id = interpreter.getPrintFlag(PrintSettings::PRINT_LABEL_ATTRIBUTE) ? l.id() : NONE; const Equation* eq = dynamic_cast(pe); const Rule* rl = dynamic_cast(pe); bool owise = eq != 0 && eq->isOwise(); @@ -179,13 +178,14 @@ MixfixModule::printAttributes(ostream& s, const PreEquation* pe, ItemType itemTy s << ']'; } + ostream& operator<<(ostream& s, const SortConstraint* sc) { if (sc->hasCondition()) s << 'c'; s << "mb "; - if (!interpreter.getPrintFlag(Interpreter::PRINT_LABEL_ATTRIBUTE)) + if (!interpreter.getPrintFlag(PrintSettings::PRINT_LABEL_ATTRIBUTE)) { const Label& l = sc->getLabel(); if (l.id() != NONE) @@ -207,7 +207,7 @@ operator<<(ostream& s, const Equation* e) if (e->hasCondition()) s << 'c'; s << "eq "; - if (!interpreter.getPrintFlag(Interpreter::PRINT_LABEL_ATTRIBUTE)) + if (!interpreter.getPrintFlag(PrintSettings::PRINT_LABEL_ATTRIBUTE)) { const Label& l = e->getLabel(); if (l.id() != NONE) @@ -229,7 +229,7 @@ operator<<(ostream& s, const Rule* r) if (r->hasCondition()) s << 'c'; s << "rl "; - if (!interpreter.getPrintFlag(Interpreter::PRINT_LABEL_ATTRIBUTE)) + if (!interpreter.getPrintFlag(PrintSettings::PRINT_LABEL_ATTRIBUTE)) { const Label& l = r->getLabel(); if (l.id() != NONE) @@ -360,7 +360,7 @@ MixfixModule::printCondition(ostream& s, const PreEquation* pe) } void -MixfixModule::printVariable(ostream& s, int name, Sort* sort) const +MixfixModule::printVariable(ostream& s, int name, Sort* sort, const PrintSettings& printSettings) const { if (Token::isFlagged(name)) { @@ -373,7 +373,7 @@ MixfixModule::printVariable(ostream& s, int name, Sort* sort) const name = Token::unflaggedCode(name); } s << Token::name(name); - if (interpreter.getPrintFlag(Interpreter::PRINT_WITH_ALIASES)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_WITH_ALIASES)) { AliasMap::const_iterator i = variableAliases.find(name); if (i != variableAliases.end() && (*i).second == sort) @@ -383,13 +383,13 @@ MixfixModule::printVariable(ostream& s, int name, Sort* sort) const } void -MixfixModule::printPrefixName(ostream& s, const char* prefixName, SymbolInfo& si) +MixfixModule::printPrefixName(ostream& s, const char* prefixName, SymbolInfo& si, const PrintSettings& printSettings) { - if (interpreter.getPrintFlag(Interpreter::PRINT_FORMAT) && (si.format.length() == 2)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_FORMAT) && (si.format.length() == 2)) { - fancySpace(s, si.format[0]); + fancySpace(s, si.format[0], printSettings); s << prefixName; - fancySpace(s, si.format[1]); + fancySpace(s, si.format[1], printSettings); } else s << prefixName; @@ -399,10 +399,11 @@ int MixfixModule::printTokens(ostream& s, const SymbolInfo& si, int pos, - const char* color) + const char* color, + const PrintSettings& printSettings) { bool noSpace = (pos == 0); - bool hasFormat = interpreter.getPrintFlag(Interpreter::PRINT_FORMAT) && (si.format.length() > 0); + bool hasFormat = printSettings.getPrintFlag(PrintSettings::PRINT_FORMAT) && (si.format.length() > 0); for (;;) { int token = si.mixfixSyntax[pos++]; @@ -411,7 +412,7 @@ MixfixModule::printTokens(ostream& s, bool special = (token == leftParen || token == rightParen || token == leftBracket || token == rightBracket || token == leftBrace || token == rightBrace); - if (!((hasFormat && fancySpace(s, si.format[pos - 1])) || special || noSpace || token == comma)) + if (!((hasFormat && fancySpace(s, si.format[pos - 1], printSettings)) || special || noSpace || token == comma)) s << ' '; noSpace = special || (hasFormat && token == comma); if (color != 0) @@ -420,7 +421,7 @@ MixfixModule::printTokens(ostream& s, if (color != 0) s << Tty(Tty::RESET); } - if (!((hasFormat && fancySpace(s, si.format[pos - 1])) || noSpace)) + if (!((hasFormat && fancySpace(s, si.format[pos - 1], printSettings)) || noSpace)) s << ' '; return pos; } @@ -432,9 +433,10 @@ MixfixModule::printTails(ostream& s, int nrTails, bool needAssocParen, bool checkForInterrupt, - const char* color) + const char* color, + const PrintSettings& printSettings) { - bool hasFormat = interpreter.getPrintFlag(Interpreter::PRINT_FORMAT) && (si.format.length() > 0); + bool hasFormat = printSettings.getPrintFlag(PrintSettings::PRINT_FORMAT) && (si.format.length() > 0); int mixfixLength = si.mixfixSyntax.length(); for (int i = 0;;) { @@ -447,7 +449,7 @@ MixfixModule::printTails(ostream& s, bool special = (token == leftParen || token == rightParen || token == leftBracket || token == rightBracket || token == leftBrace || token == rightBrace); - if (!((hasFormat && fancySpace(s, si.format[j])) || special || noSpace || token == comma)) + if (!((hasFormat && fancySpace(s, si.format[j], printSettings)) || special || noSpace || token == comma)) s << ' '; noSpace = special || (hasFormat && token == comma); if (color != 0) @@ -457,7 +459,7 @@ MixfixModule::printTails(ostream& s, s << Tty(Tty::RESET); } if (hasFormat) - (void) fancySpace(s, si.format[mixfixLength]); + (void) fancySpace(s, si.format[mixfixLength], printSettings); if (++i == nrTails) break; if (needAssocParen) @@ -466,7 +468,7 @@ MixfixModule::printTails(ostream& s, } bool -MixfixModule::fancySpace(ostream& s, int spaceToken) +MixfixModule::fancySpace(ostream& s, int spaceToken, const PrintSettings& printSettings) { bool space = false; for (const char* cmd = Token::name(spaceToken); *cmd; cmd++) @@ -515,7 +517,7 @@ MixfixModule::fancySpace(ostream& s, int spaceToken) } default: { - if (interpreter.getPrintFlag(Interpreter::PRINT_COLOR)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_COLOR)) break; switch (c) { diff --git a/src/Mixfix/printSettings.hh b/src/Mixfix/printSettings.hh new file mode 100644 index 00000000..6e3cb57a --- /dev/null +++ b/src/Mixfix/printSettings.hh @@ -0,0 +1,114 @@ +/* + + This file is part of the Maude 3 interpreter. + + Copyright 2023 SRI International, Menlo Park, CA 94025, USA. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +*/ + +// +// Class to hold settings controlling printing of various entities. +// +#ifndef _printSettings_hh_ +#define _printSettings_hh_ +#include + +class PrintSettings +{ + NO_COPYING(PrintSettings); + +public: + enum PrintFlags : uint_fast32_t + { + PRINT_CLEARED_FLAGS = 0, + // + // General prettyprinter flags. + // + PRINT_GRAPH = 0x1, // print as a set of DAG nodes + PRINT_CONCEAL = 0x2, // respect concealed argument lists + PRINT_FORMAT = 0x4, // respect format attribute + PRINT_MIXFIX = 0x8, // mixfix notation + PRINT_WITH_PARENS = 0x10, // maximal parens + PRINT_COLOR = 0x20, // dag node coloring based on ctor/reduced status + PRINT_DISAMBIG_CONST = 0x40, // (c).s for every constant c + PRINT_LABEL_ATTRIBUTE = 0x80, // use [label foo] after statement rather than [foo] : before statement + // + // Prettyprinter flags for particular symbol types. + // + PRINT_WITH_ALIASES = 0x100, // for variables + PRINT_FLAT = 0x200, // for assoc symbols + PRINT_NUMBER = 0x400, // for nats & ints + PRINT_RAT = 0x800, // for rats + PRINT_HOOKS = 0x1000, // for built-ins + PRINT_COMBINE_VARS = 0x2000, // for variables + + DEFAULT_PRINT_FLAGS = PRINT_FORMAT | PRINT_MIXFIX | PRINT_WITH_ALIASES | PRINT_FLAT | PRINT_NUMBER | PRINT_RAT | PRINT_HOOKS + }; + + PrintSettings(PrintFlags initialValue = PRINT_CLEARED_FLAGS); + + void setPrintFlag(PrintFlags flag, bool polarity = true); + bool getPrintFlag(PrintFlags flag) const; + void insertConcealed(int symbolId); + void eraseConcealed(int symbolId); + bool concealedSymbol(int symbolId) const; + +private: + PrintFlags printFlags; + set concealedSymbols; +}; + +inline +PrintSettings::PrintSettings(PrintFlags initialValue) +{ + printFlags = initialValue; +} + +inline bool +PrintSettings::getPrintFlag(PrintFlags flag) const +{ + return printFlags & flag; +} + +inline void +PrintSettings::setPrintFlag(PrintFlags flag, bool polarity) +{ + if (polarity) + printFlags = static_cast(printFlags | flag); + else + printFlags = static_cast(printFlags & ~flag); +} + +inline void +PrintSettings::insertConcealed(int symbolId) +{ + concealedSymbols.insert(symbolId); +} + +inline void +PrintSettings::eraseConcealed(int symbolId) +{ + concealedSymbols.erase(symbolId); +} + +inline bool +PrintSettings::concealedSymbol(int symbolId) const +{ + return getPrintFlag(PRINT_CONCEAL) && concealedSymbols.find(symbolId) != concealedSymbols.end(); +} + +#endif diff --git a/src/Mixfix/quotedIdentifierOpSymbol.cc b/src/Mixfix/quotedIdentifierOpSymbol.cc index bbded20c..45344b79 100644 --- a/src/Mixfix/quotedIdentifierOpSymbol.cc +++ b/src/Mixfix/quotedIdentifierOpSymbol.cc @@ -339,14 +339,26 @@ QuotedIdentifierOpSymbol::printQid(DagNode* qid, bool& ansiActive, bool& needSpa { char c = s[1]; if (Token::specialChar(c) && s[2] == '\0') - { - // - // ( ) [ ] { } , case - // - output += (s + 1); - needSpace = (c != '(') && (c != '[') && (c != '{'); - return true; - } + { + // + // ( ) [ ] { } , case + // + if (c == '(' || c == '[' || c != '{') + { + if (needSpace) + output += " "; + needSpace = false; + } + else + { + // + // No space before ) ] } , but space after unless following token doesn't need one. + // + needSpace = true; + } + output += (s + 1); + return true; + } break; } case '\\': diff --git a/src/Mixfix/sharedPrint.cc b/src/Mixfix/sharedPrint.cc index e08e1d27..32f9480a 100644 --- a/src/Mixfix/sharedPrint.cc +++ b/src/Mixfix/sharedPrint.cc @@ -159,3 +159,13 @@ MixfixModule::decideIteratedAmbiguity(bool rangeKnown, if ((overloadType & RANGE_OVERLOADED) || (!rangeKnown && !needToDisambiguate)) argumentRangeKnown = false; } + +Sort* +MixfixModule::disambiguatorSort(const Term* term) +{ + Symbol* symbol = term->symbol(); + int sortIndex = term->getSortIndex(); + if (sortIndex <= Sort::ERROR_SORT) + sortIndex = chooseDisambiguator(symbol); + return symbol->rangeComponent()->sort(sortIndex); +} diff --git a/src/Mixfix/specialTokens.cc b/src/Mixfix/specialTokens.cc index 0e4556bf..130c7078 100644 --- a/src/Mixfix/specialTokens.cc +++ b/src/Mixfix/specialTokens.cc @@ -127,6 +127,7 @@ MACRO(amatchrew, "amatchrew") MACRO(by, "by") MACRO(irreducible, "irreducible") + MACRO(ellipsis, "..."); // // Special hook identifier tokens. // diff --git a/src/Mixfix/termPrint.cc b/src/Mixfix/termPrint.cc index 0218cce1..72e8fbea 100644 --- a/src/Mixfix/termPrint.cc +++ b/src/Mixfix/termPrint.cc @@ -25,22 +25,26 @@ // const char* -MixfixModule::computeColor(SymbolType st) +MixfixModule::computeColor(SymbolType st, const PrintSettings& printSettings) { - if (interpreter.getPrintFlag(Interpreter::PRINT_COLOR)) + // + // For terms, automatically generated color (as opposed to format generated color) is based + // on the axioms of each operator symbol. + // AC : red + // ACU : magenta + // A : green + // AU : cyan + // C/CU : blue + // U : yellow + // + if (printSettings.getPrintFlag(PrintSettings::PRINT_COLOR)) { if (st.hasFlag(SymbolType::ASSOC)) { if (st.hasFlag(SymbolType::COMM)) - { - return Tty(st.hasFlag(SymbolType::LEFT_ID | SymbolType::RIGHT_ID) ? - Tty::MAGENTA : Tty::RED).ctrlSequence(); - } + return Tty(st.hasFlag(SymbolType::LEFT_ID | SymbolType::RIGHT_ID) ? Tty::MAGENTA : Tty::RED).ctrlSequence(); else - { - return Tty(st.hasFlag(SymbolType::LEFT_ID | SymbolType::RIGHT_ID) ? - Tty::CYAN : Tty::GREEN).ctrlSequence(); - } + return Tty(st.hasFlag(SymbolType::LEFT_ID | SymbolType::RIGHT_ID) ? Tty::CYAN : Tty::GREEN).ctrlSequence(); } if (st.hasFlag(SymbolType::COMM)) return Tty(Tty::BLUE).ctrlSequence(); @@ -51,46 +55,33 @@ MixfixModule::computeColor(SymbolType st) } void -MixfixModule::suffix(ostream& s, - Term* term, - bool needDisambig, - const char* /* color */) +MixfixModule::suffix(ostream& s, Term* term, bool needDisambig) { if (needDisambig) s << ")." << disambiguatorSort(term); } -Sort* -MixfixModule::disambiguatorSort(const Term* term) -{ - Symbol* symbol = term->symbol(); - int sortIndex = term->getSortIndex(); - if (sortIndex <= Sort::ERROR_SORT) - sortIndex = chooseDisambiguator(symbol); - return symbol->rangeComponent()->sort(sortIndex); -} - bool MixfixModule::handleIter(ostream& s, Term* term, SymbolInfo& si, bool rangeKnown, - const char* color) + const PrintSettings& printSettings) { if (!(si.symbolType.hasFlag(SymbolType::ITER))) return false; if (si.symbolType.getBasicType() == SymbolType::SUCC_SYMBOL && - interpreter.getPrintFlag(Interpreter::PRINT_NUMBER)) + printSettings.getPrintFlag(PrintSettings::PRINT_NUMBER)) { SuccSymbol* succSymbol = safeCast(SuccSymbol*, term->symbol()); if (succSymbol->isNat(term)) { const mpz_class& nat = succSymbol->getNat(term); - bool needDisambig = !rangeKnown && - (kindsWithSucc.size() > 1 || overloadedIntegers.count(nat)); - prefix(s, needDisambig, color); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (kindsWithSucc.size() > 1 || overloadedIntegers.count(nat))); + prefix(s, needDisambig); s << nat; - suffix(s, term, needDisambig, color); + suffix(s, term, needDisambig); return true; } } @@ -107,15 +98,12 @@ MixfixModule::handleIter(ostream& s, string prefixName; makeIterName(prefixName, term->symbol()->id(), number); - if (color != 0) - s << color << prefixName << Tty(Tty::RESET); - else - printPrefixName(s, prefixName.c_str(), si); + printPrefixName(s, prefixName.c_str(), si, printSettings); s << '('; - prettyPrint(s, st->getArgument(), + prettyPrint(s, printSettings, st->getArgument(), PREFIX_GATHER, UNBOUNDED, 0, UNBOUNDED, 0, argumentRangeKnown); s << ')'; - suffix(s, term, needToDisambiguate, color); + suffix(s, term, needToDisambiguate); return true; } @@ -123,20 +111,20 @@ bool MixfixModule::handleMinus(ostream& s, Term* term, bool rangeKnown, - const char* color) + const PrintSettings& printSettings) { - if (interpreter.getPrintFlag(Interpreter::PRINT_NUMBER)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_NUMBER)) { const MinusSymbol* minusSymbol = safeCast(MinusSymbol*, term->symbol()); if (minusSymbol->isNeg(term)) { mpz_class neg; (void) minusSymbol->getNeg(term, neg); - bool needDisambig = !rangeKnown && - (kindsWithMinus.size() > 1 || overloadedIntegers.count(neg)); - prefix(s, needDisambig, color); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (kindsWithMinus.size() > 1 || overloadedIntegers.count(neg))); + prefix(s, needDisambig); s << neg; - suffix(s, term, needDisambig, color); + suffix(s, term, needDisambig); return true; } } @@ -147,20 +135,20 @@ bool MixfixModule::handleDivision(ostream& s, Term* term, bool rangeKnown, - const char* color) + const PrintSettings& printSettings) { - if (interpreter.getPrintFlag(Interpreter::PRINT_RAT)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_RAT)) { const DivisionSymbol* divisionSymbol = safeCast(DivisionSymbol*, term->symbol()); if (divisionSymbol->isRat(term)) { pair rat; rat.second = divisionSymbol->getRat(term, rat.first); - bool needDisambig = !rangeKnown && - (kindsWithDivision.size() > 1 || overloadedRationals.count(rat)); - prefix(s, needDisambig, color); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (kindsWithDivision.size() > 1 || overloadedRationals.count(rat))); + prefix(s, needDisambig); s << rat.first << '/' << rat.second; - suffix(s, term, needDisambig, color); + suffix(s, term, needDisambig); return true; } } @@ -171,66 +159,65 @@ void MixfixModule::handleFloat(ostream& s, Term* term, bool rangeKnown, - const char* color) + const PrintSettings& printSettings) { double mfValue = safeCast(FloatTerm*, term)->getValue(); - bool needDisambig = !rangeKnown && - (floatSymbols.size() > 1 || overloadedFloats.count(mfValue)); - prefix(s, needDisambig, color); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (floatSymbols.size() > 1 || overloadedFloats.count(mfValue))); + prefix(s, needDisambig); s << doubleToString(mfValue); - suffix(s, term, needDisambig, color); + suffix(s, term, needDisambig); } void MixfixModule::handleString(ostream& s, Term* term, bool rangeKnown, - const char* color) + const PrintSettings& printSettings) { string strValue; Token::ropeToString(safeCast(StringTerm*, term)->getValue(), strValue); - bool needDisambig = !rangeKnown && - (stringSymbols.size() > 1 || overloadedStrings.count(strValue)); - prefix(s, needDisambig, color); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (stringSymbols.size() > 1 || overloadedStrings.count(strValue))); + prefix(s, needDisambig); s << strValue; - suffix(s, term, needDisambig, color); + suffix(s, term, needDisambig); } void MixfixModule::handleQuotedIdentifier(ostream& s, Term* term, bool rangeKnown, - const char* color) + const PrintSettings& printSettings) { int qidCode = safeCast(QuotedIdentifierTerm*, term)->getIdIndex(); - bool needDisambig = !rangeKnown && - (quotedIdentifierSymbols.size() > 1 || - overloadedQuotedIdentifiers.count(qidCode)); - prefix(s, needDisambig, color); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (quotedIdentifierSymbols.size() > 1 || overloadedQuotedIdentifiers.count(qidCode))); + prefix(s, needDisambig); s << '\'' << Token::name(qidCode); - suffix(s, term, needDisambig, color); + suffix(s, term, needDisambig); } void MixfixModule::handleVariable(ostream& s, Term* term, bool rangeKnown, - const char* color) + const PrintSettings& printSettings) { VariableTerm* v = safeCast(VariableTerm*, term); Sort* sort = safeCast(VariableSymbol*, term->symbol())->getSort(); pair p(v->id(), sort->id()); bool needDisambig = !rangeKnown && overloadedVariables.count(p); // kinds not handled - prefix(s, needDisambig, color); - printVariable(s, p.first, sort); - suffix(s, term, needDisambig, color); + prefix(s, needDisambig); + printVariable(s, p.first, sort, printSettings); + suffix(s, term, needDisambig); } void MixfixModule::handleSMT_Number(ostream& s, Term* term, bool rangeKnown, - const char* color) + const PrintSettings& printSettings) { // // Get value. @@ -250,26 +237,27 @@ MixfixModule::handleSMT_Number(ostream& s, if (t == SMT_Info::INTEGER) { const mpz_class& integer = value.get_num(); - bool needDisambig = !rangeKnown && - (kindsWithSucc.size() > 1 || overloadedIntegers.count(integer)); - prefix(s, needDisambig, color); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (kindsWithSucc.size() > 1 || overloadedIntegers.count(integer))); + prefix(s, needDisambig); s << integer; - suffix(s, term, needDisambig, color); + suffix(s, term, needDisambig); } else { Assert(t == SMT_Info::REAL, "SMT number sort expected"); pair rat(value.get_num(), value.get_den()); - bool needDisambig = !rangeKnown && - (kindsWithDivision.size() > 1 || overloadedRationals.count(rat)); - prefix(s, needDisambig, color); + bool needDisambig = printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST) || + (!rangeKnown && (kindsWithDivision.size() > 1 || overloadedRationals.count(rat))); + prefix(s, needDisambig); s << rat.first << '/' << rat.second; - suffix(s, term, needDisambig, color); + suffix(s, term, needDisambig); } } void MixfixModule::prettyPrint(ostream& s, + const PrintSettings& printSettings, Term* term, int requiredPrec, int leftCapture, @@ -283,50 +271,49 @@ MixfixModule::prettyPrint(ostream& s, Symbol* symbol = term->symbol(); SymbolInfo& si = symbolInfo[symbol->getIndexWithinModule()]; - const char* color = computeColor(si.symbolType); // // Check for special i/o representation. // - if (handleIter(s, term, si, rangeKnown, color)) + if (handleIter(s, term, si, rangeKnown, printSettings)) return; int basicType = si.symbolType.getBasicType(); switch (basicType) { case SymbolType::MINUS_SYMBOL: { - if (handleMinus(s, term, rangeKnown, color)) + if (handleMinus(s, term, rangeKnown, printSettings)) return; break; } case SymbolType::DIVISION_SYMBOL: { - if (handleDivision(s, term, rangeKnown, color)) + if (handleDivision(s, term, rangeKnown, printSettings)) return; break; } case SymbolType::FLOAT: { - handleFloat(s, term, rangeKnown, color); + handleFloat(s, term, rangeKnown, printSettings); return; } case SymbolType::STRING: { - handleString(s, term, rangeKnown, color); + handleString(s, term, rangeKnown, printSettings); return; } case SymbolType::QUOTED_IDENTIFIER: { - handleQuotedIdentifier(s, term, rangeKnown, color); + handleQuotedIdentifier(s, term, rangeKnown, printSettings); return; } case SymbolType::VARIABLE: { - handleVariable(s, term, rangeKnown, color); + handleVariable(s, term, rangeKnown, printSettings); return; } case SymbolType::SMT_NUMBER_SYMBOL: { - handleSMT_Number(s, term, rangeKnown, color); + handleSMT_Number(s, term, rangeKnown, printSettings); return; } default: @@ -335,26 +322,27 @@ MixfixModule::prettyPrint(ostream& s, // // Default case where no special i/o representation applies. // + const char* color = computeColor(si.symbolType, printSettings); int iflags = si.iflags; bool needDisambig = !rangeKnown && ambiguous(iflags); bool argRangeKnown = false; int nrArgs = symbol->arity(); if (nrArgs == 0) { - if (interpreter.getPrintFlag(Interpreter::PRINT_DISAMBIG_CONST)) + if (printSettings.getPrintFlag(PrintSettings::PRINT_DISAMBIG_CONST)) needDisambig = true; } else argRangeKnown = rangeOfArgumentsKnown(iflags, rangeKnown, needDisambig); - - if (needDisambig) - s << '('; - if ((interpreter.getPrintFlag(Interpreter::PRINT_MIXFIX) && !si.mixfixSyntax.empty()) || basicType == SymbolType::SORT_TEST) + + prefix(s, needDisambig); + bool printConceal = printSettings.concealedSymbol(symbol->id()); + if ((printSettings.getPrintFlag(PrintSettings::PRINT_MIXFIX) && !si.mixfixSyntax.empty() && !printConceal) || basicType == SymbolType::SORT_TEST) { // // Mixfix case. // - bool printWithParens = interpreter.getPrintFlag(Interpreter::PRINT_WITH_PARENS); + bool printWithParens = printSettings.getPrintFlag(PrintSettings::PRINT_WITH_PARENS); bool needParen = !needDisambig && (printWithParens || requiredPrec < si.prec || ((iflags & LEFT_BARE) && leftCapture <= si.gather[0] && @@ -376,14 +364,14 @@ MixfixModule::prettyPrint(ostream& s, Term* t = a.argument(); a.next(); moreArgs = a.valid(); - pos = printTokens(s, si, pos, color); + pos = printTokens(s, si, pos, color, printSettings); if (arg == nrArgs - 1 && moreArgs) { ++nrTails; arg = 0; if (needAssocParen) s << '('; - pos = printTokens(s, si, 0, color); + pos = printTokens(s, si, 0, color, printSettings); } int lc = UNBOUNDED; const ConnectedComponent* lcc = 0; @@ -409,11 +397,11 @@ MixfixModule::prettyPrint(ostream& s, rcc = rightCaptureComponent; } } - prettyPrint(s, t, si.gather[arg], lc, lcc, rc, rcc, argRangeKnown); + prettyPrint(s, printSettings, t, si.gather[arg], lc, lcc, rc, rcc, argRangeKnown); if (UserLevelRewritingContext::interrupted()) return; } - printTails(s, si, pos, nrTails, needAssocParen, true, color); + printTails(s, si, pos, nrTails, needAssocParen, true, color, printSettings); if (UserLevelRewritingContext::interrupted()) return; if (needParen) @@ -428,41 +416,46 @@ MixfixModule::prettyPrint(ostream& s, if (color != 0) s << color << prefixName << Tty(Tty::RESET); else - printPrefixName(s, prefixName, si); + printPrefixName(s, prefixName, si, printSettings); ArgumentIterator a(*term); if (a.valid()) { - int nrTails = 1; - s << '('; - for (int arg = 0;; arg++) + if (printConceal) + s << "(...)"; + else { - Term* t = a.argument(); - a.next(); - int moreArgs = a.valid(); - if (arg >= nrArgs - 1 && - !(interpreter.getPrintFlag(Interpreter::PRINT_FLAT)) && - moreArgs) + int nrTails = 1; + s << '('; + for (int arg = 0;; arg++) { - ++nrTails; - printPrefixName(s, prefixName, si); - s << '('; + Term* t = a.argument(); + a.next(); + int moreArgs = a.valid(); + if (arg >= nrArgs - 1 && + !(printSettings.getPrintFlag(PrintSettings::PRINT_FLAT)) && + moreArgs) + { + ++nrTails; + printPrefixName(s, prefixName, si, printSettings); + s << '('; + } + prettyPrint(s, printSettings, t, + PREFIX_GATHER, UNBOUNDED, 0, UNBOUNDED, 0, + argRangeKnown); + if (UserLevelRewritingContext::interrupted()) + return; + if (!moreArgs) + break; + s << ", "; + } + while (nrTails-- > 0) + { + if (UserLevelRewritingContext::interrupted()) + return; + s << ')'; } - prettyPrint(s, t, - PREFIX_GATHER, UNBOUNDED, 0, UNBOUNDED, 0, - argRangeKnown); - if (UserLevelRewritingContext::interrupted()) - return; - if (!moreArgs) - break; - s << ", "; - } - while (nrTails-- > 0) - { - if (UserLevelRewritingContext::interrupted()) - return; - s << ')'; } } } - suffix(s, term, needDisambig, color); + suffix(s, term, needDisambig); } diff --git a/src/Mixfix/token.cc b/src/Mixfix/token.cc index 7f14a8de..6d2ce52a 100644 --- a/src/Mixfix/token.cc +++ b/src/Mixfix/token.cc @@ -98,12 +98,7 @@ Token::printTokenVector(ostream& s, { if (c == ')' || c == ']' || c == '}' || c == ',') needSpace = false; - else if (c == '(') - { - needSpace = false; - nextNeedSpace = false; - } - else if (c == '[' || c == '{') + else if (c == '(' || c == '[' || c == '{') nextNeedSpace = false; } if (needSpace) diff --git a/src/Mixfix/visibleModule.cc b/src/Mixfix/visibleModule.cc index ed19fcf7..8a5f01e4 100644 --- a/src/Mixfix/visibleModule.cc +++ b/src/Mixfix/visibleModule.cc @@ -70,7 +70,6 @@ // front end class definitions #include "userLevelRewritingContext.hh" #include "visibleModule.hh" - #include "interpreter.hh" // our stuff diff --git a/src/Utility/ChangeLog b/src/Utility/ChangeLog index 4302818c..919b315d 100644 --- a/src/Utility/ChangeLog +++ b/src/Utility/ChangeLog @@ -1,3 +1,11 @@ +2023-11-21 Steven Eker + + * rope.hh (class Rope): added decl for ctor from std::string + + * rope.cc (Rope::Rope): added ctor from std::string + +===================================Maude154=================================== + 2023-09-28 Steven Eker * macros.hh: #include diff --git a/src/Utility/rope.cc b/src/Utility/rope.cc index cee7cf47..579b70c1 100644 --- a/src/Utility/rope.cc +++ b/src/Utility/rope.cc @@ -85,6 +85,19 @@ Rope::Rope(const char* cString, size_type n) ptr = makeTree(cString, n, nrLeaves); } +Rope::Rope(const string& str) +{ + size_type n = str.size(); + if (n == 0) + { + ptr = 0; + return; + } + + size_type nrLeaves = (n + (TEXT_SIZE - 1)) / TEXT_SIZE; + ptr = makeTree(str.c_str(), n, nrLeaves); +} + Rope::~Rope() { decCount(ptr); diff --git a/src/Utility/rope.hh b/src/Utility/rope.hh index 6b055457..5883de15 100644 --- a/src/Utility/rope.hh +++ b/src/Utility/rope.hh @@ -56,6 +56,7 @@ public: Rope(char c); Rope(const char* cString); Rope(const char* cString, size_type n); + Rope(const string& str); ~Rope(); diff --git a/tests/Corner/badView.expected b/tests/Corner/badView.expected index 4e65eb31..e2f9b351 100644 --- a/tests/Corner/badView.expected +++ b/tests/Corner/badView.expected @@ -82,7 +82,7 @@ view V from T to M is sort Foo to Baz . var M : Oid . var X : Foo . - msg m(M, X) to term m'(M, translate(X)) . + msg m (M, X) to term m' (M, translate (X)) . endv view V from T to M is sort Foo to Baz . @@ -290,7 +290,7 @@ view V from T to M is sort Foo to Baz . var M : Oid . var X : Foo . - msg m(M, X) to term m'(M, translate(X)) . + msg m (M, X) to term m' (M, translate (X)) . endv view V from T to M is sort Foo to Baz . @@ -502,7 +502,7 @@ view V from T to M is sort Foo to Baz . var M : Oid . var X : Foo . - msg m(M, X) to term m'(M, translate(X)) . + msg m (M, X) to term m' (M, translate (X)) . endv view V from T to M is sort Foo to Baz . diff --git a/tests/Meta/metaIntPrelude.expected b/tests/Meta/metaIntPrelude.expected index 80ff362a..208eeee9 100644 --- a/tests/Meta/metaIntPrelude.expected +++ b/tests/Meta/metaIntPrelude.expected @@ -381,6 +381,9 @@ result Configuration: <> < me : User | pending(nil) > reducedTerm(me, ''`[Module`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind], ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, 'none.AttrSet], 'op_:_->_`[_`].[''metaPrettyPrint.Sort, '__[''`[Module`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, ''`[PrintOptionSet`].Kind], ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, 'none.AttrSet], 'op_:_->_`[_`].[''metaPrettyPrint.Sort, '__[''`[Module`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, ''`[PrintOptionSet`].Kind], ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, + 'none.AttrSet], 'op_:_->_`[_`].[''metaPrettyPrint.Sort, '__[ + ''`[Module`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, + ''`[PrintOptionSet`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind], ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, 'special['__['id-hook[''MetaLevelOpSymbol.Sort, ''metaPrettyPrint.Sort], 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, ''QidList.Sort], ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[ @@ -388,14 +391,19 @@ result Configuration: <> < me : User | pending(nil) > reducedTerm(me, ''`[StrategyList`,Strategy?`].Kind, ''`[PrintOptionSet`].Kind], ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, 'special['__['id-hook[''MetaLevelOpSymbol.Sort, ''metaPrettyPrintStrategy.Sort], 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, ''QidList.Sort], - ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[''metaReduce.Sort, '__[ - ''`[Module`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind], ''`[ResultPair?`].Kind, 'special[ - '__['id-hook[''MetaLevelOpSymbol.Sort, ''metaReduce.Sort], 'op-hook[ - ''qidSymbol.Sort, ''.Sort, 'nil.TypeList, ''Qid.Sort], 'op-hook[ - ''metaTermSymbol.Sort, ''_`[_`].Qid, '__[''Qid.Sort, ''NeCTermList.Sort], - ''Context.Sort], 'op-hook[''metaArgSymbol.Sort, ''_`,_.Qid, '__[ - ''GTermList.Sort, ''GTermList.Sort], ''GTermList.Sort], 'op-hook[ - ''emptyTermListSymbol.Sort, ''empty.Sort, 'nil.TypeList, + ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[''metaPrintToString.Sort, '__[ + ''`[Module`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, + ''`[PrintOptionSet`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind], ''`[String`].Kind, + 'special['__['id-hook[''MetaLevelOpSymbol.Sort, ''metaPrintToString.Sort], + 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, + ''QidList.Sort], ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[''metaReduce.Sort, + '__[''`[Module`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind], ''`[ResultPair?`].Kind, + 'special['__['id-hook[''MetaLevelOpSymbol.Sort, ''metaReduce.Sort], + 'op-hook[''qidSymbol.Sort, ''.Sort, 'nil.TypeList, ''Qid.Sort], + 'op-hook[''metaTermSymbol.Sort, ''_`[_`].Qid, '__[''Qid.Sort, + ''NeCTermList.Sort], ''Context.Sort], 'op-hook[''metaArgSymbol.Sort, + ''_`,_.Qid, '__[''GTermList.Sort, ''GTermList.Sort], ''GTermList.Sort], + 'op-hook[''emptyTermListSymbol.Sort, ''empty.Sort, 'nil.TypeList, ''GroundTermList.Sort], 'op-hook[''assignmentSymbol.Sort, ''_<-_.Sort, '__[ ''Variable.Sort, ''Term.Sort], ''Assignment.Sort], 'op-hook[ ''emptySubstitutionSymbol.Sort, ''none.Sort, 'nil.TypeList, @@ -709,8 +717,9 @@ result Configuration: <> < me : User | pending(nil) > reducedTerm(me, ''Strategy.Sort], ''Strategy?.Sort], 'op-hook[''mixfixSymbol.Sort, ''mixfix.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[ ''withParensSymbol.Sort, ''with-parens.Sort, 'nil.TypeList, - ''PrintOption.Sort], 'op-hook[''flatSymbol.Sort, ''flat.Sort, - 'nil.TypeList, ''PrintOption.Sort], 'op-hook[ + ''PrintOption.Sort], 'op-hook[''withSortsSymbol.Sort, ''with-sorts.Sort, + 'nil.TypeList, ''PrintOption.Sort], 'op-hook[''flatSymbol.Sort, + ''flat.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[ ''formatPrintOptionSymbol.Sort, ''format.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[''numberSymbol.Sort, ''number.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[''ratSymbol.Sort, ''rat.Sort, @@ -920,23 +929,24 @@ result Configuration: <> < me : User | pending(nil) > reducedTerm(me, '__['id-hook[''MetaLevelOpSymbol.Sort, ''metaWellFormedSubstitution.Sort], 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, ''QidList.Sort], ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[ - ''with-parens.Sort, 'nil.TypeList, ''PrintOption.Sort, 'ctor.Attr]], - 'none.MembAxSet, '__['eq_=_`[_`].['_`[_`][''$applySubstitution.Sort, '_`,_[ - ''Q:Qid.Variable, ''S:Substitution.Variable]], ''Q:Qid.Variable, - 'owise.Attr], 'eq_=_`[_`].['_`[_`][''$applySubstitution.Sort, '_`,_[ - ''V:Variable.Variable, '_`[_`][''_;_.Sort, '_`,_[''S:Substitution.Variable, - '_`[_`][''_<-_.Sort, '_`,_[''V:Variable.Variable, ''T:Term.Variable]]]]]], - ''T:Term.Variable, 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ - ''$applySubstitution.Sort, '_`,_['_`[_`][''_`,_.Qid, '_`,_[ - ''T:Term.Variable, ''TL:NeTermList.Variable]], ''S:Substitution.Variable]], - '_`[_`][''_`,_.Qid, '_`,_['_`[_`][''$applySubstitution.Sort, '_`,_[ - ''T:Term.Variable, ''S:Substitution.Variable]], '_`[_`][ - ''$applySubstitution.Sort, '_`,_[''TL:NeTermList.Variable, - ''S:Substitution.Variable]]]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ - ''$applySubstitution.Sort, '_`,_['_`[_`][''_`[_`].Qid, '_`,_[ - ''Q:Qid.Variable, ''TL:NeTermList.Variable]], ''S:Substitution.Variable]], - '_`[_`][''_`[_`].Qid, '_`,_[''Q:Qid.Variable, '_`[_`][ - ''$applySubstitution.Sort, '_`,_[''TL:NeTermList.Variable, + ''with-parens.Sort, 'nil.TypeList, ''PrintOption.Sort, 'ctor.Attr], + 'op_:_->_`[_`].[''with-sorts.Sort, 'nil.TypeList, ''PrintOption.Sort, + 'ctor.Attr]], 'none.MembAxSet, '__['eq_=_`[_`].['_`[_`][ + ''$applySubstitution.Sort, '_`,_[''Q:Qid.Variable, + ''S:Substitution.Variable]], ''Q:Qid.Variable, 'owise.Attr], 'eq_=_`[_`].[ + '_`[_`][''$applySubstitution.Sort, '_`,_[''V:Variable.Variable, '_`[_`][ + ''_;_.Sort, '_`,_[''S:Substitution.Variable, '_`[_`][''_<-_.Sort, '_`,_[ + ''V:Variable.Variable, ''T:Term.Variable]]]]]], ''T:Term.Variable, + 'none.AttrSet], 'eq_=_`[_`].['_`[_`][''$applySubstitution.Sort, '_`,_[ + '_`[_`][''_`,_.Qid, '_`,_[''T:Term.Variable, ''TL:NeTermList.Variable]], + ''S:Substitution.Variable]], '_`[_`][''_`,_.Qid, '_`,_['_`[_`][ + ''$applySubstitution.Sort, '_`,_[''T:Term.Variable, + ''S:Substitution.Variable]], '_`[_`][''$applySubstitution.Sort, '_`,_[ + ''TL:NeTermList.Variable, ''S:Substitution.Variable]]]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''$applySubstitution.Sort, '_`,_['_`[_`][''_`[_`].Qid, + '_`,_[''Q:Qid.Variable, ''TL:NeTermList.Variable]], + ''S:Substitution.Variable]], '_`[_`][''_`[_`].Qid, '_`,_[''Q:Qid.Variable, + '_`[_`][''$applySubstitution.Sort, '_`,_[''TL:NeTermList.Variable, ''S:Substitution.Variable]]]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ ''applySubstitution.Sort, '_`,_[''M:Module.Variable, ''T:Term.Variable, ''S:Substitution.Variable]], '_`[_`][''getTerm.Sort, '_`[_`][ @@ -1146,19 +1156,24 @@ result Configuration: <> < me : User | pending(nil) > reducedTerm(me, '_`[_`][''__.Sort, '_`,_[''mixfix.PrintOption.Constant, '_`[_`][''__.Sort, '_`,_[''flat.PrintOption.Constant, '_`[_`][''__.Sort, '_`,_[ ''format.PrintOption.Constant, '_`[_`][''__.Sort, '_`,_[ - ''number.PrintOption.Constant, ''rat.PrintOption.Constant]]]]]]]]]], - 'none.AttrSet], 'eq_=_`[_`].['_`[_`][''metaPrettyPrint.Sort, '_`,_[ - ''M:Module.Variable, ''T:Term.Variable, ''P:PrintOptionSet.Variable]], - '_`[_`][''metaPrettyPrint.Sort, '_`,_[''M:Module.Variable, - ''none.EmptyQidSet.Constant, ''T:Term.Variable, - ''P:PrintOptionSet.Variable]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ + ''number.PrintOption.Constant, ''rat.PrintOption.Constant]]]]]]]], + ''none.EmptyQidSet.Constant]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ + ''metaPrettyPrint.Sort, '_`,_[''M:Module.Variable, ''T:Term.Variable, + ''P:PrintOptionSet.Variable]], '_`[_`][''metaPrettyPrint.Sort, '_`,_[ + ''M:Module.Variable, ''none.EmptyQidSet.Constant, ''T:Term.Variable, + ''P:PrintOptionSet.Variable, ''none.EmptyQidSet.Constant]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''metaPrettyPrint.Sort, '_`,_[''M:Module.Variable, + ''VS:VariableSet.Variable, ''T:Term.Variable, + ''P:PrintOptionSet.Variable]], '_`[_`][''metaPrettyPrint.Sort, '_`,_[ + ''M:Module.Variable, ''VS:VariableSet.Variable, ''T:Term.Variable, + ''P:PrintOptionSet.Variable, ''none.EmptyQidSet.Constant]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''metaVariantDisjointUnify.Sort, '_`,_[ + ''M:Module.Variable, ''U:UnificationProblem.Variable, + ''TL:TermList.Variable, ''Q:Qid.Variable, ''N:Nat.Variable]], '_`[_`][ ''metaVariantDisjointUnify.Sort, '_`,_[''M:Module.Variable, ''U:UnificationProblem.Variable, ''TL:TermList.Variable, ''Q:Qid.Variable, - ''N:Nat.Variable]], '_`[_`][''metaVariantDisjointUnify.Sort, '_`,_[ - ''M:Module.Variable, ''U:UnificationProblem.Variable, - ''TL:TermList.Variable, ''Q:Qid.Variable, ''none.VariantOptionSet.Constant, - ''N:Nat.Variable]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ - ''metaVariantUnify.Sort, '_`,_[''M:Module.Variable, + ''none.VariantOptionSet.Constant, ''N:Nat.Variable]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''metaVariantUnify.Sort, '_`,_[''M:Module.Variable, ''U:UnificationProblem.Variable, ''TL:TermList.Variable, ''Q:Qid.Variable, ''N:Nat.Variable]], '_`[_`][''metaVariantUnify.Sort, '_`,_[ ''M:Module.Variable, ''U:UnificationProblem.Variable, diff --git a/tests/Meta/metaIntPrint.expected b/tests/Meta/metaIntPrint.expected index 1ffaf34e..baee3063 100644 --- a/tests/Meta/metaIntPrint.expected +++ b/tests/Meta/metaIntPrint.expected @@ -1,43 +1,43 @@ ========================================== erewrite in PRINT-TEST : <> < me : User | term: upTerm(1/2), flags: mixfix > createInterpreter(interpreterManager, me, none) . -rewrites: 6 +rewrites: 7 result Configuration: <> < me : User | none > printedTerm(me, interpreter(0), 's '0 '/ 's_^2 '`( '0 '`)) ========================================== erewrite in PRINT-TEST : <> < me : User | term: upTerm(1/2), flags: number > createInterpreter(interpreterManager, me, none) . -rewrites: 6 +rewrites: 7 result Configuration: <> < me : User | none > printedTerm(me, interpreter(0), '_/_ '`( '1 '`, '2 '`)) ========================================== erewrite in PRINT-TEST : <> < me : User | term: upTerm(1/2), flags: rat > createInterpreter(interpreterManager, me, none) . -rewrites: 6 +rewrites: 7 result Configuration: <> < me : User | none > printedTerm(me, interpreter(0), '1/2) ========================================== erewrite in PRINT-TEST : <> < me : User | term: upTerm(X:Rat + 1/2), flags: rat > createInterpreter(interpreterManager, me, none) . -rewrites: 6 +rewrites: 7 result Configuration: <> < me : User | none > printedTerm(me, interpreter(0), '_+_ '`( 'X '`, '1/2 '`)) ========================================== erewrite in PRINT-TEST : <> < me : User | term: upTerm(X:Rat + 1/2), flags: ( mixfix rat) > createInterpreter(interpreterManager, me, none) . -rewrites: 6 +rewrites: 7 result Configuration: <> < me : User | none > printedTerm(me, interpreter(0), 'X '+ '1/2) ========================================== erewrite in PRINT-TEST : <> < me : User | term: upTerm(X:Rat + 1/2), flags: ( mixfix number) > createInterpreter(interpreterManager, me, none) . -rewrites: 6 +rewrites: 7 result Configuration: <> < me : User | none > printedTerm(me, interpreter(0), 'X '+ '1 '/ '2) ========================================== erewrite in PRINT-TEST : <> < me : User | term: upTerm(X:Rat + 1/2), flags: mixfix > createInterpreter(interpreterManager, me, none) . -rewrites: 6 +rewrites: 7 result Configuration: <> < me : User | none > printedTerm(me, interpreter(0), 'X '+ 's '0 '/ 's_^2 '`( '0 '`)) Bye. diff --git a/tests/Meta/metaPrettyPrint.expected b/tests/Meta/metaPrettyPrint.expected index 254aef42..f9c5d308 100644 --- a/tests/Meta/metaPrettyPrint.expected +++ b/tests/Meta/metaPrettyPrint.expected @@ -141,7 +141,7 @@ reduce in META-LEVEL : metaPrettyPrint(fmod 'FOO is none none endfm, 'X:Float ; 'Y:Float, 'X:Float, mixfix) . -rewrites: 1 +rewrites: 2 result Sort: 'X ========================================== reduce in META-LEVEL : metaPrettyPrint(fmod 'FOO is @@ -152,6 +152,6 @@ reduce in META-LEVEL : metaPrettyPrint(fmod 'FOO is none none endfm, 'X:Float ; 'Y:Float, '_/_['X:Float, 'Y:Float], mixfix) . -rewrites: 1 +rewrites: 2 result NeTypeList: 'X '/ 'Y Bye. diff --git a/tests/Meta/metaProcPrelude.expected b/tests/Meta/metaProcPrelude.expected index 1010cd75..db9a74ff 100644 --- a/tests/Meta/metaProcPrelude.expected +++ b/tests/Meta/metaProcPrelude.expected @@ -381,6 +381,9 @@ result Configuration: <> < me : User | pending(nil) > reducedTerm(me, ''`[Module`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind], ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, 'none.AttrSet], 'op_:_->_`[_`].[''metaPrettyPrint.Sort, '__[''`[Module`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, ''`[PrintOptionSet`].Kind], ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, 'none.AttrSet], 'op_:_->_`[_`].[''metaPrettyPrint.Sort, '__[''`[Module`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, ''`[PrintOptionSet`].Kind], ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, + 'none.AttrSet], 'op_:_->_`[_`].[''metaPrettyPrint.Sort, '__[ + ''`[Module`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, + ''`[PrintOptionSet`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind], ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, 'special['__['id-hook[''MetaLevelOpSymbol.Sort, ''metaPrettyPrint.Sort], 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, ''QidList.Sort], ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[ @@ -388,14 +391,19 @@ result Configuration: <> < me : User | pending(nil) > reducedTerm(me, ''`[StrategyList`,Strategy?`].Kind, ''`[PrintOptionSet`].Kind], ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, 'special['__['id-hook[''MetaLevelOpSymbol.Sort, ''metaPrettyPrintStrategy.Sort], 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, ''QidList.Sort], - ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[''metaReduce.Sort, '__[ - ''`[Module`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind], ''`[ResultPair?`].Kind, 'special[ - '__['id-hook[''MetaLevelOpSymbol.Sort, ''metaReduce.Sort], 'op-hook[ - ''qidSymbol.Sort, ''.Sort, 'nil.TypeList, ''Qid.Sort], 'op-hook[ - ''metaTermSymbol.Sort, ''_`[_`].Qid, '__[''Qid.Sort, ''NeCTermList.Sort], - ''Context.Sort], 'op-hook[''metaArgSymbol.Sort, ''_`,_.Qid, '__[ - ''GTermList.Sort, ''GTermList.Sort], ''GTermList.Sort], 'op-hook[ - ''emptyTermListSymbol.Sort, ''empty.Sort, 'nil.TypeList, + ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[''metaPrintToString.Sort, '__[ + ''`[Module`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind, + ''`[PrintOptionSet`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind], ''`[String`].Kind, + 'special['__['id-hook[''MetaLevelOpSymbol.Sort, ''metaPrintToString.Sort], + 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, + ''QidList.Sort], ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[''metaReduce.Sort, + '__[''`[Module`].Kind, ''`[QidList`,TypeListSet`,QidSet`,Type?`,ModuleExpression`,ParameterList`,GTermList`,Header`].Kind], ''`[ResultPair?`].Kind, + 'special['__['id-hook[''MetaLevelOpSymbol.Sort, ''metaReduce.Sort], + 'op-hook[''qidSymbol.Sort, ''.Sort, 'nil.TypeList, ''Qid.Sort], + 'op-hook[''metaTermSymbol.Sort, ''_`[_`].Qid, '__[''Qid.Sort, + ''NeCTermList.Sort], ''Context.Sort], 'op-hook[''metaArgSymbol.Sort, + ''_`,_.Qid, '__[''GTermList.Sort, ''GTermList.Sort], ''GTermList.Sort], + 'op-hook[''emptyTermListSymbol.Sort, ''empty.Sort, 'nil.TypeList, ''GroundTermList.Sort], 'op-hook[''assignmentSymbol.Sort, ''_<-_.Sort, '__[ ''Variable.Sort, ''Term.Sort], ''Assignment.Sort], 'op-hook[ ''emptySubstitutionSymbol.Sort, ''none.Sort, 'nil.TypeList, @@ -709,8 +717,9 @@ result Configuration: <> < me : User | pending(nil) > reducedTerm(me, ''Strategy.Sort], ''Strategy?.Sort], 'op-hook[''mixfixSymbol.Sort, ''mixfix.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[ ''withParensSymbol.Sort, ''with-parens.Sort, 'nil.TypeList, - ''PrintOption.Sort], 'op-hook[''flatSymbol.Sort, ''flat.Sort, - 'nil.TypeList, ''PrintOption.Sort], 'op-hook[ + ''PrintOption.Sort], 'op-hook[''withSortsSymbol.Sort, ''with-sorts.Sort, + 'nil.TypeList, ''PrintOption.Sort], 'op-hook[''flatSymbol.Sort, + ''flat.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[ ''formatPrintOptionSymbol.Sort, ''format.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[''numberSymbol.Sort, ''number.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[''ratSymbol.Sort, ''rat.Sort, @@ -920,23 +929,24 @@ result Configuration: <> < me : User | pending(nil) > reducedTerm(me, '__['id-hook[''MetaLevelOpSymbol.Sort, ''metaWellFormedSubstitution.Sort], 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, ''QidList.Sort], ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[ - ''with-parens.Sort, 'nil.TypeList, ''PrintOption.Sort, 'ctor.Attr]], - 'none.MembAxSet, '__['eq_=_`[_`].['_`[_`][''$applySubstitution.Sort, '_`,_[ - ''Q:Qid.Variable, ''S:Substitution.Variable]], ''Q:Qid.Variable, - 'owise.Attr], 'eq_=_`[_`].['_`[_`][''$applySubstitution.Sort, '_`,_[ - ''V:Variable.Variable, '_`[_`][''_;_.Sort, '_`,_[''S:Substitution.Variable, - '_`[_`][''_<-_.Sort, '_`,_[''V:Variable.Variable, ''T:Term.Variable]]]]]], - ''T:Term.Variable, 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ - ''$applySubstitution.Sort, '_`,_['_`[_`][''_`,_.Qid, '_`,_[ - ''T:Term.Variable, ''TL:NeTermList.Variable]], ''S:Substitution.Variable]], - '_`[_`][''_`,_.Qid, '_`,_['_`[_`][''$applySubstitution.Sort, '_`,_[ - ''T:Term.Variable, ''S:Substitution.Variable]], '_`[_`][ - ''$applySubstitution.Sort, '_`,_[''TL:NeTermList.Variable, - ''S:Substitution.Variable]]]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ - ''$applySubstitution.Sort, '_`,_['_`[_`][''_`[_`].Qid, '_`,_[ - ''Q:Qid.Variable, ''TL:NeTermList.Variable]], ''S:Substitution.Variable]], - '_`[_`][''_`[_`].Qid, '_`,_[''Q:Qid.Variable, '_`[_`][ - ''$applySubstitution.Sort, '_`,_[''TL:NeTermList.Variable, + ''with-parens.Sort, 'nil.TypeList, ''PrintOption.Sort, 'ctor.Attr], + 'op_:_->_`[_`].[''with-sorts.Sort, 'nil.TypeList, ''PrintOption.Sort, + 'ctor.Attr]], 'none.MembAxSet, '__['eq_=_`[_`].['_`[_`][ + ''$applySubstitution.Sort, '_`,_[''Q:Qid.Variable, + ''S:Substitution.Variable]], ''Q:Qid.Variable, 'owise.Attr], 'eq_=_`[_`].[ + '_`[_`][''$applySubstitution.Sort, '_`,_[''V:Variable.Variable, '_`[_`][ + ''_;_.Sort, '_`,_[''S:Substitution.Variable, '_`[_`][''_<-_.Sort, '_`,_[ + ''V:Variable.Variable, ''T:Term.Variable]]]]]], ''T:Term.Variable, + 'none.AttrSet], 'eq_=_`[_`].['_`[_`][''$applySubstitution.Sort, '_`,_[ + '_`[_`][''_`,_.Qid, '_`,_[''T:Term.Variable, ''TL:NeTermList.Variable]], + ''S:Substitution.Variable]], '_`[_`][''_`,_.Qid, '_`,_['_`[_`][ + ''$applySubstitution.Sort, '_`,_[''T:Term.Variable, + ''S:Substitution.Variable]], '_`[_`][''$applySubstitution.Sort, '_`,_[ + ''TL:NeTermList.Variable, ''S:Substitution.Variable]]]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''$applySubstitution.Sort, '_`,_['_`[_`][''_`[_`].Qid, + '_`,_[''Q:Qid.Variable, ''TL:NeTermList.Variable]], + ''S:Substitution.Variable]], '_`[_`][''_`[_`].Qid, '_`,_[''Q:Qid.Variable, + '_`[_`][''$applySubstitution.Sort, '_`,_[''TL:NeTermList.Variable, ''S:Substitution.Variable]]]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ ''applySubstitution.Sort, '_`,_[''M:Module.Variable, ''T:Term.Variable, ''S:Substitution.Variable]], '_`[_`][''getTerm.Sort, '_`[_`][ @@ -1146,19 +1156,24 @@ result Configuration: <> < me : User | pending(nil) > reducedTerm(me, '_`[_`][''__.Sort, '_`,_[''mixfix.PrintOption.Constant, '_`[_`][''__.Sort, '_`,_[''flat.PrintOption.Constant, '_`[_`][''__.Sort, '_`,_[ ''format.PrintOption.Constant, '_`[_`][''__.Sort, '_`,_[ - ''number.PrintOption.Constant, ''rat.PrintOption.Constant]]]]]]]]]], - 'none.AttrSet], 'eq_=_`[_`].['_`[_`][''metaPrettyPrint.Sort, '_`,_[ - ''M:Module.Variable, ''T:Term.Variable, ''P:PrintOptionSet.Variable]], - '_`[_`][''metaPrettyPrint.Sort, '_`,_[''M:Module.Variable, - ''none.EmptyQidSet.Constant, ''T:Term.Variable, - ''P:PrintOptionSet.Variable]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ + ''number.PrintOption.Constant, ''rat.PrintOption.Constant]]]]]]]], + ''none.EmptyQidSet.Constant]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ + ''metaPrettyPrint.Sort, '_`,_[''M:Module.Variable, ''T:Term.Variable, + ''P:PrintOptionSet.Variable]], '_`[_`][''metaPrettyPrint.Sort, '_`,_[ + ''M:Module.Variable, ''none.EmptyQidSet.Constant, ''T:Term.Variable, + ''P:PrintOptionSet.Variable, ''none.EmptyQidSet.Constant]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''metaPrettyPrint.Sort, '_`,_[''M:Module.Variable, + ''VS:VariableSet.Variable, ''T:Term.Variable, + ''P:PrintOptionSet.Variable]], '_`[_`][''metaPrettyPrint.Sort, '_`,_[ + ''M:Module.Variable, ''VS:VariableSet.Variable, ''T:Term.Variable, + ''P:PrintOptionSet.Variable, ''none.EmptyQidSet.Constant]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''metaVariantDisjointUnify.Sort, '_`,_[ + ''M:Module.Variable, ''U:UnificationProblem.Variable, + ''TL:TermList.Variable, ''Q:Qid.Variable, ''N:Nat.Variable]], '_`[_`][ ''metaVariantDisjointUnify.Sort, '_`,_[''M:Module.Variable, ''U:UnificationProblem.Variable, ''TL:TermList.Variable, ''Q:Qid.Variable, - ''N:Nat.Variable]], '_`[_`][''metaVariantDisjointUnify.Sort, '_`,_[ - ''M:Module.Variable, ''U:UnificationProblem.Variable, - ''TL:TermList.Variable, ''Q:Qid.Variable, ''none.VariantOptionSet.Constant, - ''N:Nat.Variable]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ - ''metaVariantUnify.Sort, '_`,_[''M:Module.Variable, + ''none.VariantOptionSet.Constant, ''N:Nat.Variable]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''metaVariantUnify.Sort, '_`,_[''M:Module.Variable, ''U:UnificationProblem.Variable, ''TL:TermList.Variable, ''Q:Qid.Variable, ''N:Nat.Variable]], '_`[_`][''metaVariantUnify.Sort, '_`,_[ ''M:Module.Variable, ''U:UnificationProblem.Variable, diff --git a/tests/Meta/metaProcPrint.expected b/tests/Meta/metaProcPrint.expected index 5ec5b297..edb5d851 100644 --- a/tests/Meta/metaProcPrint.expected +++ b/tests/Meta/metaProcPrint.expected @@ -1,43 +1,43 @@ ========================================== erewrite in PRINT-TEST : <> < me : User | term: upTerm(1/2), flags: mixfix > createInterpreter(interpreterManager, me, newProcess) . -rewrites: 6 +rewrites: 7 result Configuration: <> < me : User | none > printedTerm(me, interpreter(0), 's '0 '/ 's_^2 '`( '0 '`)) ========================================== erewrite in PRINT-TEST : <> < me : User | term: upTerm(1/2), flags: number > createInterpreter(interpreterManager, me, newProcess) . -rewrites: 6 +rewrites: 7 result Configuration: <> < me : User | none > printedTerm(me, interpreter(0), '_/_ '`( '1 '`, '2 '`)) ========================================== erewrite in PRINT-TEST : <> < me : User | term: upTerm(1/2), flags: rat > createInterpreter(interpreterManager, me, newProcess) . -rewrites: 6 +rewrites: 7 result Configuration: <> < me : User | none > printedTerm(me, interpreter(0), '1/2) ========================================== erewrite in PRINT-TEST : <> < me : User | term: upTerm(X:Rat + 1/2), flags: rat > createInterpreter(interpreterManager, me, newProcess) . -rewrites: 6 +rewrites: 7 result Configuration: <> < me : User | none > printedTerm(me, interpreter(0), '_+_ '`( 'X '`, '1/2 '`)) ========================================== erewrite in PRINT-TEST : <> < me : User | term: upTerm(X:Rat + 1/2), flags: ( mixfix rat) > createInterpreter(interpreterManager, me, newProcess) . -rewrites: 6 +rewrites: 7 result Configuration: <> < me : User | none > printedTerm(me, interpreter(0), 'X '+ '1/2) ========================================== erewrite in PRINT-TEST : <> < me : User | term: upTerm(X:Rat + 1/2), flags: ( mixfix number) > createInterpreter(interpreterManager, me, newProcess) . -rewrites: 6 +rewrites: 7 result Configuration: <> < me : User | none > printedTerm(me, interpreter(0), 'X '+ '1 '/ '2) ========================================== erewrite in PRINT-TEST : <> < me : User | term: upTerm(X:Rat + 1/2), flags: mixfix > createInterpreter(interpreterManager, me, newProcess) . -rewrites: 6 +rewrites: 7 result Configuration: <> < me : User | none > printedTerm(me, interpreter(0), 'X '+ 's '0 '/ 's_^2 '`( '0 '`)) Bye. diff --git a/tests/Meta/metaUp.expected b/tests/Meta/metaUp.expected index a3ca0466..d5d7074a 100644 --- a/tests/Meta/metaUp.expected +++ b/tests/Meta/metaUp.expected @@ -536,10 +536,14 @@ eq 'metaParse['M:Module, 'Q:QidList, 'T:Type?] = 'metaParse['M:Module, 'none.EmptyQidSet, 'Q:QidList, 'T:Type?] [none] . eq 'metaPrettyPrint['M:Module, 'T:Term] = 'metaPrettyPrint['M:Module, 'none.EmptyQidSet, 'T:Term, '__['mixfix.PrintOption, '__['flat.PrintOption, - '__['format.PrintOption, '__['number.PrintOption, 'rat.PrintOption]]]]] [ - none] . + '__['format.PrintOption, '__['number.PrintOption, 'rat.PrintOption]]]], + 'none.EmptyQidSet] [none] . eq 'metaPrettyPrint['M:Module, 'T:Term, 'P:PrintOptionSet] = 'metaPrettyPrint[ - 'M:Module, 'none.EmptyQidSet, 'T:Term, 'P:PrintOptionSet] [none] . + 'M:Module, 'none.EmptyQidSet, 'T:Term, 'P:PrintOptionSet, + 'none.EmptyQidSet] [none] . +eq 'metaPrettyPrint['M:Module, 'VS:VariableSet, 'T:Term, 'P:PrintOptionSet] = + 'metaPrettyPrint['M:Module, 'VS:VariableSet, 'T:Term, 'P:PrintOptionSet, + 'none.EmptyQidSet] [none] . eq 'metaVariantDisjointUnify['M:Module, 'U:UnificationProblem, 'TL:TermList, 'Q:Qid, 'N:Nat] = 'metaVariantDisjointUnify['M:Module, 'U:UnificationProblem, 'TL:TermList, 'Q:Qid, 'none.VariantOptionSet, diff --git a/tests/Meta/metaUp2.expected b/tests/Meta/metaUp2.expected index 94453e59..c50ebc10 100644 --- a/tests/Meta/metaUp2.expected +++ b/tests/Meta/metaUp2.expected @@ -903,7 +903,8 @@ op 'metaParseStrategy : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermLis op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [none] . op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[PrintOptionSet`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [none] . op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[PrintOptionSet`] - -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [special( + -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [none] . +op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[PrintOptionSet`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [special( id-hook('MetaLevelOpSymbol, 'metaPrettyPrint) op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] . @@ -912,6 +913,11 @@ op 'metaPrettyPrintStrategy : '`[Module`] '`[ModuleExpression`,ParameterList`,GT id-hook('MetaLevelOpSymbol, 'metaPrettyPrintStrategy) op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] . +op 'metaPrintToString : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] + '`[PrintOptionSet`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[String`] [special( + id-hook('MetaLevelOpSymbol, 'metaPrintToString) + op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] + . op 'metaReduce : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[ResultPair?`] [special( id-hook('MetaLevelOpSymbol, 'metaReduce) op-hook('qidSymbol, ', nil, 'Qid) @@ -1180,6 +1186,7 @@ op 'metaReduce : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidS op-hook('mixfixSymbol, 'mixfix, nil, 'PrintOption) op-hook('withParensSymbol, 'with-parens, nil, 'PrintOption) + op-hook('withSortsSymbol, 'with-sorts, nil, 'PrintOption) op-hook('flatSymbol, 'flat, nil, 'PrintOption) op-hook('formatPrintOptionSymbol, 'format, nil, 'PrintOption) op-hook('numberSymbol, 'number, nil, 'PrintOption) @@ -1526,6 +1533,7 @@ op 'wellFormed : '`[Module`] '`[Substitution?`] -> '`[Bool`] [special( op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] . op 'with-parens : nil -> 'PrintOption [ctor] . +op 'with-sorts : nil -> 'PrintOption [ctor] . op 'xmatch_s.t._ : 'Term 'EqCondition -> 'Strategy [ctor prec(21)] . op 'xmatchrew_s.t._by_ : 'Term 'EqCondition 'UsingPairSet -> 'Strategy [ctor] . op '|_| : 'NeQidSet -> 'NzNat [none] . @@ -1808,7 +1816,8 @@ op 'metaParseStrategy : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermLis op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [none] . op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[PrintOptionSet`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [none] . op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[PrintOptionSet`] - -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [special( + -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [none] . +op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[PrintOptionSet`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [special( id-hook('MetaLevelOpSymbol, 'metaPrettyPrint) op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] . @@ -1817,6 +1826,11 @@ op 'metaPrettyPrintStrategy : '`[Module`] '`[ModuleExpression`,ParameterList`,GT id-hook('MetaLevelOpSymbol, 'metaPrettyPrintStrategy) op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] . +op 'metaPrintToString : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] + '`[PrintOptionSet`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[String`] [special( + id-hook('MetaLevelOpSymbol, 'metaPrintToString) + op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] + . op 'metaReduce : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[ResultPair?`] [special( id-hook('MetaLevelOpSymbol, 'metaReduce) op-hook('qidSymbol, ', nil, 'Qid) @@ -2085,6 +2099,7 @@ op 'metaReduce : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidS op-hook('mixfixSymbol, 'mixfix, nil, 'PrintOption) op-hook('withParensSymbol, 'with-parens, nil, 'PrintOption) + op-hook('withSortsSymbol, 'with-sorts, nil, 'PrintOption) op-hook('flatSymbol, 'flat, nil, 'PrintOption) op-hook('formatPrintOptionSymbol, 'format, nil, 'PrintOption) op-hook('numberSymbol, 'number, nil, 'PrintOption) @@ -2287,6 +2302,7 @@ op 'wellFormed : '`[Module`] '`[Substitution?`] -> '`[Bool`] [special( op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] . op 'with-parens : nil -> 'PrintOption [ctor] . +op 'with-sorts : nil -> 'PrintOption [ctor] . ========================================== reduce in META-LEVEL : upOpDecls('IDENTICAL, true) . rewrites: 0 @@ -3123,7 +3139,9 @@ result FModule: fmod 'META-LEVEL is op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [none] . op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[PrintOptionSet`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [none] . op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] - '`[PrintOptionSet`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [special( + '`[PrintOptionSet`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [none] . + op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] + '`[PrintOptionSet`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [special( id-hook('MetaLevelOpSymbol, 'metaPrettyPrint) op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] . @@ -3132,6 +3150,11 @@ result FModule: fmod 'META-LEVEL is id-hook('MetaLevelOpSymbol, 'metaPrettyPrintStrategy) op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] . + op 'metaPrintToString : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] + '`[PrintOptionSet`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[String`] [special( + id-hook('MetaLevelOpSymbol, 'metaPrintToString) + op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] + . op 'metaReduce : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[ResultPair?`] [special( id-hook('MetaLevelOpSymbol, 'metaReduce) op-hook('qidSymbol, ', nil, 'Qid) @@ -3400,6 +3423,7 @@ result FModule: fmod 'META-LEVEL is op-hook('mixfixSymbol, 'mixfix, nil, 'PrintOption) op-hook('withParensSymbol, 'with-parens, nil, 'PrintOption) + op-hook('withSortsSymbol, 'with-sorts, nil, 'PrintOption) op-hook('flatSymbol, 'flat, nil, 'PrintOption) op-hook('formatPrintOptionSymbol, 'format, nil, 'PrintOption) op-hook('numberSymbol, 'number, nil, 'PrintOption) @@ -3745,6 +3769,7 @@ result FModule: fmod 'META-LEVEL is op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] . op 'with-parens : nil -> 'PrintOption [ctor] . + op 'with-sorts : nil -> 'PrintOption [ctor] . op 'xmatch_s.t._ : 'Term 'EqCondition -> 'Strategy [ctor prec(21)] . op 'xmatchrew_s.t._by_ : 'Term 'EqCondition 'UsingPairSet -> 'Strategy [ctor] . @@ -4201,11 +4226,14 @@ result FModule: fmod 'META-LEVEL is 'none.EmptyQidSet, 'Q:QidList, 'T:Type?] [none] . eq 'metaPrettyPrint['M:Module, 'T:Term] = 'metaPrettyPrint['M:Module, 'none.EmptyQidSet, 'T:Term, '__['mixfix.PrintOption, '__['flat.PrintOption, - '__['format.PrintOption, '__['number.PrintOption, 'rat.PrintOption]]]]] [ - none] . + '__['format.PrintOption, '__['number.PrintOption, 'rat.PrintOption]]]], + 'none.EmptyQidSet] [none] . eq 'metaPrettyPrint['M:Module, 'T:Term, 'P:PrintOptionSet] = - 'metaPrettyPrint['M:Module, 'none.EmptyQidSet, 'T:Term, 'P:PrintOptionSet] - [none] . + 'metaPrettyPrint['M:Module, 'none.EmptyQidSet, 'T:Term, 'P:PrintOptionSet, + 'none.EmptyQidSet] [none] . + eq 'metaPrettyPrint['M:Module, 'VS:VariableSet, 'T:Term, 'P:PrintOptionSet] = + 'metaPrettyPrint['M:Module, 'VS:VariableSet, 'T:Term, 'P:PrintOptionSet, + 'none.EmptyQidSet] [none] . eq 'metaVariantDisjointUnify['M:Module, 'U:UnificationProblem, 'TL:TermList, 'Q:Qid, 'N:Nat] = 'metaVariantDisjointUnify['M:Module, 'U:UnificationProblem, 'TL:TermList, 'Q:Qid, 'none.VariantOptionSet, @@ -4551,7 +4579,9 @@ result FModule: fmod 'META-LEVEL is op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [none] . op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[PrintOptionSet`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [none] . op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] - '`[PrintOptionSet`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [special( + '`[PrintOptionSet`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [none] . + op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] + '`[PrintOptionSet`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [special( id-hook('MetaLevelOpSymbol, 'metaPrettyPrint) op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] . @@ -4560,6 +4590,11 @@ result FModule: fmod 'META-LEVEL is id-hook('MetaLevelOpSymbol, 'metaPrettyPrintStrategy) op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] . + op 'metaPrintToString : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] + '`[PrintOptionSet`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[String`] [special( + id-hook('MetaLevelOpSymbol, 'metaPrintToString) + op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] + . op 'metaReduce : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[ResultPair?`] [special( id-hook('MetaLevelOpSymbol, 'metaReduce) op-hook('qidSymbol, ', nil, 'Qid) @@ -4828,6 +4863,7 @@ result FModule: fmod 'META-LEVEL is op-hook('mixfixSymbol, 'mixfix, nil, 'PrintOption) op-hook('withParensSymbol, 'with-parens, nil, 'PrintOption) + op-hook('withSortsSymbol, 'with-sorts, nil, 'PrintOption) op-hook('flatSymbol, 'flat, nil, 'PrintOption) op-hook('formatPrintOptionSymbol, 'format, nil, 'PrintOption) op-hook('numberSymbol, 'number, nil, 'PrintOption) @@ -5029,6 +5065,7 @@ result FModule: fmod 'META-LEVEL is op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] . op 'with-parens : nil -> 'PrintOption [ctor] . + op 'with-sorts : nil -> 'PrintOption [ctor] . none eq '$applySubstitution['Q:Qid, 'S:Substitution] = 'Q:Qid [owise] . eq '$applySubstitution['V:Variable, '_;_['S:Substitution, '_<-_['V:Variable, @@ -5155,11 +5192,14 @@ result FModule: fmod 'META-LEVEL is 'none.EmptyQidSet, 'Q:QidList, 'T:Type?] [none] . eq 'metaPrettyPrint['M:Module, 'T:Term] = 'metaPrettyPrint['M:Module, 'none.EmptyQidSet, 'T:Term, '__['mixfix.PrintOption, '__['flat.PrintOption, - '__['format.PrintOption, '__['number.PrintOption, 'rat.PrintOption]]]]] [ - none] . + '__['format.PrintOption, '__['number.PrintOption, 'rat.PrintOption]]]], + 'none.EmptyQidSet] [none] . eq 'metaPrettyPrint['M:Module, 'T:Term, 'P:PrintOptionSet] = - 'metaPrettyPrint['M:Module, 'none.EmptyQidSet, 'T:Term, 'P:PrintOptionSet] - [none] . + 'metaPrettyPrint['M:Module, 'none.EmptyQidSet, 'T:Term, 'P:PrintOptionSet, + 'none.EmptyQidSet] [none] . + eq 'metaPrettyPrint['M:Module, 'VS:VariableSet, 'T:Term, 'P:PrintOptionSet] = + 'metaPrettyPrint['M:Module, 'VS:VariableSet, 'T:Term, 'P:PrintOptionSet, + 'none.EmptyQidSet] [none] . eq 'metaVariantDisjointUnify['M:Module, 'U:UnificationProblem, 'TL:TermList, 'Q:Qid, 'N:Nat] = 'metaVariantDisjointUnify['M:Module, 'U:UnificationProblem, 'TL:TermList, 'Q:Qid, 'none.VariantOptionSet, @@ -6364,7 +6404,9 @@ result FModule: fmod 'META-LEVEL is op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [none] . op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[PrintOptionSet`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [none] . op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] - '`[PrintOptionSet`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [special( + '`[PrintOptionSet`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [none] . + op 'metaPrettyPrint : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] + '`[PrintOptionSet`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] [special( id-hook('MetaLevelOpSymbol, 'metaPrettyPrint) op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] . @@ -6373,6 +6415,11 @@ result FModule: fmod 'META-LEVEL is id-hook('MetaLevelOpSymbol, 'metaPrettyPrintStrategy) op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] . + op 'metaPrintToString : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] + '`[PrintOptionSet`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[String`] [special( + id-hook('MetaLevelOpSymbol, 'metaPrintToString) + op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] + . op 'metaReduce : '`[Module`] '`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`] -> '`[ResultPair?`] [special( id-hook('MetaLevelOpSymbol, 'metaReduce) op-hook('qidSymbol, ', nil, 'Qid) @@ -6641,6 +6688,7 @@ result FModule: fmod 'META-LEVEL is op-hook('mixfixSymbol, 'mixfix, nil, 'PrintOption) op-hook('withParensSymbol, 'with-parens, nil, 'PrintOption) + op-hook('withSortsSymbol, 'with-sorts, nil, 'PrintOption) op-hook('flatSymbol, 'flat, nil, 'PrintOption) op-hook('formatPrintOptionSymbol, 'format, nil, 'PrintOption) op-hook('numberSymbol, 'number, nil, 'PrintOption) @@ -6986,6 +7034,7 @@ result FModule: fmod 'META-LEVEL is op-hook('shareWith, 'metaReduce, 'Module 'ModuleExpression, 'ResultPair?))] . op 'with-parens : nil -> 'PrintOption [ctor] . + op 'with-sorts : nil -> 'PrintOption [ctor] . op 'xmatch_s.t._ : 'Term 'EqCondition -> 'Strategy [ctor prec(21)] . op 'xmatchrew_s.t._by_ : 'Term 'EqCondition 'UsingPairSet -> 'Strategy [ctor] . @@ -7442,11 +7491,14 @@ result FModule: fmod 'META-LEVEL is 'none.EmptyQidSet, 'Q:QidList, 'T:Type?] [none] . eq 'metaPrettyPrint['M:Module, 'T:Term] = 'metaPrettyPrint['M:Module, 'none.EmptyQidSet, 'T:Term, '__['mixfix.PrintOption, '__['flat.PrintOption, - '__['format.PrintOption, '__['number.PrintOption, 'rat.PrintOption]]]]] [ - none] . + '__['format.PrintOption, '__['number.PrintOption, 'rat.PrintOption]]]], + 'none.EmptyQidSet] [none] . eq 'metaPrettyPrint['M:Module, 'T:Term, 'P:PrintOptionSet] = - 'metaPrettyPrint['M:Module, 'none.EmptyQidSet, 'T:Term, 'P:PrintOptionSet] - [none] . + 'metaPrettyPrint['M:Module, 'none.EmptyQidSet, 'T:Term, 'P:PrintOptionSet, + 'none.EmptyQidSet] [none] . + eq 'metaPrettyPrint['M:Module, 'VS:VariableSet, 'T:Term, 'P:PrintOptionSet] = + 'metaPrettyPrint['M:Module, 'VS:VariableSet, 'T:Term, 'P:PrintOptionSet, + 'none.EmptyQidSet] [none] . eq 'metaVariantDisjointUnify['M:Module, 'U:UnificationProblem, 'TL:TermList, 'Q:Qid, 'N:Nat] = 'metaVariantDisjointUnify['M:Module, 'U:UnificationProblem, 'TL:TermList, 'Q:Qid, 'none.VariantOptionSet, @@ -8686,20 +8738,24 @@ result ResultPair: {'fmod_is_sorts_.____endfm[''META-LEVEL.Sort, ''metaPrettyPrint.Sort, '__[''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'none.AttrSet], 'op_:_->_`[_`].[''metaPrettyPrint.Sort, '__[ ''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[PrintOptionSet`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'none.AttrSet], 'op_:_->_`[_`].[''metaPrettyPrint.Sort, '__[ ''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, - ''`[PrintOptionSet`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'special['__['id-hook[ - ''MetaLevelOpSymbol.Sort, ''metaPrettyPrint.Sort], 'op-hook[ - ''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, - ''ModuleExpression.Sort], ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[ - ''metaPrettyPrintStrategy.Sort, '__[''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, - ''`[StrategyList`,Strategy?`].Kind, ''`[PrintOptionSet`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'special['__['id-hook[''MetaLevelOpSymbol.Sort, + ''`[PrintOptionSet`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'none.AttrSet], + 'op_:_->_`[_`].[''metaPrettyPrint.Sort, '__[''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[PrintOptionSet`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'special['__['id-hook[''MetaLevelOpSymbol.Sort, + ''metaPrettyPrint.Sort], 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[ + ''Module.Sort, ''ModuleExpression.Sort], ''ResultPair?.Sort]]]], + 'op_:_->_`[_`].[''metaPrettyPrintStrategy.Sort, '__[''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[StrategyList`,Strategy?`].Kind, ''`[PrintOptionSet`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'special['__['id-hook[''MetaLevelOpSymbol.Sort, ''metaPrettyPrintStrategy.Sort], 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, ''ModuleExpression.Sort], - ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[''metaReduce.Sort, '__[ - ''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind], ''`[ResultPair?`].Kind, 'special[ - '__['id-hook[''MetaLevelOpSymbol.Sort, ''metaReduce.Sort], 'op-hook[ - ''qidSymbol.Sort, ''.Sort, 'nil.TypeList, ''Qid.Sort], 'op-hook[ - ''metaTermSymbol.Sort, ''_`[_`].Qid, '__[''Qid.Sort, - ''NeGroundTermList.Sort], ''GroundTerm.Sort], 'op-hook[ + ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[''metaPrintToString.Sort, '__[ + ''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, + ''`[PrintOptionSet`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind], ''`[String`].Kind, + 'special['__['id-hook[''MetaLevelOpSymbol.Sort, ''metaPrintToString.Sort], + 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, + ''ModuleExpression.Sort], ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[ + ''metaReduce.Sort, '__[''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind], + ''`[ResultPair?`].Kind, 'special['__['id-hook[''MetaLevelOpSymbol.Sort, + ''metaReduce.Sort], 'op-hook[''qidSymbol.Sort, ''.Sort, + 'nil.TypeList, ''Qid.Sort], 'op-hook[''metaTermSymbol.Sort, ''_`[_`].Qid, + '__[''Qid.Sort, ''NeGroundTermList.Sort], ''GroundTerm.Sort], 'op-hook[ ''metaArgSymbol.Sort, ''_`,_.Qid, '__[''NeGroundTermList.Sort, ''GroundTermList.Sort], ''NeGroundTermList.Sort], 'op-hook[ ''emptyTermListSymbol.Sort, ''empty.Sort, 'nil.TypeList, @@ -9016,8 +9072,9 @@ result ResultPair: {'fmod_is_sorts_.____endfm[''META-LEVEL.Sort, ''Strategy.Sort], ''Strategy?.Sort], 'op-hook[''mixfixSymbol.Sort, ''mixfix.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[ ''withParensSymbol.Sort, ''with-parens.Sort, 'nil.TypeList, - ''PrintOption.Sort], 'op-hook[''flatSymbol.Sort, ''flat.Sort, - 'nil.TypeList, ''PrintOption.Sort], 'op-hook[ + ''PrintOption.Sort], 'op-hook[''withSortsSymbol.Sort, ''with-sorts.Sort, + 'nil.TypeList, ''PrintOption.Sort], 'op-hook[''flatSymbol.Sort, + ''flat.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[ ''formatPrintOptionSymbol.Sort, ''format.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[''numberSymbol.Sort, ''number.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[''ratSymbol.Sort, ''rat.Sort, @@ -9426,7 +9483,8 @@ result ResultPair: {'fmod_is_sorts_.____endfm[''META-LEVEL.Sort, ''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, ''ModuleExpression.Sort], ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[ ''with-parens.Sort, 'nil.TypeList, ''PrintOption.Sort, 'ctor.Attr], - 'op_:_->_`[_`].[''xmatch_s.t._.Constant, '__[''Term.Sort, + 'op_:_->_`[_`].[''with-sorts.Sort, 'nil.TypeList, ''PrintOption.Sort, + 'ctor.Attr], 'op_:_->_`[_`].[''xmatch_s.t._.Constant, '__[''Term.Sort, ''EqCondition.Sort], ''Strategy.Sort, '__['ctor.Attr, 'prec['s_^21[ '0.Zero]]]], 'op_:_->_`[_`].[''xmatchrew_s.t._by_.Constant, '__[ ''Term.Sort, ''EqCondition.Sort, ''UsingPairSet.Sort], ''Strategy.Sort, @@ -10261,19 +10319,24 @@ result ResultPair: {'fmod_is_sorts_.____endfm[''META-LEVEL.Sort, '_`[_`][''__.Sort, '_`,_[''mixfix.PrintOption.Constant, '_`[_`][''__.Sort, '_`,_[''flat.PrintOption.Constant, '_`[_`][''__.Sort, '_`,_[ ''format.PrintOption.Constant, '_`[_`][''__.Sort, '_`,_[ - ''number.PrintOption.Constant, ''rat.PrintOption.Constant]]]]]]]]]], - 'none.AttrSet], 'eq_=_`[_`].['_`[_`][''metaPrettyPrint.Sort, '_`,_[ - ''M:Module.Variable, ''T:Term.Variable, ''P:PrintOptionSet.Variable]], - '_`[_`][''metaPrettyPrint.Sort, '_`,_[''M:Module.Variable, - ''none.EmptyQidSet.Constant, ''T:Term.Variable, - ''P:PrintOptionSet.Variable]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ + ''number.PrintOption.Constant, ''rat.PrintOption.Constant]]]]]]]], + ''none.EmptyQidSet.Constant]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ + ''metaPrettyPrint.Sort, '_`,_[''M:Module.Variable, ''T:Term.Variable, + ''P:PrintOptionSet.Variable]], '_`[_`][''metaPrettyPrint.Sort, '_`,_[ + ''M:Module.Variable, ''none.EmptyQidSet.Constant, ''T:Term.Variable, + ''P:PrintOptionSet.Variable, ''none.EmptyQidSet.Constant]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''metaPrettyPrint.Sort, '_`,_[''M:Module.Variable, + ''VS:VariableSet.Variable, ''T:Term.Variable, + ''P:PrintOptionSet.Variable]], '_`[_`][''metaPrettyPrint.Sort, '_`,_[ + ''M:Module.Variable, ''VS:VariableSet.Variable, ''T:Term.Variable, + ''P:PrintOptionSet.Variable, ''none.EmptyQidSet.Constant]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''metaVariantDisjointUnify.Sort, '_`,_[ + ''M:Module.Variable, ''U:UnificationProblem.Variable, + ''TL:TermList.Variable, ''Q:Qid.Variable, ''N:Nat.Variable]], '_`[_`][ ''metaVariantDisjointUnify.Sort, '_`,_[''M:Module.Variable, ''U:UnificationProblem.Variable, ''TL:TermList.Variable, ''Q:Qid.Variable, - ''N:Nat.Variable]], '_`[_`][''metaVariantDisjointUnify.Sort, '_`,_[ - ''M:Module.Variable, ''U:UnificationProblem.Variable, - ''TL:TermList.Variable, ''Q:Qid.Variable, ''none.VariantOptionSet.Constant, - ''N:Nat.Variable]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ - ''metaVariantUnify.Sort, '_`,_[''M:Module.Variable, + ''none.VariantOptionSet.Constant, ''N:Nat.Variable]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''metaVariantUnify.Sort, '_`,_[''M:Module.Variable, ''U:UnificationProblem.Variable, ''TL:TermList.Variable, ''Q:Qid.Variable, ''N:Nat.Variable]], '_`[_`][''metaVariantUnify.Sort, '_`,_[ ''M:Module.Variable, ''U:UnificationProblem.Variable, @@ -11305,20 +11368,24 @@ result GroundTerm: 'fmod_is_sorts_.____endfm[''META-LEVEL.Sort, ''metaPrettyPrint.Sort, '__[''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'none.AttrSet], 'op_:_->_`[_`].[''metaPrettyPrint.Sort, '__[ ''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[PrintOptionSet`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'none.AttrSet], 'op_:_->_`[_`].[''metaPrettyPrint.Sort, '__[ ''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, - ''`[PrintOptionSet`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'special['__['id-hook[ - ''MetaLevelOpSymbol.Sort, ''metaPrettyPrint.Sort], 'op-hook[ - ''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, - ''ModuleExpression.Sort], ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[ - ''metaPrettyPrintStrategy.Sort, '__[''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, - ''`[StrategyList`,Strategy?`].Kind, ''`[PrintOptionSet`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'special['__['id-hook[''MetaLevelOpSymbol.Sort, + ''`[PrintOptionSet`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'none.AttrSet], + 'op_:_->_`[_`].[''metaPrettyPrint.Sort, '__[''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[PrintOptionSet`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'special['__['id-hook[''MetaLevelOpSymbol.Sort, + ''metaPrettyPrint.Sort], 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[ + ''Module.Sort, ''ModuleExpression.Sort], ''ResultPair?.Sort]]]], + 'op_:_->_`[_`].[''metaPrettyPrintStrategy.Sort, '__[''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[StrategyList`,Strategy?`].Kind, ''`[PrintOptionSet`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'special['__['id-hook[''MetaLevelOpSymbol.Sort, ''metaPrettyPrintStrategy.Sort], 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, ''ModuleExpression.Sort], - ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[''metaReduce.Sort, '__[ - ''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind], ''`[ResultPair?`].Kind, 'special[ - '__['id-hook[''MetaLevelOpSymbol.Sort, ''metaReduce.Sort], 'op-hook[ - ''qidSymbol.Sort, ''.Sort, 'nil.TypeList, ''Qid.Sort], 'op-hook[ - ''metaTermSymbol.Sort, ''_`[_`].Qid, '__[''Qid.Sort, - ''NeGroundTermList.Sort], ''GroundTerm.Sort], 'op-hook[ + ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[''metaPrintToString.Sort, '__[ + ''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, + ''`[PrintOptionSet`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind], ''`[String`].Kind, + 'special['__['id-hook[''MetaLevelOpSymbol.Sort, ''metaPrintToString.Sort], + 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, + ''ModuleExpression.Sort], ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[ + ''metaReduce.Sort, '__[''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind], + ''`[ResultPair?`].Kind, 'special['__['id-hook[''MetaLevelOpSymbol.Sort, + ''metaReduce.Sort], 'op-hook[''qidSymbol.Sort, ''.Sort, + 'nil.TypeList, ''Qid.Sort], 'op-hook[''metaTermSymbol.Sort, ''_`[_`].Qid, + '__[''Qid.Sort, ''NeGroundTermList.Sort], ''GroundTerm.Sort], 'op-hook[ ''metaArgSymbol.Sort, ''_`,_.Qid, '__[''NeGroundTermList.Sort, ''GroundTermList.Sort], ''NeGroundTermList.Sort], 'op-hook[ ''emptyTermListSymbol.Sort, ''empty.Sort, 'nil.TypeList, @@ -11635,8 +11702,9 @@ result GroundTerm: 'fmod_is_sorts_.____endfm[''META-LEVEL.Sort, ''Strategy.Sort], ''Strategy?.Sort], 'op-hook[''mixfixSymbol.Sort, ''mixfix.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[ ''withParensSymbol.Sort, ''with-parens.Sort, 'nil.TypeList, - ''PrintOption.Sort], 'op-hook[''flatSymbol.Sort, ''flat.Sort, - 'nil.TypeList, ''PrintOption.Sort], 'op-hook[ + ''PrintOption.Sort], 'op-hook[''withSortsSymbol.Sort, ''with-sorts.Sort, + 'nil.TypeList, ''PrintOption.Sort], 'op-hook[''flatSymbol.Sort, + ''flat.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[ ''formatPrintOptionSymbol.Sort, ''format.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[''numberSymbol.Sort, ''number.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[''ratSymbol.Sort, ''rat.Sort, @@ -12045,7 +12113,8 @@ result GroundTerm: 'fmod_is_sorts_.____endfm[''META-LEVEL.Sort, ''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, ''ModuleExpression.Sort], ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[ ''with-parens.Sort, 'nil.TypeList, ''PrintOption.Sort, 'ctor.Attr], - 'op_:_->_`[_`].[''xmatch_s.t._.Constant, '__[''Term.Sort, + 'op_:_->_`[_`].[''with-sorts.Sort, 'nil.TypeList, ''PrintOption.Sort, + 'ctor.Attr], 'op_:_->_`[_`].[''xmatch_s.t._.Constant, '__[''Term.Sort, ''EqCondition.Sort], ''Strategy.Sort, '__['ctor.Attr, 'prec['s_^21[ '0.Zero]]]], 'op_:_->_`[_`].[''xmatchrew_s.t._by_.Constant, '__[ ''Term.Sort, ''EqCondition.Sort, ''UsingPairSet.Sort], ''Strategy.Sort, @@ -12880,19 +12949,24 @@ result GroundTerm: 'fmod_is_sorts_.____endfm[''META-LEVEL.Sort, '_`[_`][''__.Sort, '_`,_[''mixfix.PrintOption.Constant, '_`[_`][''__.Sort, '_`,_[''flat.PrintOption.Constant, '_`[_`][''__.Sort, '_`,_[ ''format.PrintOption.Constant, '_`[_`][''__.Sort, '_`,_[ - ''number.PrintOption.Constant, ''rat.PrintOption.Constant]]]]]]]]]], - 'none.AttrSet], 'eq_=_`[_`].['_`[_`][''metaPrettyPrint.Sort, '_`,_[ - ''M:Module.Variable, ''T:Term.Variable, ''P:PrintOptionSet.Variable]], - '_`[_`][''metaPrettyPrint.Sort, '_`,_[''M:Module.Variable, - ''none.EmptyQidSet.Constant, ''T:Term.Variable, - ''P:PrintOptionSet.Variable]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ + ''number.PrintOption.Constant, ''rat.PrintOption.Constant]]]]]]]], + ''none.EmptyQidSet.Constant]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ + ''metaPrettyPrint.Sort, '_`,_[''M:Module.Variable, ''T:Term.Variable, + ''P:PrintOptionSet.Variable]], '_`[_`][''metaPrettyPrint.Sort, '_`,_[ + ''M:Module.Variable, ''none.EmptyQidSet.Constant, ''T:Term.Variable, + ''P:PrintOptionSet.Variable, ''none.EmptyQidSet.Constant]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''metaPrettyPrint.Sort, '_`,_[''M:Module.Variable, + ''VS:VariableSet.Variable, ''T:Term.Variable, + ''P:PrintOptionSet.Variable]], '_`[_`][''metaPrettyPrint.Sort, '_`,_[ + ''M:Module.Variable, ''VS:VariableSet.Variable, ''T:Term.Variable, + ''P:PrintOptionSet.Variable, ''none.EmptyQidSet.Constant]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''metaVariantDisjointUnify.Sort, '_`,_[ + ''M:Module.Variable, ''U:UnificationProblem.Variable, + ''TL:TermList.Variable, ''Q:Qid.Variable, ''N:Nat.Variable]], '_`[_`][ ''metaVariantDisjointUnify.Sort, '_`,_[''M:Module.Variable, ''U:UnificationProblem.Variable, ''TL:TermList.Variable, ''Q:Qid.Variable, - ''N:Nat.Variable]], '_`[_`][''metaVariantDisjointUnify.Sort, '_`,_[ - ''M:Module.Variable, ''U:UnificationProblem.Variable, - ''TL:TermList.Variable, ''Q:Qid.Variable, ''none.VariantOptionSet.Constant, - ''N:Nat.Variable]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ - ''metaVariantUnify.Sort, '_`,_[''M:Module.Variable, + ''none.VariantOptionSet.Constant, ''N:Nat.Variable]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''metaVariantUnify.Sort, '_`,_[''M:Module.Variable, ''U:UnificationProblem.Variable, ''TL:TermList.Variable, ''Q:Qid.Variable, ''N:Nat.Variable]], '_`[_`][''metaVariantUnify.Sort, '_`,_[ ''M:Module.Variable, ''U:UnificationProblem.Variable, @@ -13924,20 +13998,24 @@ result ResultPair: {'fmod_is_sorts_.____endfm[''META-LEVEL.Sort, ''metaPrettyPrint.Sort, '__[''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'none.AttrSet], 'op_:_->_`[_`].[''metaPrettyPrint.Sort, '__[ ''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[PrintOptionSet`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'none.AttrSet], 'op_:_->_`[_`].[''metaPrettyPrint.Sort, '__[ ''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, - ''`[PrintOptionSet`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'special['__['id-hook[ - ''MetaLevelOpSymbol.Sort, ''metaPrettyPrint.Sort], 'op-hook[ - ''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, - ''ModuleExpression.Sort], ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[ - ''metaPrettyPrintStrategy.Sort, '__[''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, - ''`[StrategyList`,Strategy?`].Kind, ''`[PrintOptionSet`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'special['__['id-hook[''MetaLevelOpSymbol.Sort, + ''`[PrintOptionSet`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'none.AttrSet], + 'op_:_->_`[_`].[''metaPrettyPrint.Sort, '__[''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[PrintOptionSet`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'special['__['id-hook[''MetaLevelOpSymbol.Sort, + ''metaPrettyPrint.Sort], 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[ + ''Module.Sort, ''ModuleExpression.Sort], ''ResultPair?.Sort]]]], + 'op_:_->_`[_`].[''metaPrettyPrintStrategy.Sort, '__[''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[StrategyList`,Strategy?`].Kind, ''`[PrintOptionSet`].Kind], ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, 'special['__['id-hook[''MetaLevelOpSymbol.Sort, ''metaPrettyPrintStrategy.Sort], 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, ''ModuleExpression.Sort], - ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[''metaReduce.Sort, '__[ - ''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind], ''`[ResultPair?`].Kind, 'special[ - '__['id-hook[''MetaLevelOpSymbol.Sort, ''metaReduce.Sort], 'op-hook[ - ''qidSymbol.Sort, ''.Sort, 'nil.TypeList, ''Qid.Sort], 'op-hook[ - ''metaTermSymbol.Sort, ''_`[_`].Qid, '__[''Qid.Sort, - ''NeGroundTermList.Sort], ''GroundTerm.Sort], 'op-hook[ + ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[''metaPrintToString.Sort, '__[ + ''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind, + ''`[PrintOptionSet`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind], ''`[String`].Kind, + 'special['__['id-hook[''MetaLevelOpSymbol.Sort, ''metaPrintToString.Sort], + 'op-hook[''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, + ''ModuleExpression.Sort], ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[ + ''metaReduce.Sort, '__[''`[Module`].Kind, ''`[ModuleExpression`,ParameterList`,GTermList`,QidSet`,QidList`,TypeListSet`,Type?`,Header`].Kind], + ''`[ResultPair?`].Kind, 'special['__['id-hook[''MetaLevelOpSymbol.Sort, + ''metaReduce.Sort], 'op-hook[''qidSymbol.Sort, ''.Sort, + 'nil.TypeList, ''Qid.Sort], 'op-hook[''metaTermSymbol.Sort, ''_`[_`].Qid, + '__[''Qid.Sort, ''NeGroundTermList.Sort], ''GroundTerm.Sort], 'op-hook[ ''metaArgSymbol.Sort, ''_`,_.Qid, '__[''NeGroundTermList.Sort, ''GroundTermList.Sort], ''NeGroundTermList.Sort], 'op-hook[ ''emptyTermListSymbol.Sort, ''empty.Sort, 'nil.TypeList, @@ -14254,8 +14332,9 @@ result ResultPair: {'fmod_is_sorts_.____endfm[''META-LEVEL.Sort, ''Strategy.Sort], ''Strategy?.Sort], 'op-hook[''mixfixSymbol.Sort, ''mixfix.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[ ''withParensSymbol.Sort, ''with-parens.Sort, 'nil.TypeList, - ''PrintOption.Sort], 'op-hook[''flatSymbol.Sort, ''flat.Sort, - 'nil.TypeList, ''PrintOption.Sort], 'op-hook[ + ''PrintOption.Sort], 'op-hook[''withSortsSymbol.Sort, ''with-sorts.Sort, + 'nil.TypeList, ''PrintOption.Sort], 'op-hook[''flatSymbol.Sort, + ''flat.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[ ''formatPrintOptionSymbol.Sort, ''format.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[''numberSymbol.Sort, ''number.Sort, 'nil.TypeList, ''PrintOption.Sort], 'op-hook[''ratSymbol.Sort, ''rat.Sort, @@ -14664,7 +14743,8 @@ result ResultPair: {'fmod_is_sorts_.____endfm[''META-LEVEL.Sort, ''shareWith.Sort, ''metaReduce.Sort, '__[''Module.Sort, ''ModuleExpression.Sort], ''ResultPair?.Sort]]]], 'op_:_->_`[_`].[ ''with-parens.Sort, 'nil.TypeList, ''PrintOption.Sort, 'ctor.Attr], - 'op_:_->_`[_`].[''xmatch_s.t._.Constant, '__[''Term.Sort, + 'op_:_->_`[_`].[''with-sorts.Sort, 'nil.TypeList, ''PrintOption.Sort, + 'ctor.Attr], 'op_:_->_`[_`].[''xmatch_s.t._.Constant, '__[''Term.Sort, ''EqCondition.Sort], ''Strategy.Sort, '__['ctor.Attr, 'prec['s_^21[ '0.Zero]]]], 'op_:_->_`[_`].[''xmatchrew_s.t._by_.Constant, '__[ ''Term.Sort, ''EqCondition.Sort, ''UsingPairSet.Sort], ''Strategy.Sort, @@ -15499,19 +15579,24 @@ result ResultPair: {'fmod_is_sorts_.____endfm[''META-LEVEL.Sort, '_`[_`][''__.Sort, '_`,_[''mixfix.PrintOption.Constant, '_`[_`][''__.Sort, '_`,_[''flat.PrintOption.Constant, '_`[_`][''__.Sort, '_`,_[ ''format.PrintOption.Constant, '_`[_`][''__.Sort, '_`,_[ - ''number.PrintOption.Constant, ''rat.PrintOption.Constant]]]]]]]]]], - 'none.AttrSet], 'eq_=_`[_`].['_`[_`][''metaPrettyPrint.Sort, '_`,_[ - ''M:Module.Variable, ''T:Term.Variable, ''P:PrintOptionSet.Variable]], - '_`[_`][''metaPrettyPrint.Sort, '_`,_[''M:Module.Variable, - ''none.EmptyQidSet.Constant, ''T:Term.Variable, - ''P:PrintOptionSet.Variable]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ + ''number.PrintOption.Constant, ''rat.PrintOption.Constant]]]]]]]], + ''none.EmptyQidSet.Constant]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ + ''metaPrettyPrint.Sort, '_`,_[''M:Module.Variable, ''T:Term.Variable, + ''P:PrintOptionSet.Variable]], '_`[_`][''metaPrettyPrint.Sort, '_`,_[ + ''M:Module.Variable, ''none.EmptyQidSet.Constant, ''T:Term.Variable, + ''P:PrintOptionSet.Variable, ''none.EmptyQidSet.Constant]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''metaPrettyPrint.Sort, '_`,_[''M:Module.Variable, + ''VS:VariableSet.Variable, ''T:Term.Variable, + ''P:PrintOptionSet.Variable]], '_`[_`][''metaPrettyPrint.Sort, '_`,_[ + ''M:Module.Variable, ''VS:VariableSet.Variable, ''T:Term.Variable, + ''P:PrintOptionSet.Variable, ''none.EmptyQidSet.Constant]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''metaVariantDisjointUnify.Sort, '_`,_[ + ''M:Module.Variable, ''U:UnificationProblem.Variable, + ''TL:TermList.Variable, ''Q:Qid.Variable, ''N:Nat.Variable]], '_`[_`][ ''metaVariantDisjointUnify.Sort, '_`,_[''M:Module.Variable, ''U:UnificationProblem.Variable, ''TL:TermList.Variable, ''Q:Qid.Variable, - ''N:Nat.Variable]], '_`[_`][''metaVariantDisjointUnify.Sort, '_`,_[ - ''M:Module.Variable, ''U:UnificationProblem.Variable, - ''TL:TermList.Variable, ''Q:Qid.Variable, ''none.VariantOptionSet.Constant, - ''N:Nat.Variable]], 'none.AttrSet], 'eq_=_`[_`].['_`[_`][ - ''metaVariantUnify.Sort, '_`,_[''M:Module.Variable, + ''none.VariantOptionSet.Constant, ''N:Nat.Variable]], 'none.AttrSet], + 'eq_=_`[_`].['_`[_`][''metaVariantUnify.Sort, '_`,_[''M:Module.Variable, ''U:UnificationProblem.Variable, ''TL:TermList.Variable, ''Q:Qid.Variable, ''N:Nat.Variable]], '_`[_`][''metaVariantUnify.Sort, '_`,_[ ''M:Module.Variable, ''U:UnificationProblem.Variable, diff --git a/tests/Misc/commands.expected b/tests/Misc/commands.expected index cc4c63ab..2cd57340 100644 --- a/tests/Misc/commands.expected +++ b/tests/Misc/commands.expected @@ -7,12 +7,12 @@ mod FOO is subsort Int < Foo . op f : Int Int -> Int [assoc comm id: 1] . vars X Y Z : Int . - eq f(f(X, Y), X) = f(Y, Y) . - cq f(f(X, Y), Y) = f(Y, X) if X =/= Y . - rl f(f(X, Y), X) => f(Y, Y) . - crl f(f(X, Y), Y) => f(Z, X) if Z =/= Y . - mb f(X, X) : NzInt . - cmb f(X, Y) : NzInt if X =/= Y . + eq f (f (X, Y), X) = f (Y, Y) . + cq f (f (X, Y), Y) = f (Y, X) if X =/= Y . + rl f (f (X, Y), X) => f (Y, Y) . + crl f (f (X, Y), Y) => f (Z, X) if Z =/= Y . + mb f (X, X) : NzInt . + cmb f (X, Y) : NzInt if X =/= Y . endm Warning: membership axioms are not guaranteed to work correctly for iterated symbol s_ as it has declarations that are not at the kind level. @@ -545,12 +545,12 @@ mod FOO is subsort Int < Foo . op f : Int Int -> Int [assoc comm id: 1] . vars X Y Z : Int . - eq f(f(X, Y), X) = f(Y, Y) . - cq f(f(X, Y), Y) = f(Y, X) if X =/= Y . - rl f(f(X, Y), X) => f(Y, Y) . - crl f(f(X, Y), Y) => f(Z, X) if Z =/= Y . - mb f(X, X) : NzInt . - cmb f(X, Y) : NzInt if X =/= Y . + eq f (f (X, Y), X) = f (Y, Y) . + cq f (f (X, Y), Y) = f (Y, X) if X =/= Y . + rl f (f (X, Y), X) => f (Y, Y) . + crl f (f (X, Y), Y) => f (Z, X) if Z =/= Y . + mb f (X, X) : NzInt . + cmb f (X, Y) : NzInt if X =/= Y . endm eq f(X, X, Y) = f(Y, Y) . ceq f(X, Y, Y) = f(X, Y) if X =/= Y = true . diff --git a/tests/ObjectOriented/parameterization.expected b/tests/ObjectOriented/parameterization.expected index 70ba73cc..93d8cee1 100644 --- a/tests/ObjectOriented/parameterization.expected +++ b/tests/ObjectOriented/parameterization.expected @@ -136,7 +136,7 @@ view Bag{Y :: TRIV} from CONTAINER to BAG{Y} is sort Elt to Y$Elt . vars R S : Oid . var D : Elt . - msg insert(R, S, D) to term replace(R, D) . + msg insert (R, S, D) to term replace (R, D) . endv view Bag{Y :: TRIV} from CONTAINER to BAG{Y} is sort Elt to Y$Elt .