-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add support for .lblod files. - Add support for Case Split. - Add new Parse Error for Literate fails. - Add support for Add Clause. - Literate processing fails if code blocks are not separated by a blank line.
- Loading branch information
Showing
11 changed files
with
104 additions
and
42 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
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module Parser.Unlit | ||
|
||
%default total | ||
|
||
export | ||
isLitFile : String -> Bool | ||
isLitFile file = isSuffixOf ".lblod" file || isSuffixOf ".lidr" file | ||
|
||
data LineType = Blank | Code | Text | ||
|
||
lineType : String -> (LineType, String) | ||
lineType str = if length str > 0 | ||
then | ||
if assert_total (strHead str) == '>' | ||
then (Code, assert_total (strTail str)) | ||
else | ||
if all isSpace (unpack str) | ||
then (Blank, str) | ||
else (Text, str) | ||
else (Blank, str) | ||
|
||
export | ||
isLit : String -> (Bool, String) | ||
isLit str = case lineType str of | ||
(Code, tail) => (True, tail) | ||
_ => (False, str) | ||
|
||
export | ||
unlit : Bool -> Bool -> String -> Either (List Int) String | ||
unlit lit enforce str = if lit | ||
then let (_, lns, errors) = foldr unlit' (Blank, [], []) (lines str) in | ||
if enforce | ||
then case errors of | ||
[] => Right (unlines lns) | ||
_ => let l : Int = cast (length lns) in Left (map (l -) errors) | ||
else Right (unlines lns) | ||
else Right str where | ||
unlit' : String -> (LineType, List String, List Int) -> (LineType, List String, List Int) | ||
unlit' str (type, ls, errs) with (lineType str) | ||
unlit' str (Code, ls, errs) | (Text, _) = (Text, "" :: ls, cast (length ls) :: errs) | ||
unlit' str (Text, ls, errs) | (Code, s) = (Code, (strCons ' ' s) :: ls, cast (length ls) :: errs) | ||
unlit' str (type, ls, errs) | (Code, s) = (Code, (strCons ' ' s) :: ls, errs) | ||
unlit' str (type, ls, errs) | (new, s) = (new, "" :: ls, errs) | ||
|
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