-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This pr adds the `--statements` flag to `juvix dev latex export`. It can be used like this: ``` juvix dev latex export --statements "List; elem; find" List.juvix ``` All statements are selectable by their 'label'. The label of a statement is defined as: 1. The function/type/operator/alias/axiom/local_module/fixity/iterator name being defined. 2. The module name being imported. ## Limitations: 1. Only top statements are allowed. I.e. statements inside local modules cannot be selected. 1. Open statements are not selectable. Giving `--statements "My.Module"` will refer to the import statement `import My.Module`. 4. Single constructors are not selectable. Only the whole type definition. 5. No comments will be printed.
- Loading branch information
1 parent
206bed5
commit 2b5ece7
Showing
12 changed files
with
172 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,51 @@ | ||
module Juvix.Compiler.Concrete.Language | ||
( module Juvix.Compiler.Concrete.Language.Base, | ||
module Juvix.Compiler.Concrete.Language.IsApeInstances, | ||
module Juvix.Compiler.Concrete.Language, | ||
) | ||
where | ||
|
||
import Juvix.Compiler.Concrete.Data.ScopedName | ||
import Juvix.Compiler.Concrete.Language.Base | ||
import Juvix.Compiler.Concrete.Language.IsApeInstances | ||
import Juvix.Prelude | ||
|
||
symbolTypeLabel :: forall s. (SingI s) => Lens' (SymbolType s) Text | ||
symbolTypeLabel = case sing :: SStage s of | ||
SParsed -> withLocParam | ||
SScoped -> nameVerbatim | ||
|
||
modulePathTypeLabel :: forall s t. (SingI s, SingI t) => ModulePathType s t -> Text | ||
modulePathTypeLabel = case (sing :: SStage s, sing :: SModuleIsTop t) of | ||
(SParsed, SModuleTop) -> topModulePathToDottedPath | ||
(SParsed, SModuleLocal) -> (^. symbolTypeLabel) | ||
(SScoped, SModuleTop) -> (^. nameVerbatim) | ||
(SScoped, SModuleLocal) -> (^. symbolTypeLabel) | ||
|
||
-- | Returns a label for the given statement. Useful so that we can refer to | ||
-- statements from the CLI. This label may not be unique (e.g. for two import | ||
-- statements that import the same module). | ||
statementLabel :: forall s. (SingI s) => Statement s -> Maybe Text | ||
statementLabel = \case | ||
StatementSyntax s -> goSyntax s | ||
StatementOpenModule {} -> Nothing | ||
StatementProjectionDef {} -> Nothing | ||
StatementFunctionDef f -> Just (f ^. signName . symbolTypeLabel) | ||
StatementImport i -> Just (i ^. importModulePath . to modulePathTypeLabel) | ||
StatementInductive i -> Just (i ^. inductiveName . symbolTypeLabel) | ||
StatementModule i -> Just (i ^. modulePath . to modulePathTypeLabel) | ||
StatementAxiom a -> Just (a ^. axiomName . symbolTypeLabel) | ||
where | ||
goSyntax :: SyntaxDef s -> Maybe Text | ||
goSyntax = \case | ||
SyntaxFixity f -> Just (f ^. fixitySymbol . symbolTypeLabel) | ||
SyntaxOperator f -> Just (f ^. opSymbol . symbolTypeLabel) | ||
SyntaxIterator f -> Just (f ^. iterSymbol . symbolTypeLabel) | ||
SyntaxAlias f -> Just (f ^. aliasDefName . symbolTypeLabel) | ||
|
||
-- | Indexes top statements by label | ||
topStatementsByLabel :: (SingI s) => Module s t -> HashMap Text (Statement s) | ||
topStatementsByLabel m = | ||
hashMap | ||
[ (lbl, x) | x <- m ^. moduleBody, Just lbl <- [statementLabel x] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters