Verified Commit f9383425 authored by Camil Staps's avatar Camil Staps 🚀

Remove Regex dependency

parent d49fc61e
...@@ -26,8 +26,6 @@ from Text import class Text(join,split,trim,rtrim), ...@@ -26,8 +26,6 @@ from Text import class Text(join,split,trim,rtrim),
import Text.Language import Text.Language
import Text.Parsers.Simple.ParserCombinators import Text.Parsers.Simple.ParserCombinators
import Regex
from Clean.Types import :: Type, :: TypeRestriction from Clean.Types import :: Type, :: TypeRestriction
import qualified Clean.Types.Parse as T import qualified Clean.Types.Parse as T
...@@ -148,16 +146,20 @@ docBlockToDoc{|OBJECT|} fx doc = appFst OBJECT <$> fx doc ...@@ -148,16 +146,20 @@ docBlockToDoc{|OBJECT|} fx doc = appFst OBJECT <$> fx doc
docBlockToDoc{|MultiLineString|} (Left [s]) = Right (MultiLine $ trimMultiLine $ split "\n" s, []) docBlockToDoc{|MultiLineString|} (Left [s]) = Right (MultiLine $ trimMultiLine $ split "\n" s, [])
docBlockToDoc{|ParamDoc|} (Left [s]) = case match rgx (fromString s) of docBlockToDoc{|ParamDoc|} (Left [s]) = case findName (fromString s) of
[(_,_,groups):_] -> Right ( Just (name,rest) -> Right (
{ name = toString <$> lookup (NotNamed 0) groups { name = Just $ toString name
, description = case lookup (NotNamed 1) groups of , description = case rest of
Just cs=:[_:_] -> Just (toString cs) [] -> Nothing
_ -> Nothing _ -> Just $ toString rest
}, []) }, [])
[] -> Right ({name=Nothing, description=Just s}, []) _ -> Right ({name=Nothing, description=Just s}, [])
where where
rgx = regex ['^(\\w+):\\s*(.*)$'] findName cs
# (name,cs) = span (\c -> isAlphanum c || c == '`') cs
| not (isEmpty name) && not (isEmpty cs) && hd cs == ':'
= Just (toString name, dropWhile isSpace (tl cs))
= Nothing
docBlockToDoc{|Type|} (Left []) = Left InternalNoDataError docBlockToDoc{|Type|} (Left []) = Left InternalNoDataError
docBlockToDoc{|Type|} (Left ss) = case [v \\ Just v <- map ('T'.parseType o fromString) ss] of docBlockToDoc{|Type|} (Left ss) = case [v \\ Just v <- map ('T'.parseType o fromString) ss] of
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment