-
Notifications
You must be signed in to change notification settings - Fork 29
Need help! Removing codeExprDoc from drasil-printers?
#4509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,7 +51,7 @@ import Language.Drasil.Choices (Comments(..), ConstantStructure(..), | |
| Logging(..), Structure(..), hasSampleInput, InternalConcept(..)) | ||
| import Language.Drasil.CodeSpec (HasOldCodeSpec(..)) | ||
| import Language.Drasil.Expr.Development (Completeness(..)) | ||
| import Language.Drasil.Printers (SingleLine(OneLine), codeExprDoc, showHasSymbImpl, PrintingInformation) | ||
| import Language.Drasil.Printers (SingleLine(OneLine), showHasSymbImpl, PrintingInformation) | ||
|
|
||
| import Drasil.GOOL (MSBody, MSBlock, SVariable, SValue, MSStatement, | ||
| SMethod, CSStateVar, SClass, SharedProg, OOProg, BodySym(..), bodyStatements, | ||
|
|
@@ -63,7 +63,7 @@ import Drasil.GOOL (MSBody, MSBlock, SVariable, SValue, MSStatement, | |
| VisibilitySym(..), MethodSym(..), StateVarSym(..), pubDVar, convType, | ||
| convTypeOO, VisibilityTag(..)) | ||
|
|
||
| import qualified Drasil.GOOL as OO (SFile) | ||
| import qualified Drasil.GOOL as OO (SFile, SValue) | ||
| import Drasil.GProc (ProcProg) | ||
| import qualified Drasil.GProc as Proc (SFile) | ||
|
|
||
|
|
@@ -419,15 +419,15 @@ printConstraint v c = do | |
| printConstraint' _ (Range _ (Bounded (_, e1) (_, e2))) = do | ||
| lb <- convExpr e1 | ||
| ub <- convExpr e2 | ||
| return $ [printStr "between ", print lb] ++ printExpr e1 db ++ | ||
| [printStr " and ", print ub] ++ printExpr e2 db ++ [printStrLn "."] | ||
| return $ [printStr "between "] ++ printExpr lb db ++ | ||
| [printStr " and "] ++ printExpr ub db ++ [printStrLn "."] | ||
| printConstraint' _ (Range _ (UpTo (_, e))) = do | ||
| ub <- convExpr e | ||
| return $ [printStr "below ", print ub] ++ printExpr e db ++ | ||
| return $ [printStr "below "] ++ printExpr ub db ++ | ||
| [printStrLn "."] | ||
| printConstraint' _ (Range _ (UpFrom (_, e))) = do | ||
| lb <- convExpr e | ||
| return $ [printStr "above ", print lb] ++ printExpr e db ++ [printStrLn "."] | ||
| return $ [printStr "above "] ++ printExpr lb db ++ [printStrLn "."] | ||
|
Comment on lines
419
to
+430
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One question to ask ourselves first is: What do we want the format of the constraint violation messages to be? I somewhat like these, but I would also like to see
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that more traceability in constraint violation messages would be even better. |
||
| printConstraint' name (Elem _ e) = do | ||
| lb <- convExpr (Variable ("set_" ++ name) e) | ||
| return $ [printStr "an element of the set ", print lb] ++ [printStrLn "."] | ||
|
|
@@ -437,9 +437,8 @@ printConstraint v c = do | |
| -- | Don't print expressions that are just literals, because that would be | ||
| -- redundant (the values are already printed by printConstraint). | ||
| -- If expression is more than just a literal, print it in parentheses. | ||
| printExpr :: (SharedProg r) => CodeExpr -> PrintingInformation -> [MSStatement r] | ||
| printExpr Lit{} _ = [] | ||
| printExpr e db = [printStr $ " (" ++ render (codeExprDoc db OneLine e) ++ ")"] | ||
| printExpr :: (SharedProg r) => OO.SValue r -> PrintingInformation -> [MSStatement r] | ||
| printExpr e db = [print e] -- [printStr " (", print e, printStr ")"] -- ++ render (codeExprDoc db OneLine e) ++ ")"] | ||
|
|
||
| -- | | Generates a function for reading inputs from a file. | ||
| genInputFormat :: (OOProg r) => VisibilityTag -> | ||
|
|
@@ -984,15 +983,15 @@ printConstraintProc c = do | |
| printConstraint' (Range _ (Bounded (_, e1) (_, e2))) = do | ||
| lb <- convExprProc e1 | ||
| ub <- convExprProc e2 | ||
| return $ [printStr "between ", print lb] ++ printExpr e1 db ++ | ||
| [printStr " and ", print ub] ++ printExpr e2 db ++ [printStrLn "."] | ||
| return $ [printStr "between "] ++ printExpr lb db ++ | ||
| [printStr " and "] ++ printExpr ub db ++ [printStrLn "."] | ||
| printConstraint' (Range _ (UpTo (_, e))) = do | ||
| ub <- convExprProc e | ||
| return $ [printStr "below ", print ub] ++ printExpr e db ++ | ||
| return $ [printStr "below "] ++ printExpr ub db ++ | ||
| [printStrLn "."] | ||
| printConstraint' (Range _ (UpFrom (_, e))) = do | ||
| lb <- convExprProc e | ||
| return $ [printStr "above ", print lb] ++ printExpr e db ++ [printStrLn "."] | ||
| return $ [printStr "above "] ++ printExpr lb db ++ [printStrLn "."] | ||
| printConstraint' (Elem _ e) = do | ||
| lb <- convExprProc e | ||
| return $ [printStr "an element of the set ", print lb] ++ [printStrLn "."] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ module Language.Drasil.Plain.Print ( | |
| -- * Types | ||
| SingleLine(..), | ||
| -- * Functions | ||
| exprDoc, codeExprDoc, sentenceDoc, symbolDoc, unitDoc, showSymb, | ||
| exprDoc, sentenceDoc, symbolDoc, unitDoc, showSymb, | ||
| showHasSymbImpl | ||
| ) where | ||
|
|
||
|
|
@@ -13,14 +13,13 @@ import Text.PrettyPrint.HughesPJ (Doc, (<>), (<+>), brackets, comma, double, | |
| doubleQuotes, empty, hcat, hsep, integer, parens, punctuate, space, text, | ||
| vcat, render) | ||
|
|
||
| import qualified Drasil.Code.CodeExpr.Development as C (CodeExpr) | ||
| import Language.Drasil (Sentence, Special(..), Stage(..), Symbol, USymb(..)) | ||
| import qualified Language.Drasil as L (Expr, HasSymbol(..)) | ||
| import Utils.Drasil (toPlainName) | ||
|
|
||
| import Language.Drasil.Printing.AST (Expr(..), Spec(..), Ops(..), Fence(..), | ||
| OverSymb(..), Fonts(..), Spacing(..), LinkType(..)) | ||
| import Language.Drasil.Printing.Import (expr, codeExpr, spec, symbol) | ||
| import Language.Drasil.Printing.Import (expr, spec, symbol) | ||
| import Language.Drasil.Printing.PrintingInformation (PrintingInformation) | ||
|
|
||
| -- | Data is either linear or not. | ||
|
|
@@ -30,10 +29,6 @@ data SingleLine = OneLine | MultiLine | |
| exprDoc :: PrintingInformation -> SingleLine -> L.Expr -> Doc | ||
| exprDoc pinfo sl e = pExprDoc sl (expr e pinfo) | ||
|
|
||
| -- | Create code expressions for a document in 'Doc' format. | ||
| codeExprDoc :: PrintingInformation -> SingleLine -> C.CodeExpr -> Doc | ||
| codeExprDoc pinfo sl e = pExprDoc sl (codeExpr e pinfo) | ||
|
Comment on lines
-33
to
-35
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is used by
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like reasonable functionality - where does it belong? And maybe it should be in two stages (i.e. |
||
|
|
||
| -- | Create sentences for a document in 'Doc' format. | ||
| sentenceDoc :: PrintingInformation -> SingleLine -> Sentence -> Doc | ||
| sentenceDoc pinfo sl s = specDoc sl (spec pinfo s) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These imports (of
SFileandSValue), as well asProcProg` all seem to point to something being odd here.