-
Notifications
You must be signed in to change notification settings - Fork 0
Frontend #11
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
Merged
Merged
Frontend #11
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
c349bd2
Frontend scaffold and type expression parsed
bladyjoker 892e8a3
Parse module name
bladyjoker f061665
Parse Sum body
bladyjoker 3570085
Parsed type definition
bladyjoker c1a50a3
Parsed module
bladyjoker f866837
Whitespace nad newlines
bladyjoker 692d746
Switched to using a Syntax DSL
bladyjoker 87dce69
Cleanup
bladyjoker 3834b53
Parsed module import statements
bladyjoker 003a901
Module resolution first draft
bladyjoker 4727561
Module scope imports
bladyjoker fd8bc43
Switched to using parametrized Syntax types
bladyjoker d8de131
Frontend CLI scaffold
bladyjoker d1fa860
lambda-buffers-frontend-cli compile -i resources/ -f Test.lbf
bladyjoker 1f825ce
Andrea and Vlad told me how to get rid of instance def boilerplate!
bladyjoker 80a1ba3
Added PPrint and sorted out error reporting
bladyjoker 1e85f4a
Added good examples
bladyjoker a2e5b32
Fixed strict builds
bladyjoker 82ec434
Fixed hoogle issues by removing additional
bladyjoker a8f2470
Minor cleanup
bladyjoker a2f94fd
Merge remote-tracking branch 'origin/main' into bladyjoker/frontend
bladyjoker a59dd1f
Fixed after merge issues
bladyjoker 4a06b4e
Cosmetic on compiler
bladyjoker 7655310
Scaffolded tests for the Frontend
bladyjoker 2787388
Added Frontend error tests
bladyjoker af67d90
Added simple good unit test
bladyjoker c5b8120
Implemented pretty printing and the `lambda-buffers-frontend-cli form…
bladyjoker 9f4b2cb
Applied review suggestions
bladyjoker b9baec0
Merge remote-tracking branch 'origin/main' into bladyjoker/frontend
bladyjoker d646a0e
Moved Frontend/FrontM.hs to Frontend.hs
bladyjoker e048d95
Added formatting unit test
bladyjoker c2145c3
Added documentation, FIXMEs and TODOs
bladyjoker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,9 +1,7 @@ | ||
{-# LANGUAGE ImportQualifiedPost #-} | ||
|
||
module Main (main) where | ||
|
||
import Test.KindCheck qualified as KC | ||
import Test.Tasty | ||
import Test.Tasty (defaultMain, testGroup) | ||
|
||
main :: IO () | ||
main = defaultMain $ testGroup "All Tests" [KC.test] | ||
main = defaultMain $ testGroup "Compiler tests" [KC.test] |
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake ..#dev-frontend |
26 changes: 26 additions & 0 deletions
26
lambda-buffers-frontend/app/LambdaBuffers/Frontend/Cli/Compile.hs
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module LambdaBuffers.Frontend.Cli.Compile (CompileOpts (..), compile) where | ||
|
||
import Control.Lens (makeLenses, (^.)) | ||
import Data.Map qualified as Map | ||
import LambdaBuffers.Frontend (runFrontend) | ||
import LambdaBuffers.Frontend.PPrint () | ||
import Prettyprinter (Pretty (pretty)) | ||
import Proto.Compiler () | ||
|
||
data CompileOpts = CompileOpts | ||
{ _importPaths :: [FilePath] | ||
, _moduleFilepath :: FilePath | ||
} | ||
deriving stock (Eq, Show) | ||
|
||
makeLenses ''CompileOpts | ||
|
||
-- | Compile a filepath containing a LambdaBuffers module | ||
compile :: CompileOpts -> IO () | ||
bladyjoker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
compile opts = do | ||
errOrMod <- runFrontend (opts ^. importPaths) (opts ^. moduleFilepath) | ||
case errOrMod of | ||
Left err -> print err | ||
Right mods -> do | ||
putStrLn "OK" | ||
putStrLn $ "Compiler closure contains the following modules: " <> (show . pretty . Map.elems $ mods) |
29 changes: 29 additions & 0 deletions
29
lambda-buffers-frontend/app/LambdaBuffers/Frontend/Cli/Format.hs
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module LambdaBuffers.Frontend.Cli.Format (FormatOpts (..), format) where | ||
|
||
import Control.Lens (makeLenses, (^.)) | ||
import Data.Text.IO qualified as Text | ||
import LambdaBuffers.Frontend.PPrint () | ||
import LambdaBuffers.Frontend.Parsec qualified as Parsec | ||
import Prettyprinter (Pretty (pretty)) | ||
import Proto.Compiler () | ||
|
||
data FormatOpts = FormatOpts | ||
{ _moduleFilepath :: FilePath | ||
, _inPlace :: Bool | ||
} | ||
deriving stock (Eq, Show) | ||
|
||
makeLenses ''FormatOpts | ||
|
||
-- | Format a LambdaBuffers file | ||
format :: FormatOpts -> IO () | ||
format opts = do | ||
modContent <- Text.readFile (opts ^. moduleFilepath) | ||
modOrErr <- Parsec.runParser Parsec.parseModule (opts ^. moduleFilepath) modContent | ||
case modOrErr of | ||
Left err -> print err | ||
Right m -> do | ||
let formatted = show . pretty $ m | ||
if opts ^. inPlace | ||
then Prelude.writeFile (opts ^. moduleFilepath) formatted | ||
else Prelude.putStrLn formatted |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.